| 
					
				 | 
			
			
				@@ -7,10 +7,12 @@ use App\Form\ArticleType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use App\Repository\ArticleRepository; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use Doctrine\ORM\EntityManagerInterface; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use Symfony\Component\DependencyInjection\Attribute\Target; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use Symfony\Component\HttpFoundation\Request; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use Symfony\Component\HttpFoundation\Response; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use Symfony\Component\Routing\Attribute\Route; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 use Symfony\Component\Security\Http\Attribute\IsGranted; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+use Symfony\Component\Workflow\WorkflowInterface; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #[Route('/article')] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 #[IsGranted('ROLE_AUTHOR')] 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -25,13 +27,33 @@ final class ArticleController extends AbstractController 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     #[Route('/new', name: 'app_article_new', methods: ['GET', 'POST'])] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public function new(Request $request, EntityManagerInterface $entityManager): Response 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public function new( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Request $request, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        EntityManagerInterface $entityManager, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        #[Target('blog_publishing')] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        WorkflowInterface $workflow 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ): Response 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $article = new Article($this->getUser()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $form = $this->createForm(ArticleType::class, $article); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $workflow->getMarking($article); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $transitions = $workflow->getEnabledTransitions($article); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $transitionsChoice = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        foreach($transitions as $transition) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $transitionsChoice[$transition->getName()] = $transition->getName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $form = $this->createForm(ArticleType::class, $article, [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'transitions' => $transitionsChoice 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $form->handleRequest($request); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if ($form->isSubmitted() && $form->isValid()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $publicationChoice = $form->get('publicationChoice')->getData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if ($publicationChoice !== "") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $workflow->apply($article, $publicationChoice); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             $entityManager->persist($article); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             $entityManager->flush(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -55,12 +77,32 @@ final class ArticleController extends AbstractController 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     #[Route('/{id}/edit', name: 'app_article_edit', methods: ['GET', 'POST'])] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     #[IsGranted('edit', 'article')] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public function edit(Request $request, Article $article, EntityManagerInterface $entityManager): Response 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public function edit( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Request $request, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Article $article, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        EntityManagerInterface $entityManager, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        #[Target('blog_publishing')] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        WorkflowInterface $workflow 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ): Response 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $form = $this->createForm(ArticleType::class, $article); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $transitions = $workflow->getEnabledTransitions($article); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $transitionsChoice = []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        foreach($transitions as $transition) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $transitionsChoice[$transition->getName()] = $transition->getName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+         
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $form = $this->createForm(ArticleType::class, $article, [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            'transitions' => $transitionsChoice 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $form->handleRequest($request); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if ($form->isSubmitted() && $form->isValid()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $publicationChoice = $form->get('publicationChoice')->getData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if ($publicationChoice !== "") { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $workflow->apply($article, $publicationChoice); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             $entityManager->flush(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return $this->redirectToRoute('app_article_index', [], Response::HTTP_SEE_OTHER); 
			 |