Add listener for updating lastSubscribedAt

[MAILPOET-3031]
This commit is contained in:
Jan Lysý
2021-03-22 19:44:12 +01:00
committed by Veljko V
parent 91b2a11643
commit fd5a9904c0
6 changed files with 87 additions and 4 deletions

View File

@ -3,6 +3,7 @@
namespace MailPoet\Doctrine;
use MailPoet\Doctrine\EventListeners\EmojiEncodingListener;
use MailPoet\Doctrine\EventListeners\LastSubscribedAtListener;
use MailPoet\Doctrine\EventListeners\TimestampListener;
use MailPoet\Doctrine\EventListeners\ValidationListener;
use MailPoet\Tracy\DoctrinePanel\DoctrinePanel;
@ -29,18 +30,23 @@ class EntityManagerFactory {
/** @var EmojiEncodingListener */
private $emojiEncodingListener;
/** @var LastSubscribedAtListener */
private $lastSubscribedAtListener;
public function __construct(
Connection $connection,
Configuration $configuration,
TimestampListener $timestampListener,
ValidationListener $validationListener,
EmojiEncodingListener $emojiEncodingListener
EmojiEncodingListener $emojiEncodingListener,
LastSubscribedAtListener $lastSubscribedAtListener
) {
$this->connection = $connection;
$this->configuration = $configuration;
$this->timestampListener = $timestampListener;
$this->validationListener = $validationListener;
$this->emojiEncodingListener = $emojiEncodingListener;
$this->lastSubscribedAtListener = $lastSubscribedAtListener;
}
public function createEntityManager() {
@ -67,5 +73,10 @@ class EntityManagerFactory {
[Events::prePersist, Events::preUpdate],
$this->emojiEncodingListener
);
$entityManager->getEventManager()->addEventListener(
[Events::prePersist, Events::preUpdate],
$this->lastSubscribedAtListener
);
}
}