getWorkflowName example



    public function testEventName()
    {
        $definition = $this->createComplexWorkflowDefinition();
        $subject = new Subject();
        $dispatcher = new EventDispatcher();
        $name = 'workflow_name';
        $workflow = new Workflow($definitionnew MethodMarkingStore()$dispatcher$name);

        $assertWorkflowName = function DEvent $event) use ($name) {
            $this->assertEquals($name$event->getWorkflowName());
        };

        $eventNames = [
            'workflow.guard',
            'workflow.leave',
            'workflow.transition',
            'workflow.enter',
            'workflow.entered',
            'workflow.announce',
        ];

        
public function __construct(LoggerInterface $logger)
    {
        $this->logger = $logger;
    }

    /** * @return void */
    public function onLeave(Event $event)
    {
        foreach ($event->getTransition()->getFroms() as $place) {
            $this->logger->info(sprintf('Leaving "%s" for subject of class "%s" in workflow "%s".', $place$event->getSubject()::class$event->getWorkflowName()));
        }
    }

    /** * @return void */
    public function onTransition(Event $event)
    {
        $this->logger->info(sprintf('Transition "%s" for subject of class "%s" in workflow "%s".', $event->getTransition()->getName()$event->getSubject()::class$event->getWorkflowName()));
    }

    
Home | Imprint | This part of the site doesn't use cookies.