@@ -1306,11 +1306,11 @@ In Twig templates, metadata is available via the ``workflow_metadata()`` functio
13061306 </ul>
13071307 </p>
13081308
1309- Adding Custom Definition Validators
1310- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1309+ Validating Workflow Definitions
1310+ -------------------------------
13111311
1312- Sometimes, you may want to add custom logics to validate your workflow definition .
1313- To do this, you need to implement the
1312+ Symfony allows you to validate workflow definitions using your own custom logic .
1313+ To do so, create a class that implements the
13141314:class: `Symfony\\ Component\\ Workflow\\ Validator\\ DefinitionValidatorInterface `::
13151315
13161316 namespace App\Workflow\Validator;
@@ -1326,11 +1326,12 @@ To do this, you need to implement the
13261326 if (!$definition->getMetadataStore()->getMetadata('title')) {
13271327 throw new InvalidDefinitionException(sprintf('The workflow metadata title is missing in Workflow "%s".', $name));
13281328 }
1329+
1330+ // ...
13291331 }
13301332 }
13311333
1332- Once your definition validator is implemented, you can configure your workflow to use
1333- it:
1334+ After implementing your validator, configure your workflow to use it:
13341335
13351336.. configuration-block ::
13361337
@@ -1340,7 +1341,7 @@ it:
13401341 framework :
13411342 workflows :
13421343 blog_publishing :
1343- # ... previous configuration
1344+ # ...
13441345
13451346 definition_validators :
13461347 - App\Workflow\Validator\BlogPublishingValidator
@@ -1357,7 +1358,7 @@ it:
13571358 >
13581359 <framework : config >
13591360 <framework : workflow name =" blog_publishing" >
1360- <!-- ... previous configuration -->
1361+ <!-- ... -->
13611362 <framework : definition-validators >App\Workflow\Validator\BlogPublishingValidator</framework : definition-validators >
13621363 </framework : workflow >
13631364 </framework : config >
@@ -1370,7 +1371,7 @@ it:
13701371
13711372 return static function (FrameworkConfig $framework): void {
13721373 $blogPublishing = $framework->workflows()->workflows('blog_publishing');
1373- // ... previous configuration
1374+ // ...
13741375
13751376 $blogPublishing->definitionValidators([
13761377 App\Workflow\Validator\BlogPublishingValidator::class
@@ -1379,11 +1380,12 @@ it:
13791380 // ...
13801381 };
13811382
1382- The ``BlogPublishingValidator `` definition validator will be executed during the container compilation.
1383+ The ``BlogPublishingValidator `` will be executed during container compilation
1384+ to validate the workflow definition.
13831385
13841386.. versionadded :: 7.3
13851387
1386- Support for defining custom workflow definition validators was introduced in Symfony 7.3.
1388+ Support for workflow definition validators was introduced in Symfony 7.3.
13871389
13881390Learn more
13891391----------
0 commit comments