Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions reference/attributes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ Each validation constraint comes with a PHP attribute. See

* :doc:`HasNamedArgument </validation/custom_constraint>`

Workflow
~~~~~~~~

* :ref:`AsAnnounceListener <workflow_using-events>`
* :ref:`AsCompletedListener <workflow_using-events>`
* :ref:`AsEnterListener <workflow_using-events>`
* :ref:`AsEnteredListener <workflow_using-events>`
* :ref:`AsGuardListener <workflow_using-events>`
* :ref:`AsLeaveListener <workflow_using-events>`
* :ref:`AsTransitionListener <workflow_using-events>`

.. _`AsEntityAutocompleteField`: https://symfony.com/bundles/ux-autocomplete/current/index.html#usage-in-a-form-with-ajax
.. _`AsLiveComponent`: https://symfony.com/bundles/ux-live-component/current/index.html
.. _`AsTwigComponent`: https://symfony.com/bundles/ux-twig-component/current/index.html
Expand Down
36 changes: 36 additions & 0 deletions workflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ name.
You can find the list of available workflow services with the
``php bin/console debug:autowiring workflow`` command.

.. _workflow_using-events:

Using Events
------------

Expand Down Expand Up @@ -519,6 +521,40 @@ it via the marking::
// contains the new value
$marking->getContext();

It is also possible to listen to these events by declaring event listeners
with the following attributes:

* :class:`Symfony\\Component\\Workflow\\Attribute\\AsAnnounceListener`
* :class:`Symfony\\Component\\Workflow\\Attribute\\AsCompletedListener`
* :class:`Symfony\\Component\\Workflow\\Attribute\\AsEnterListener`
* :class:`Symfony\\Component\\Workflow\\Attribute\\AsEnteredListener`
* :class:`Symfony\\Component\\Workflow\\Attribute\\AsGuardListener`
* :class:`Symfony\\Component\\Workflow\\Attribute\\AsLeaveListener`
* :class:`Symfony\\Component\\Workflow\\Attribute\\AsTransitionListener`

These attributes do work like the
:class:`Symfony\\Component\\EventDispatcher\\Attribute\\AsEventListener`
attributes::

class ArticleWorkflowEventListener
{
#[AsTransitionListener(workflow: 'my-workflow', transition: 'published')]
public function onPublishedTransition(TransitionEvent $event): void
{
// ...
}

// ...
}

You may refer to the documentation about
:ref:`defining event listeners with PHP attributes <event-dispatcher_event-listener-attributes>`
for further use.

.. versionadded:: 6.4

The workflow event attributes were introduced in Symfony 6.4.

.. _workflow-usage-guard-events:

Guard Events
Expand Down