| 
					
				 | 
			
			
				@@ -5,7 +5,8 @@ namespace App\Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use App\Entity\Film; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use App\Entity\User; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-use Symfony\Component\Routing\Generator\UrlGeneratorInterface; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use Symfony\Component\Routing\Generator\UrlGeneratorInterface;; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * Envoi notifs mattermost 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -17,38 +18,49 @@ class Mattermost 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     protected $channelId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     protected $channelIdAdmin; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     protected $router; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected $flashBagInterface; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * Mattermost Manager 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public function __construct($url, $token, $channelId, $channelIdAdmin, UrlGeneratorInterface $router) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public function __construct($url, $token, $channelId, $channelIdAdmin, UrlGeneratorInterface $router, FlashBagInterface $flashBagInterface) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $this->url = $url . "/api/v4/posts"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $this->token = $token; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $this->channelId = $channelId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $this->channelIdAdmin = $channelIdAdmin; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $this->router = $router; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $this->flashBagInterface = $flashBagInterface; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     protected function SendNotif($message, $isChanAdmin = False) :void 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // crée une nouvelle ressource cURL 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $ch = curl_init(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // fixe l'URL et les autres options appropriées 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $options = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            CURLOPT_URL => $this->url, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            CURLOPT_HTTPHEADER => array('Content-Type: application/json', 'Authorization: Bearer ' . $this->token), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            CURLOPT_POSTFIELDS  =>  '{"channel_id": "' . ($isChanAdmin ? $this->channelIdAdmin : $this->channelId) . '", "message": "' . $message . '"}' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        curl_setopt_array($ch, $options); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // attrape l'URL et la passe au navigateur 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        curl_exec($ch); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // ferme la ressource cURL et libère les ressources systèmes 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        curl_close($ch); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (function_exists("curl_init")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // crée une nouvelle ressource cURL 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $ch = curl_init(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw new \Exception("Curl n'est pas installé.", 500); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // fixe l'URL et les autres options appropriées 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $options = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                CURLOPT_URL => $this->url, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                CURLOPT_HTTPHEADER => array('Content-Type: application/json', 'Authorization: Bearer ' . $this->token), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                CURLOPT_POSTFIELDS  =>  '{"channel_id": "' . ($isChanAdmin ? $this->channelIdAdmin : $this->channelId) . '", "message": "' . $message . '"}' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            curl_setopt_array($ch, $options); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // attrape l'URL et la passe au navigateur 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            curl_exec($ch); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // ferme la ressource cURL et libère les ressources systèmes 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            curl_close($ch); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (\Exception $e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $this->flashBagInterface->add('error', "L'envoi vers mattermost a échoué."); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public function sendNouveauFilm(Film $film) :void 
			 |