<?php declare(strict_types=1); /* * This file is part of newsmailer bundle for Contao. * * (c) Benjamin Roth * * @license LGPL-3.0-or-later */ namespace vonRotenberg\NewsmailerBundle\EventListener; use Contao\CoreBundle\ServiceAnnotation\Callback; use Contao\Database; use Contao\DataContainer; /** * @Callback(table="tl_news_archive", target="fields.nc_notification.options") */ class NewsArchiveNotificationOptionsListener { public function __invoke(DataContainer $dc) { $arrOptions = array(); $objNotifications = Database::getInstance()->execute("SELECT id,title FROM tl_nc_notification WHERE type='news_submitted' ORDER BY title"); while ($objNotifications->next()) { $arrOptions[$objNotifications->id] = $objNotifications->title; } return $arrOptions; } }