Skip to content

[Workflow] Add support for weighted transitions #60201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 7.4
Choose a base branch
from

Conversation

lyrixx
Copy link
Member

@lyrixx lyrixx commented Apr 11, 2025

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? yes
Issues Fix #60107
License MIT

Allow to handle complex workflow like:

make_table:
    transitions:
        start:
            from: init
            to:
                -   place: prepare_leg
                    weight: 4
                -   place: prepare_top
                    weight: 1
                -   place: stopwatch_running
                    weight: 1
        build_leg:
            from: prepare_leg
            to: leg_created
        build_top:
            from: prepare_top
            to: top_created
        join:
            from:
                - place: leg_created
                  weight: 4
                - top_created
                - stopwatch_running
            to: finished
$definition = new Definition(
    [],
    [
        new Transition('start', 'init', [new Arc('prepare_leg', 4), 'prepare_top', 'stopwatch_running']),
        new Transition('build_leg', 'prepare_leg', 'leg_created'),
        new Transition('build_top', 'prepare_top', 'top_created'),
        new Transition('join', [new Arc('leg_created', 4), 'top_created', 'stopwatch_running'], 'finished'),
    ]
);

$subject = new Subject();
$workflow = new Workflow($definition);

$workflow->apply($subject, 'start');

$workflow->apply($subject, 'build_leg');
$workflow->apply($subject, 'build_top');
$workflow->apply($subject, 'build_leg');
$workflow->apply($subject, 'build_leg');
$workflow->apply($subject, 'build_leg');
$workflow->apply($subject, 'join');

Another example, based on https://demo-symfony-workflow.cleverapps.io/articles/show/1
workflow.webm

@lyrixx
Copy link
Member Author

lyrixx commented Apr 12, 2025

@bkosun Thanks for the review. I addressed your comments

@fabpot fabpot modified the milestones: 7.3, 7.4 May 26, 2025
@lyrixx lyrixx force-pushed the workflow-transition-weight branch from 9a13aba to 7758d3d Compare June 4, 2025 10:00
@lyrixx
Copy link
Member Author

lyrixx commented Jun 4, 2025

Thanks for the review, I addressed your comments, and also rebased.

@lyrixx
Copy link
Member Author

lyrixx commented Jun 4, 2025

I don't get why the tests are broken:

4) Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\YamlFrameworkExtensionTest::testWorkflowAreValidated
Failed asserting that exception of type "ReflectionException" matches expected exception "Symfony\Component\Workflow\Exception\InvalidDefinitionException". Message was: "Class "Symfony\Component\Workflow\Arc" does not exist" at

since I put

  "require-dev": {
      "symfony/workflow": "^7.4|^8.0",

in src/Symfony/Bundle/FrameworkBundle/composer.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Workflow] Unexpected marking with a complex workflow after transition
6 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy