Giter Site home page Giter Site logo

state-machine's People

Contributors

bendavies avatar blazarecki avatar bpolaszek avatar cawolf avatar coldic3 avatar cordoval avatar dantleech avatar jgiacobbi avatar lchrusciel avatar loic425 avatar patrick-mcdougle avatar richtermeister avatar s-chizhik avatar sebdesign avatar snoob avatar winzou avatar zales0123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

state-machine's Issues

Support for anonymous = triggerless = completion transitions

Thanks for the great state machine, but often there is a need in triggerless transitions which I can realize here.
Machine may be needed to change its state after some period in time accordingly to some guard condition or just after all activities done when it came to a target state.
Is there a possibility to implement it.
Or maybe I could do this.

Support for php 8.0 or higher

whenever im trying to use it with 8.0 or higher i get (in the releases is stated that it would already support 8.0)
" - winzou/state-machine[0.4.1, ..., v0.4.x-dev] require php ^7.1.3 -> your php version (8.0.26) does not satisfy that requirement."

in composer.json:
"winzou/state-machine": "^0.4",

DOC - mention of 6 states while there are only 4

In the README.md, this is mentionned :

$config = array(
    'graph'         => 'myGraphA', // Name of the current graph - there can be many of them attached to the same object
    'property_path' => 'stateA',  // Property path of the object actually holding the state
    'states'        => array(
        'checkout',
        'pending',
        'confirmed',
        'cancelled'
    ),
    [...]

followed by this explanation :

So, in the previous example, the graph has 6 possible states, and those can be achieved by applying some transitions to the object. [...]

But from what I read, there are only 4 states present in the declared graph and not 6 like said above.

Impossible to use string constant or enum as a callback argument

A configuration like that is impossible to use

       callbacks:
            after:
                on_initial_fraud_pass:
                    on: !php/const Services\Account\Constants\FraudStateTransition::INITIAL_FRAUD_PASS
                    do: Services\Account\State\TransitionCallbackManager::transitionUserState
                    args:
                        - 'object'
                        - !php/const Services\Account\Constants\AccountStateTransition::ACTIVATE

Since expression parser is applied and constant returns unquoted string

Question: how to set an "initial" state

As the question says, how do we set the state machine to an initial state? It seems an obvious thing to want to do, but I can't find documentation on it, and I don't see any obvious attempt at setting an initial state in your code.

Composer Issue with PHP8

Apologies if this is the wrong place. I am having issues installing your package using composer with PHP 8.0.3

  Problem 1
    - winzou/state-machine[0.4.1, ..., v0.4.x-dev] require php ^7.1.3 -> your php version (8.0.3) does not satisfy that requirement.
    - Root composer.json requires winzou/state-machine ^0.4.1 -> satisfiable by winzou/state-machine[0.4.1, v0.4.x-dev].

Compatibility with symfony/event-dispatcher ^4.3

Since 4.3, symfony/event-dispatcher changed the signature of the EventDispatcherInterface::dispatch() and removed the Event class. These deprecated changes were removed in 5.0. See the changelog.

Is there a plan to upgrade this package? I am the maintainer of sebdesign/laravel-state-machine which is based on this package and I would love to support the newer versions of Symfony and Laravel.

[RFC] Add a clear method to the factory

In long batch processes that use the state machine, the factory gets very large (as more state machines are added to it). Additionally since each state machine stores the actual entity objects within it, the memory for them can never be freed by the garbage collector (and subsequently the objects that they refer to as well). Is there some way that application level code, could unset some or all of the state machines in the factory? I know that I could just write my own Factory implementation that does that, but this seems like a feature that might be important to the rest of the open-source community.

I propose a clear() that simply sets $stateMachines = [];

Thoughts?

Support for multiple transitions with the same name

Currently all transitions must be uniquely named. There's support to allow a transition to go from multiple states to a single end state, i.e.:

$config = ['transitions' => [
    'foo' => [
        'from' => ['a', 'b', 'c'],
        'to' => 'd',
    ],
]];

I propose adding support to have transitions going to different states, but having a same name, i.e.:

$config = ['transitions' => [
    'foo' => [
        [
            'from' => ['a', 'b', 'c'],
            'to' => 'd',
        ],
        [
            'from' => ['e', 'f'],
            'to' => 'g'
        ]
    ],
]];

This might not seem benefitial at first, but would be a huge help, when using the event dispatcher. It would enable having nifty listeners such as listening to confirm transitions and sending e-mails regarding the state change. No explicit listing of transitions would be necessary.

BC can also be kept by simply keeping support for the old structure.

Would you be interested in having this merged, should I implement it?

Question: what's the best solution to be compatible with an exist numeric state?

hi,
the state of my entities is the property status which is an integer number in database.

currently, in order to be compatible and human readable, i create the method getState:

// in entity class
private $stateByStatusMap = [
     0 => "new",
     1 => "processing",
     2 => "finish"
];
public function getState(){
      return $this->stateByStatusMap[$this->Status];
}

[Feature Request] Stop Transtion in pre-listener

The pre-events currently can't do anything to stop the transition from happening, it'd be cool if the pre-events were more like voters and if any of them returned false, the transition would fail.

Thoughts?

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.