src/EventSubscriber/SampleWorkflowSubscriber.php line 57

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use App\Service\Subscription\SubscriptionService;
  4. use App\Service\UserLog;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. use Symfony\Component\Security\Core\Security;
  8. use Symfony\Component\Workflow\Event\Event;
  9. use App\Service\Log\QuotationLogService;
  10. use Symfony\Component\Workflow\Registry;
  11. class SampleWorkflowSubscriber implements EventSubscriberInterface
  12. {
  13.     private $security;
  14.     private $logService;
  15.     private $userLog;
  16.     private $workflows;
  17.     private $em;
  18.     private $subscriptionService;
  19.     public function __construct(
  20.         Security $security,
  21.         QuotationLogService $logService,
  22.         Registry $workflows,
  23.         UserLog $userLog,
  24.         SubscriptionService $subscriptionService,
  25.         EntityManagerInterface $em
  26.     )
  27.     {
  28.         $this->em $em;
  29.         $this->workflows $workflows;
  30.         $this->security $security;
  31.         $this->subscriptionService $subscriptionService;
  32.         $this->logService $logService;
  33.         $this->userLog $userLog;
  34.     }
  35.     public static function getSubscribedEvents()
  36.     {
  37.         return [
  38.             'workflow.sample_status.completed.to_producing' => [
  39.                 ['createSubscriptions']
  40.             ],
  41.             'workflow.sample_status.announce' => [
  42.                 ['sampleStatusChangeNotify']
  43.             ],
  44.         ];
  45.     }
  46.     public function createSubscriptions(Event $event)
  47.     {
  48.         $this->subscriptionService->generateSubscriptions($event->getSubject(), $event->getSubject()->getCreatedBy());
  49.     }
  50.     public function sampleStatusChangeNotify(Event $event)
  51.     {
  52.         $this->subscriptionService->proceedEvent(
  53.             'sample.transition.' $event->getTransition()->getName(),
  54.             $event->getSubject(),
  55.             [
  56.             'data' => [
  57.                 'uuid' => $event->getSubject()->getUuid()
  58.             ],
  59.             'action_name' => 'sampleStatusChangeNotify',
  60.             ]
  61.         );
  62.     }
  63. }