99use CodeRhapsodie \DataflowBundle \Entity \Job ;
1010use CodeRhapsodie \DataflowBundle \Event \Events ;
1111use CodeRhapsodie \DataflowBundle \Event \ProcessingEvent ;
12+ use CodeRhapsodie \DataflowBundle \Gateway \JobGateway ;
1213use CodeRhapsodie \DataflowBundle \Logger \BufferHandler ;
1314use CodeRhapsodie \DataflowBundle \Logger \DelegatingLogger ;
1415use CodeRhapsodie \DataflowBundle \Registry \DataflowTypeRegistryInterface ;
@@ -27,7 +28,7 @@ public function __construct(
2728 private JobRepository $ repository ,
2829 private DataflowTypeRegistryInterface $ registry ,
2930 private EventDispatcherInterface $ dispatcher ,
30- private ? Filesystem $ filesystem = null
31+ private JobGateway $ jobGateway ,
3132 )
3233 {
3334 }
@@ -70,25 +71,19 @@ private function beforeProcessing(Job $job): void
7071 ->setStatus (Job::STATUS_RUNNING )
7172 ->setStartTime (new \DateTime ())
7273 ;
73- $ this ->repository ->save ($ job );
74+ $ this ->jobGateway ->save ($ job );
7475 }
7576
7677 private function afterProcessing (Job $ job , Result $ result , BufferHandler $ bufferLogger ): void
7778 {
78- $ exceptions = $ bufferLogger ->clearBuffer ();
79- if ($ this ->filesystem ) {
80- $ this ->filesystem ->write (sprintf ('dataflow-job-%s.log ' ,$ job ->getId ()), json_encode ($ exceptions ));
81- $ exceptions = [];
82- }
83-
8479 $ job
8580 ->setEndTime ($ result ->getEndTime ())
8681 ->setStatus (Job::STATUS_COMPLETED )
8782 ->setCount ($ result ->getSuccessCount ())
88- ->setExceptions ($ exceptions )
83+ ->setExceptions ($ bufferLogger -> clearBuffer () )
8984 ;
9085
91- $ this ->repository ->save ($ job );
86+ $ this ->jobGateway ->save ($ job );
9287
9388 $ this ->dispatcher ->dispatch (new ProcessingEvent ($ job ), Events::AFTER_PROCESSING );
9489 }
0 commit comments