Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit08a12ec

Browse files
committed
[Workflow] Document the EventNameTrait
1 parent3dba331 commit08a12ec

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

‎workflow.rst‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ workflow leaves a place::
496496
use Psr\Log\LoggerInterface;
497497
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
498498
use Symfony\Component\Workflow\Event\Event;
499+
use Symfony\Component\Workflow\Event\LeaveEvent;
499500

500501
class WorkflowLoggerSubscriber implements EventSubscriberInterface
501502
{
@@ -518,11 +519,24 @@ workflow leaves a place::
518519
public static function getSubscribedEvents(): array
519520
{
520521
return [
521-
'workflow.blog_publishing.leave' => 'onLeave',
522+
LeaveEvent::getName('blog_publishing') => 'onLeave',
523+
// if you prefer, you can write the event name manually like this:
524+
// 'workflow.blog_publishing.leave' => 'onLeave',
522525
];
523526
}
524527
}
525528

529+
..tip::
530+
531+
All built-in workflow events define the ``getName(?string $workflowName, ?string $transitionOrPlaceName)``
532+
method to build the full event name without having to deal with strings.
533+
You can also use this method in your custom events via the
534+
:class:`Symfony\\Component\\Workflow\\Event\\EventNameTrait`.
535+
536+
..versionadded::7.1
537+
538+
The ``getName()`` method was introduced in Symfony 7.1.
539+
526540
If some listeners update the context during a transition, you can retrieve
527541
it via the marking::
528542

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp