<?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_member", target="fields.nc_news_subscribe.save") */ class MemberNcNewsNotificationChangedateListener { public function __invoke($varValue, $context) { if ($context instanceof DataContainer) { $context = $context->activeRecord; } if ($varValue != $context->nc_news_subscribe) { Database::getInstance()->prepare("UPDATE tl_member SET nc_news_subscribe_changed=? WHERE id=?")->execute(array(time(),$context->id)); } return $varValue; } }