Download the PHP package linkbee/state-workflow without Composer
On this page you can find all versions of the php package linkbee/state-workflow. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download linkbee/state-workflow
More information about linkbee/state-workflow
Files in linkbee/state-workflow
Package state-workflow
Short Description State Management workflow for Laravel, this package is fork form RingierIMU/state-workflow
License MIT
Homepage https://github.com/ptyz030529/state-workflow
Informations about the package state-workflow
Laravel State workflow
Implement Symfony Workflow component in Laravel
A workflow consist of state and actions to get from one place to another. The actions are called transitions which describes how to get from one state to another.
Installation
For Laravel versions lower than 5.5, this step is important after running above script.
- Open your config/app.php file and add custom service provider:
Publish config/workflow.php
file
Run migrations
Configuration
-
Open
config/workflow.php
and configure it - Add
HasWorkflowTrait
to your model class to support workflow
Usage
Manage State/Workflow
Fired Event
Each step has three events that are fired in order:
- An event for every workflow
- An event for the workflow concerned
- An event for the workflow concerned with the specific transition or state name
During state/workflow transition, the following events are fired in the following order:
-
Validate whether the transition is allowed at all. Their event listeners are invoked every time a call to
workflow()->can()
,workflow()->apply()
orworkflow()->getEnabledTransitions()
is executed.Guard Event
-
The subject is about to leave a state.
Leave Event
-
The subject is going through this transition.
Transition Event
-
The subject is about to enter a new state. This event is triggered just before the subject states are updated.
Enter Event
-
The subject has entered in the states and is updated.
Entered Event
- The subject has completed this transition.
Completed Event
Subscriber
Create subscriber class to listen to those events and the class should extends WorkflowSubscriberHandler
.
To register method to listen to specific even within subscriber use the following format for method name:
- on[Event] -
onGuard()
- on[Event][Transition/State name] -
onGuardActivate()
NB:
- Method name must start with
on
key word otherwise it will be ignored. Subscriber
class must be register insideworkflow.php
config file with the appropriate workflow configuration.Subscriber
class must extendsWorkflowSubscriberHandler
.Guard
,Transition
andCompleted
Event uses of transition name.Leave
,Enter
andEntered
Event uses state name.
Event Methods
Each workflow event has an instance of Event
. This means that each event has access to the following information:
getOriginalEvent()
: Returns the Parent Event that dispatched the event which has the following children methods:getSubject()
: Returns the object that dispatches the event.getTransition()
: Returns the Transition that dispatches the event.getWorkflowName()
: Returns a string with the name of the workflow that triggered the event.isBlocked()
: Returns true/false if transition is blocked.setBlocked()
: Sets the blocked value.
Artisan Command
Symfony workflow uses GraphvizDumper to create the workflow image by using the dot
command.
The dot
command is part of Graphviz.
You will be required to download dot
command to make use of this command.
https://graphviz.gitlab.io/download/
Usage
All versions of state-workflow with dependencies
illuminate/events Version >7.0
illuminate/support Version >7.0
symfony/event-dispatcher Version ^5.1
symfony/workflow Version ^5.1
symfony/property-access Version ^5.1