Skip to content

Commit 124fd2a

Browse files
committed
[Workflow] Fix code blocks using an enum
1 parent 22890da commit 124fd2a

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

workflow.rst

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,11 @@ and transitions:
361361
<framework:config>
362362
<!-- or type="state_machine" -->
363363
<framework:workflow name="blog_publishing" type="workflow" places="App\Enumeration\BlogPostStatus::*">
364-
<framework:marking-store type="single_state">
364+
<framework:initial-marking>draft</framework:initial-marking>
365+
<framework:marking-store type="method">
365366
<framework:argument>status</framework:argument>
366367
</framework:marking-store>
367368
<framework:support>App\Entity\BlogPost</framework:support>
368-
<framework:initial-marking>draft</framework:initial-marking>
369369
370370
<framework:transition name="to_review">
371371
<framework:from>draft</framework:from>
@@ -391,32 +391,35 @@ and transitions:
391391
use Symfony\Config\FrameworkConfig;
392392
393393
return static function (FrameworkConfig $framework): void {
394-
$blogPublishing = $framework->workflows()->workflows('blog_publishing');
394+
$blogPublishing = $framework->workflows()->workflow('blog_publishing');
395395
$blogPublishing
396396
->type('workflow')
397397
->supports([BlogPost::class])
398-
->initialMarking([BlogPostStatus::Draft]);
398+
->initialMarking([BlogPostStatus::Draft->value]);
399399
400400
$blogPublishing->markingStore()
401401
->type('method')
402402
->property('status');
403403
404-
$blogPublishing->places(BlogPostStatus::cases());
404+
$blogPublishing->place(BlogPostStatus::Draft->value);
405+
$blogPublishing->place(BlogPostStatus::Reviewed->value);
406+
$blogPublishing->place(BlogPostStatus::Published->value);
407+
$blogPublishing->place(BlogPostStatus::Rejected->value);
405408
406409
$blogPublishing->transition()
407410
->name('to_review')
408-
->from(BlogPostStatus::Draft)
409-
->to([BlogPostStatus::Reviewed]);
411+
->from([BlogPostStatus::Draft->value])
412+
->to([BlogPostStatus::Reviewed->value]);
410413
411414
$blogPublishing->transition()
412415
->name('publish')
413-
->from([BlogPostStatus::Reviewed])
414-
->to([BlogPostStatus::Published]);
416+
->from([BlogPostStatus::Reviewed->value])
417+
->to([BlogPostStatus::Published->value]);
415418
416419
$blogPublishing->transition()
417420
->name('reject')
418-
->from([BlogPostStatus::Reviewed])
419-
->to([BlogPostStatus::Rejected]);
421+
->from([BlogPostStatus::Reviewed->value])
422+
->to([BlogPostStatus::Rejected->value]);
420423
};
421424
422425
The component will now transparently cast the enum to its backing value

0 commit comments

Comments
 (0)