2017 © Pedro Peláez
 

library workflow

Vespolina library for handling workflow

image

vespolina/workflow

Vespolina library for handling workflow

  • Friday, May 22, 2015
  • by iampersistent
  • Repository
  • 8 Watchers
  • 22 Stars
  • 61 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 1 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

workflow

Build Status Total Downloads Latest Stable Version SensioLabsInsight Scrutinizer Quality Score Code Coverage Dependency Status, (*1)

Workflow is a library that lets you first build a graph with places and transactions interconnecting them with arcs. And then lets you traverse the created workflow for any number of runs each identifiable via a token. The traversing starts on an input place node and ends in an output place node for a given workflow. Workflow uses a logger to log the flow traversing details., (*2)

The tokenable nodes can execute custom implementations. These custom implementations can be used to carry out flows on processes of a web application or other process based systems., (*3)

Install

composer require vespolina/workflow dev-master

Usage

Suppose we want a workflow like this:, (*4)


O -> [A] -> O -> [B] -> O in p1 out

The code that implements and runs down on it would look like:, (*5)

 <?php

use Vespolina\Workflow\Task\Automatic;
use Vespolina\Workflow\Place;
use Vespolina\Workflow\Workflow;
use Vespolina\Workflow\Token;
use Vespolina\Workflow\TokenInterface;
use Monolog\Logger;

class NodeA extends Automatic
{
    public function execute(TokenInterface $token)
    {
        if ($token->getData('autoB')) {
            return false;
        }
        $token->setData('autoA', true);

        return true;
    }
}

class NodeB extends Automatic
{
    public function execute(TokenInterface $token)
    {
        if (!$token->getData('autoA')) {
            return false;
        }
        $token->setData('autoB', true);

        return true;
    }
}

$logger = new Logger('test');
$workflow = new Workflow($logger);

// create sequence
$a = new NodeA();
$b = new NodeB();
$place = new Place();
$place->setWorkflow($workflow, $logger);

$workflow->addNode($a, 'a');
$workflow->addNode($place, 'p1');
$workflow->addNode($b, 'b');

$workflow->connectToStart('a');
$workflow->connect('a', 'p1');
$workflow->connect('p1', 'b');
$workflow->connectToFinish('b');

$workflow->accept(new Token());

And we will see the traversing in our logs:, (*6)

... test.INFO: Token accepted into workflow {"token":"[object] (Vespolina\\Workflow\\Token: {})"} []
... test.INFO: Token advanced into workflow.start {"token":"[object] (Vespolina\\Workflow\\Token: {})"} []
... test.INFO: Token advanced into a {"token":"[object] (Vespolina\\Workflow\\Token: {})"} []
... test.INFO: Token advanced into p1 {"token":"[object] (Vespolina\\Workflow\\Token: {})"} []
... test.INFO: Token advanced into b {"token":"[object] (Vespolina\\Workflow\\Token: {})"} []
... test.INFO: Token advanced into workflow.finish {"token":"[object] (Vespolina\\Workflow\\Token: {})"} []

The Versions

22/05 2015

dev-master

9999999-dev http://vespolina-project.org

Vespolina library for handling workflow

  Sources   Download

MIT

The Requires

 

The Development Requires

workflow vespolina