mattermostSender = $mattermostSender; } public function postPersist(LifecycleEventArgs $args) { $entity = $args->getObject(); if (!$entity instanceof Film and !$entity instanceof Commentaire) { return; } try { if ($entity instanceof Film) $this->mattermostSender->sendNouveauFilm($entity); else $this->mattermostSender->sendNouveauCommentaire($entity->getUser(), $entity->getFilm()); } catch (Exception $exception) { } } }