PHPackages                             kphoen/doctrine-state-machine-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. kphoen/doctrine-state-machine-bundle

AbandonedSymfony-bundle

kphoen/doctrine-state-machine-bundle
====================================

Integrates DoctrineStateMachineBehavior in Symfony2.

1.1.3(9y ago)48218.5k19[5 issues](https://github.com/K-Phoen/DoctrineStateMachineBundle/issues)[1 PRs](https://github.com/K-Phoen/DoctrineStateMachineBundle/pulls)MITPHP

Since Oct 28Pushed 9y ago2 watchersCompare

[ Source](https://github.com/K-Phoen/DoctrineStateMachineBundle)[ Packagist](https://packagist.org/packages/kphoen/doctrine-state-machine-bundle)[ RSS](/packages/kphoen-doctrine-state-machine-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (5)Versions (10)Used By (0)

DoctrineStateMachineBundle
==========================

[](#doctrinestatemachinebundle)

Doctrine2 behavior adding a finite state machine in your entities.

The state machine implementation used is [Finite](https://github.com/yohang/Finite).

Status
------

[](#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
-------------

[](#configuration)

In your `app/config/config.yml` file, define your state machines:

```
k_phoen_doctrine_state_machine:
    auto_injection:     true    # should we automatically inject state machines into hydrated objects?
    auto_validation:    true    # should we validate any status change before the persistence happens?

    state_machines:
        article_state_machine:
            class:      \Acme\FooBundle\Entity\Article
            property:   state
            states:
                new:        {type: initial}
                reviewed:   ~
                accepted:   ~
                published:  {type: final, properties: {printable: true}}
                rejected:   {type: final}
            transitions:
                review:     {from: [new], to: reviewed}
                accept:     {from: [reviewed], to: accepted}
                publish:    {from: [accepted], to: published}
                reject:     {from: [new, reviewed, accepted, published], to: rejected}
```

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
-----

[](#usage)

`Stateful` entities have access to their own state machine. See [Finite's documentation](https://github.com/yohang/Finite) for more details about it.

The `Article` entity below is ready to be used as a `Stateful` entity.

```
