winzou / state-machine Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
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.
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",
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.
Hi,
I'd be interested to know (and maybe add it to the readme) how this library differs from https://github.com/yohang/Finite and what different direction is being taken (why Finate wasn't suitable etc...)
Thanks
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
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.
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].
Could this be possible?
here https://github.com/winzou/state-machine/blob/master/src/SM/Factory/AbstractFactory.php#L48 when the $this-config is not set for some reason, the code will throw error in php7 and php8 because it can loop on null.
any chance to get this patched to cast the null into empty array to avoid this kind of error?
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.
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?
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?
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];
}
Hello,
What is the difference between callback use and event use ?
I'd like to use the changes in this commit without having to depend on dev-master
. Can you tag that commit as a new version?
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.