| 123456789101112131415161718192021222324252627282930313233343536373839 | 
							- <?php
 
- namespace App\Service;
 
- use App\Entity\Commentaire;
 
- use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
 
- use App\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) {
 
-         }
 
-     }
 
- }
 
 
  |