Git Product home page Git Product logo

Comments (4)

zerodahero avatar zerodahero commented on August 16, 2024

Hmmm, not quite sure. This looks like a carry-over from an earlier version of this package. Looks like the tricky part here is defining (via assoc. array in config) whether a transition should go from multiple places to one, or whether two different places can both transition to that place.

Do you have any suggestions on addressing that? Looks like the Symfony Transition class will handle an array $from (lol at the misspelling in source). My first thought would be treating the "top" level of the 'from' array in the config as the "places" and allow arrays in it. So, your diagram example would be:

// ...
'transitions' => [
            'publish' => [
                'from' => [
                   ['approved_by_journalist', 'approved_by_spellchecker']
                ]
                'to' => 'published'
            ],
// ...

Which, looking at the code, that may already support that, though it's not documented anywhere?

from laravel-workflow.

PavelTytyuk avatar PavelTytyuk commented on August 16, 2024

Symfony really supports arrays in $from, and, I believe, been doing so since early workflow component versions.

I have already applied the code I mentioned in first snippet. Instead of foreach:

            $transitionObj = new Transition($transitionName, $transition['from'], $transition['to']);
            $builder->addTransition($transitionObj);

            if (isset($transition['metadata'])) {
                $metadata['transitions']->attach($transitionObj, $transition['metadata']);
            }

And the diagram looks this way:

            'publish' => [
                'from' => ['approved by journalist', 'approved by spellchecker'],
                'to' => 'published'
            ],

Don't see any reason to add another level to 'from' and treat it any different from 'to'. Original YAML config is a plain array:

                publish:
                    guard: "is_fully_authenticated()"
                    from:
                        - approved by journalist
                        - approved by spellchecker
                    to: published

from laravel-workflow.

zerodahero avatar zerodahero commented on August 16, 2024

Yes, that's right. The Transition class has supported arrays since at least 3.0, but I'm not sure the YAML has. I'll have to take a closer look into how Symfony handles it (that's the biggest divergence between this package and Symfony). The issue is how to differentiate between (a) either Place1 OR Place2 can transition to Place3 and (b) BOTH Place1 AND Place2 transition to Place3.

from laravel-workflow.

zerodahero avatar zerodahero commented on August 16, 2024

I'm going to close this for now, in favor of adding this into the documentation. There may be some possible routes to explore in the future with changing this behavior based on the workflow type (state machine or workflow), though I'm not quite sure how we could make the right assumptions to keep the config as is.

Please let me know if I'm misunderstanding anything here and we can reopen this.

from laravel-workflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.