2017 © Pedro Peláez
 

library workflow

Rezzza workflow

image

rezzza/workflow

Rezzza workflow

  • Wednesday, September 17, 2014
  • by steph_py
  • Repository
  • 5 Watchers
  • 9 Stars
  • 506 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Rezzza\Workflow

Build Status, (*1)

Define workflow of an object easily., (*2)

Installation

Through Composer :, (*3)

$ composer require --dev "rezzza/workflow:1.0.*@dev"

Warning, this library uses binary system, it assigns a binary mask to each state. By this way, you'll be limited in number of states., (*4)

Usage


use \Rezzza\Workflow\Graph; use \Rezzza\Workflow\State; use \Rezzza\Workflow\Workflow; use \Rezzza\Workflow\Exception; $graph = new Graph(); $graph ->addState('empty', new State\NextOne()) // can go to filled ->addState('filled', new State\StateCollection(array('empty', 'confirmed'))) // can go to empty or confirmed ->addState('confirmed', new State\NextOne()) // can go to pending transaction ->addState('pending_transaction', new State\NextAll()) // can go to failing_transaction or success_transaction ->addState('failing_transaction', new State\End()) ->addState('success_transaction', new State\End()) $cart = new Acme\ECommerce\Path\To\Cart(); $workflow = new Workflow($graph, $cart, 'status'); $states = $workflow->getAuthorizedStates(); try { $workflow->moveToState('filled'); } catch (Exception\ConflictException e) { // it seems you want to add a state already setted. } catch (Exception\WorkflowException $e) { // you try to set a state not authorized. }

Specifications

You can add a specification to each states, (*5)

use Rezzza\Workflow\Specification\SpecificationInterface;

class ConfirmableSpecification implements SpecificationInterface
{
    public function isSatisfiedBy($object)
    {
        return $object->hasUserAuthenticated();
    }
}

$graph = new Graph();
$graph
    //........
    ->addState('confirmed', new State\NextOne(new ConfirmableSpecification()))
    //.........

States

You can use each one of theses states:, (*6)

Name Description
All all states
End no state
NextAll all states registered after current
NextOne next one state registered after current
NextUntil all next states registered until defined state
PreviousAll all states registered before current
PreviousOne previous one state registered before current
PreviousUntil all previous states registered until defined state
StateCollection states defined via a collection of id

The Versions

17/09 2014

dev-master

9999999-dev https://github.com/rezzza/workflow

Rezzza workflow

  Sources   Download

MIT

The Requires

 

The Development Requires

workflow state