44
55namespace CodeRhapsodie \EzDataflowBundle \Controller ;
66
7+ use CodeRhapsodie \DataflowBundle \Entity \ScheduledDataflow ;
78use CodeRhapsodie \EzDataflowBundle \Form \CreateScheduledType ;
89use CodeRhapsodie \EzDataflowBundle \Form \UpdateScheduledType ;
9- use CodeRhapsodie \EzDataflowBundle \Gateway \ScheduledDataflowGateway ;
1010use CodeRhapsodie \EzDataflowBundle \Gateway \JobGateway ;
11- use CodeRhapsodie \DataflowBundle \ Entity \ ScheduledDataflow ;
11+ use CodeRhapsodie \EzDataflowBundle \ Gateway \ ScheduledDataflowGateway ;
1212use eZ \Publish \Core \MVC \Symfony \Security \Authorization \Attribute ;
1313use EzSystems \EzPlatformAdminUi \Notification \NotificationHandlerInterface ;
1414use EzSystems \EzPlatformAdminUiBundle \Controller \Controller ;
1515use Symfony \Component \HttpFoundation \JsonResponse ;
1616use Symfony \Component \HttpFoundation \Request ;
1717use Symfony \Component \HttpFoundation \Response ;
1818use Symfony \Component \Routing \Annotation \Route ;
19- use Symfony \Component \Translation \TranslatorInterface ;
19+ use Symfony \Contracts \Translation \TranslatorInterface ;
2020
2121/**
2222 * @Route("/ezdataflow/scheduled_workflow")
@@ -32,8 +32,12 @@ class ScheduledDataflowController extends Controller
3232 /** @var TranslatorInterface */
3333 private $ translator ;
3434
35- public function __construct (JobGateway $ jobGateway , NotificationHandlerInterface $ notificationHandler , ScheduledDataflowGateway $ scheduledDataflowGateway , TranslatorInterface $ translator )
36- {
35+ public function __construct (
36+ JobGateway $ jobGateway ,
37+ NotificationHandlerInterface $ notificationHandler ,
38+ ScheduledDataflowGateway $ scheduledDataflowGateway ,
39+ TranslatorInterface $ translator
40+ ) {
3741 $ this ->jobGateway = $ jobGateway ;
3842 $ this ->notificationHandler = $ notificationHandler ;
3943 $ this ->scheduledDataflowGateway = $ scheduledDataflowGateway ;
@@ -42,10 +46,6 @@ public function __construct(JobGateway $jobGateway, NotificationHandlerInterface
4246
4347 /**
4448 * @Route("/create", name="coderhapsodie.ezdataflow.workflow.create", methods={"POST"})
45- *
46- * @param Request $request
47- *
48- * @return Response
4949 */
5050 public function create (Request $ request ): Response
5151 {
@@ -63,7 +63,8 @@ public function create(Request $request): Response
6363 $ this ->scheduledDataflowGateway ->save ($ newWorkflow );
6464 $ this ->notificationHandler ->success ($ this ->translator ->trans ('coderhapsodie.ezdataflow.workflow.create.success ' ));
6565 } catch (\Exception $ e ) {
66- $ this ->notificationHandler ->error ($ this ->translator ->trans ('coderhapsodie.ezdataflow.workflow.create.error ' , ['message ' => $ e ->getMessage ()]));
66+ $ this ->notificationHandler ->error ($ this ->translator ->trans ('coderhapsodie.ezdataflow.workflow.create.error ' ,
67+ ['message ' => $ e ->getMessage ()]));
6768 }
6869
6970 return new JsonResponse (['redirect ' => $ this ->generateUrl ('coderhapsodie.ezdataflow.main ' )]);
@@ -79,10 +80,6 @@ public function create(Request $request): Response
7980
8081 /**
8182 * @Route("/{id}/delete", name="coderhapsodie.ezdataflow.workflow.delete", methods={"post"})
82- *
83- * @param int $id
84- *
85- * @return Response
8683 */
8784 public function delete (int $ id ): Response
8885 {
@@ -94,19 +91,15 @@ public function delete(int $id): Response
9491
9592 return new JsonResponse (['code ' => 200 ]);
9693 } catch (\Exception $ e ) {
97- $ this ->notificationHandler ->error ($ this ->translator ->trans ('coderhapsodie.ezdataflow.workflow.delete.error ' , ['message ' => $ e ->getMessage ()]));
94+ $ this ->notificationHandler ->error ($ this ->translator ->trans ('coderhapsodie.ezdataflow.workflow.delete.error ' ,
95+ ['message ' => $ e ->getMessage ()]));
9896
9997 return new JsonResponse (['code ' => $ e ->getCode ()]);
10098 }
10199 }
102100
103101 /**
104102 * @Route("/{id}/edit", name="coderhapsodie.ezdataflow.workflow.edit")
105- *
106- * @param Request $request
107- * @param int $id
108- *
109- * @return Response
110103 */
111104 public function edit (Request $ request , int $ id ): Response
112105 {
@@ -123,7 +116,8 @@ public function edit(Request $request, int $id): Response
123116 $ this ->scheduledDataflowGateway ->save ($ editDataflow );
124117 $ this ->notificationHandler ->success ($ this ->translator ->trans ('coderhapsodie.ezdataflow.workflow.edit.success ' ));
125118 } catch (\Exception $ e ) {
126- $ this ->notificationHandler ->error ($ this ->translator ->trans ('coderhapsodie.ezdataflow.workflow.edit.error ' , ['message ' => $ e ->getMessage ()]));
119+ $ this ->notificationHandler ->error ($ this ->translator ->trans ('coderhapsodie.ezdataflow.workflow.edit.error ' ,
120+ ['message ' => $ e ->getMessage ()]));
127121 }
128122
129123 return new JsonResponse (['redirect ' => $ this ->generateUrl ('coderhapsodie.ezdataflow.main ' )]);
@@ -139,10 +133,6 @@ public function edit(Request $request, int $id): Response
139133
140134 /**
141135 * @Route("/{id}/enable", name="coderhapsodie.ezdataflow.workflow.enable")
142- *
143- * @param int $id
144- *
145- * @return Response
146136 */
147137 public function enableDataflow (int $ id ): Response
148138 {
@@ -153,22 +143,6 @@ public function enableDataflow(int $id): Response
153143 return $ this ->redirectToRoute ('coderhapsodie.ezdataflow.main ' );
154144 }
155145
156- /**
157- * @Route("/{id}/disable", name="coderhapsodie.ezdataflow.workflow.disable")
158- *
159- * @param int $id
160- *
161- * @return Response
162- */
163- public function disableDataflow (int $ id ): Response
164- {
165- $ this ->denyAccessUnlessGranted (new Attribute ('ezdataflow ' , 'edit ' ));
166-
167- $ this ->changeDataflowStatus ($ id , false );
168-
169- return $ this ->redirectToRoute ('coderhapsodie.ezdataflow.main ' );
170- }
171-
172146 private function changeDataflowStatus (int $ id , bool $ status )
173147 {
174148 try {
@@ -182,4 +156,16 @@ private function changeDataflowStatus(int $id, bool $status)
182156 $ this ->notificationHandler ->error (sprintf ('An error occured : "%s". ' , $ e ->getMessage ()));
183157 }
184158 }
159+
160+ /**
161+ * @Route("/{id}/disable", name="coderhapsodie.ezdataflow.workflow.disable")
162+ */
163+ public function disableDataflow (int $ id ): Response
164+ {
165+ $ this ->denyAccessUnlessGranted (new Attribute ('ezdataflow ' , 'edit ' ));
166+
167+ $ this ->changeDataflowStatus ($ id , false );
168+
169+ return $ this ->redirectToRoute ('coderhapsodie.ezdataflow.main ' );
170+ }
185171}
0 commit comments