The workflow functionality passes a Content item version through a series of stages.
For example, an editorial workflow can pass a Content item from draft stage through design and proofreading.
You can define different workflow in configuration. The workflow is permission-aware.
Each workflow consists of stages and transitions between them.
The following configuration defines a workflow where you can pass a draft to technical review, then to proofreading, and to final approval.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
Each stage in the workflow has an identifier and can be assigned a label and a color (lines 16-18).
Each transition also has an identifier. It must state between which stages it transitions, or be marked as
reverse of a different transition.
Transitions can also have labels and icons (lines 36-37).
notification (lines 64-67) defines who will be notified when a transition happens by providing the User or User Group ID.
Notifications will be displayed in the user menu.
You can view all configured workflows in the Admin Panel by selecting Workflow.
You can limit access to workflows at stage and transition level.
workflow/change_stage Policy to grant a User permission to change stages in a specific workflow.
This Policy can be limited with the Workflow Transition Limitation to only allow sending content in the allowed transition.
For example, using the example above, a
workflow/change_stage Policy with
WorkflowTransitionLimitation set to
will allow the Technical team to send content to proofreading after they are done with technical review.
You can also use the Workflow Stage Limitation together with the
content/publish Policy to limit the ability to edit content in specific stages.
For example, you can use it to only allow Technical team to edit content in the
Workflow makes use of the Symfony Workflow Component, but special eZ Platform treatment is covered in the Workflow service.
The service implements the following methods:
start- places a Content item in a workflow
apply- performs a transition
can- checks if a transition is possible
can are the same as in Symfony Workflow, but the implementation in Workflow Service
extends them, for example by providing messages.
You can also use the following methods to read information about workflow from the database:
loadWorkflowMetadataForContent- reads all workflow information about a Content item (as
loadWorkflowMetadataOriginatedByUser- reads all workflow actions performed by the provided user (as
loadAllWorkflowMetadata- reads all workflow information from the system
\EzSystems\EzPlatformWorkflow\Value\WorkflowMetadata object contains all information about a workflow, such as ID, name, transitions and current stage.
\EzSystems\EzPlatformWorkflow\Value\WorkflowMetadata::$workflow gives you direct access to native Symfony Workflow object.
Publishing content with workflow¶
The workflow functionality only operates on workflow stages. It does not perform operations on content, such as publishing it, out of the box.
This means it does not automatically publish a Content item when it reaches the final stage of a workflow. It can be done with a custom implementation.
Publish content that reaches final stage¶
To publish a Content item once it reaches the final stage of a workflow, you need to set up an event subscriber.
You can use the
PublishOnLastStageSubscriber.php from eZ Platform demo as a basis for the subscriber.
The subscriber must be registered as a service:
1 2 3 4 5
You must also provide the identifier of the workflow you want the subscriber to apply to.
Do it in the
Finish workflow for published content¶
With proper permissions, you can publish content even before it has gone through a whole workflow. Afterward it will still be visible in the review queue and in the relevant stage of Content item(s) under review tab under Workflow in the Admin panel.
To avoid cluttering the tables with published content, you can use an event subscriber which will automatically move content to the last stage of the workflow after it has been published.
You can use the
EndWorkflowSubscriber.php from eZ Platform demo as a basis for the subscriber.
doEndWorkflows() function in the example
applies all transitions that are needed to bring the Content item to the final workflow stage.
The subscriber must also be registered as a service:
1 2 3