Add entity lifecycle listener for emoji sanitisation
[MAILPOET-3196]
This commit is contained in:
committed by
Veljko V
parent
7449d3df3e
commit
96f2bfaa20
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace MailPoet\Doctrine;
|
||||
|
||||
use MailPoet\Doctrine\EventListeners\EmojiEncodingListener;
|
||||
use MailPoet\Doctrine\EventListeners\TimestampListener;
|
||||
use MailPoet\Doctrine\EventListeners\ValidationListener;
|
||||
use MailPoet\Tracy\DoctrinePanel\DoctrinePanel;
|
||||
@@ -25,16 +26,21 @@ class EntityManagerFactory {
|
||||
/** @var ValidationListener */
|
||||
private $validationListener;
|
||||
|
||||
/** @var EmojiEncodingListener */
|
||||
private $emojiEncodingListener;
|
||||
|
||||
public function __construct(
|
||||
Connection $connection,
|
||||
Configuration $configuration,
|
||||
TimestampListener $timestampListener,
|
||||
ValidationListener $validationListener
|
||||
ValidationListener $validationListener,
|
||||
EmojiEncodingListener $emojiEncodingListener
|
||||
) {
|
||||
$this->connection = $connection;
|
||||
$this->configuration = $configuration;
|
||||
$this->timestampListener = $timestampListener;
|
||||
$this->validationListener = $validationListener;
|
||||
$this->emojiEncodingListener = $emojiEncodingListener;
|
||||
}
|
||||
|
||||
public function createEntityManager() {
|
||||
@@ -56,5 +62,10 @@ class EntityManagerFactory {
|
||||
[Events::onFlush],
|
||||
$this->validationListener
|
||||
);
|
||||
|
||||
$entityManager->getEventManager()->addEventListener(
|
||||
[Events::prePersist, Events::preUpdate],
|
||||
$this->emojiEncodingListener
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user