Skip to content

Commit

Permalink
Code Quality
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Aug 13, 2024
1 parent 501ca3e commit eecd6a3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
14 changes: 13 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
"contao/news-bundle": "^4.13 || ^5.0",
"contao/newsletter-bundle": "^4.13 || ^5.0",
"codefog/contao-haste": "^5.0",
"terminal42/notification_center": "^2.0"
"terminal42/notification_center": "^2.0",
"doctrine/dbal": "^3.0",
"symfony/config": "^5 || ^6 || ^7",
"symfony/dependency-injection": "^5 || ^6 || ^7",
"symfony/http-kernel": "^5 || ^6 || ^7"
},
"require-dev": {
"contao/manager-plugin": "^2.0",
Expand All @@ -47,5 +51,13 @@
},
"extra": {
"contao-manager-plugin": "Terminal42\\NewsNewsletterBundle\\ContaoManager\\Plugin"
},
"config": {
"allow-plugins": {
"contao-components/installer": false,
"php-http/discovery": false,
"contao/manager-plugin": false,
"terminal42/contao-build-tools": true
}
}
}
3 changes: 3 additions & 0 deletions src/EventListener/NotificationOptionsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public function __construct(private readonly NotificationCenter $notificationCen
{
}

/**
* @return array<int, string>
*/
public function __invoke(): array
{
return $this->notificationCenter->getNotificationsForNotificationType(NewsNewsletterNotificationType::NAME);
Expand Down
15 changes: 8 additions & 7 deletions src/EventListener/SendNewsletterListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ public function __construct(
}

/**
* @param string|null $href
* @param string|null $label
* @param string|null $title
* @param string|null $icon
* @param array<string, string|int> $row
* @param string|null $href
* @param string|null $label
* @param string|null $title
* @param string|null $icon
*/
public function __invoke(array $row, $href, $label, $title, $icon): string
{
$archive = NewsArchiveModel::findByPk($row['pid']);
$archive = NewsArchiveModel::findById($row['pid']);

if (null === $archive || !$archive->newsletter || !$archive->newsletter_channel || !$archive->nc_notification) {
return '';
Expand All @@ -63,14 +64,14 @@ public function __invoke(array $row, $href, $label, $title, $icon): string

// Add the confirmation popup
$intRecipients = NewsletterRecipientsModel::countBy(["pid=? AND active='1'"], $archive->newsletter_channel);
$attributes = 'onclick="if(!confirm(\''.sprintf($GLOBALS['TL_LANG']['tl_news']['sendNewsletterConfirm'], $intRecipients).'\'))return false;Backend.getScrollOffset()"';
$attributes = 'onclick="if(!confirm(\''.\sprintf($GLOBALS['TL_LANG']['tl_news']['sendNewsletterConfirm'], $intRecipients).'\'))return false;Backend.getScrollOffset()"';

return '<a href="'.Backend::addToUrl($href.'&newsletter='.$row['id']).'" title="'.StringUtil::specialchars($title).'"'.$attributes.'>'.Image::getHtml($icon, $label).'</a> ';
}

private function sendNewsMessage(int $newsletterId): bool
{
$news = NewsModel::findByPk($newsletterId);
$news = NewsModel::findById($newsletterId);

if (null === $news) {
return false;
Expand Down

0 comments on commit eecd6a3

Please sign in to comment.