123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace AppBundle\Service;
- use AppBundle\Entity\Commentaire;
- use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
- use AppBundle\Entity\Film;
- use Symfony\Component\Config\Definition\Exception\Exception;
- class FilmCreationListener
- {
- /**
- * var mattermostSender
- */
- private $mattermostSender;
- public function __construct(Mattermost $mattermostSender)
- {
- $this->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) {
- }
- }
- }
|