<?php
namespace App\EventSubscriber;
use App\Service\Subscription\SubscriptionService;
use App\Service\UserLog;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Workflow\Event\Event;
use App\Service\Log\QuotationLogService;
use Symfony\Component\Workflow\Registry;
class SampleWorkflowSubscriber implements EventSubscriberInterface
{
private $security;
private $logService;
private $userLog;
private $workflows;
private $em;
private $subscriptionService;
public function __construct(
Security $security,
QuotationLogService $logService,
Registry $workflows,
UserLog $userLog,
SubscriptionService $subscriptionService,
EntityManagerInterface $em
)
{
$this->em = $em;
$this->workflows = $workflows;
$this->security = $security;
$this->subscriptionService = $subscriptionService;
$this->logService = $logService;
$this->userLog = $userLog;
}
public static function getSubscribedEvents()
{
return [
'workflow.sample_status.completed.to_producing' => [
['createSubscriptions']
],
'workflow.sample_status.announce' => [
['sampleStatusChangeNotify']
],
];
}
public function createSubscriptions(Event $event)
{
$this->subscriptionService->generateSubscriptions($event->getSubject(), $event->getSubject()->getCreatedBy());
}
public function sampleStatusChangeNotify(Event $event)
{
$this->subscriptionService->proceedEvent(
'sample.transition.' . $event->getTransition()->getName(),
$event->getSubject(),
[
'data' => [
'uuid' => $event->getSubject()->getUuid()
],
'action_name' => 'sampleStatusChangeNotify',
]
);
}
}