Download the PHP package kphoen/doctrine-state-machine-bundle without Composer
On this page you can find all versions of the php package kphoen/doctrine-state-machine-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kphoen/doctrine-state-machine-bundle
More information about kphoen/doctrine-state-machine-bundle
Files in kphoen/doctrine-state-machine-bundle
Package doctrine-state-machine-bundle
Short Description Integrates DoctrineStateMachineBehavior in Symfony2.
License MIT
Informations about the package doctrine-state-machine-bundle
DoctrineStateMachineBundle
Doctrine2 behavior adding a finite state machine in your entities.
The state machine implementation used is Finite.
Status
This project is DEPRECATED and should NOT be used.
If someone magically appears and wants to maintain this project, I'll gladly give access to this repository.
Configuration
In your app/config/config.yml
file, define your state machines:
The state machines configuration is pretty straightforward. In addition to the states and transitions, you just have to define the entity class and the column used to store the state.
Important: the entity has to implement the Stateful
interface.
To ease the implementation, you can use the StatefulTrait
that comes bundled
with the behavior.
Usage
Stateful
entities have access to their own state machine. See Finite's
documentation for more details about it.
The Article
entity below is ready to be used as a Stateful
entity.
Entities using the StatefulTrait
see the setStateMachine()
and
getStateMachine()
methods implemented and gain access to the following
methods:
can($transition)
: indicating if the given transition is allowed ;- and a few magic methods, based on the transition allowed by the
state-machine:
{TransitionName}()
: apply the transition {TransitionName} (ie:accept()
,reject()
, etc) ;can{TransitionName}()
: test if the transition {TransitionName} can be applied (ie:canAccept()
,canReject()
, etc).is{StateName}()
: test if the current state is {StatusName} (ie:isAccepted()
,isRejected()
, etc).
Lifecyle callbacks
If you use the event-aware state-machine (which is the default one used by the bundle), the extension provides a listener implementing "lifecyle callbacks" for stateful entities.
For each available transition, three methods can be executed:
pre{TransitionName}()
: called before the transition {TransitionName} is applied ;post{TransitionName}()
: called after the transition {TransitionName} is applied ;can{TransitionName}()
: called when the state-machine tests if the transition {TransitionName} can be applied.
Using a service
You can put the state logic outside of the entity using a listener on Finite events. The extension provides an abstract EventSubcriber with the same methods as the "lifecyle callbacks" listener.
You need to declare a service and extend the AbstractSubcriber.
Twig
The bundle also exposes a few Twig helpers:
Installation
Install the behavior adding kphoen/doctrine-state-machine-bundle
to your composer.json or from CLI:
Than register the bundle in your app/AppKernel.php
file:
License
This bundle is released under the MIT license.
All versions of doctrine-state-machine-bundle with dependencies
doctrine/doctrine-bundle Version ~1.2
kphoen/doctrine-state-machine Version ~1.0