2017 © Pedro Peláez
 

library flow-control

component that allows to control state changes in the flow.

image

devhelp/flow-control

component that allows to control state changes in the flow.

  • Saturday, October 4, 2014
  • by devhelp
  • Repository
  • 2 Watchers
  • 1 Stars
  • 77 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Build Status SensioLabsInsight, (*1)

Installation

Composer is preferred to install Flow Control, please check composer website for more information., (*2)

$ composer require 'devhelp/flow-control:dev-master'

Purpose

Flow Control is a simple tool that allows to control the flow defined in the Flow class., (*3)

Two main classes are Flow and FlowControl. Flow is defined using moves array and entry points. FlowControl is used to control state changes in flows., (*4)

Concept of the flow is general, some obvious use case can be, to define and control flow in checkout process, (*5)

Usage

//two way flow with optional 'step_c'
$exampleFlowA = new Flow(
    'flow_a',
    array(
        'step_a' => array('step_b'),
        'step_b' => array('step_a', 'step_c', 'step_d'),
        'step_c' => array('step_b', 'step_d'),
        'step_d' => array('step_b', 'step_c')
    ),
    array('step_a')
);

//one way flow
$exampleFlowB = new Flow(
    'flow_b',
    array(
        'step_a' => array('step_b'),
        'step_b' => array('step_c'),
        'step_c' => array('step_d'),
    ),
    array('step_a')
);

$flows = array($exampleFlowA, $exampleFlowB);

$repository = new SimpleFlowRepository($flows);

$flowControl = new FlowControl($repository);

/**
 * origin of current steps is out of the scope of FlowControl component,
 * the same is regarding changing the state in the flow. FlowControl
 * is only for resolving valid moves
 */
$currentSteps = array(
    'flow_a' => 'step_c',
);

$flowControl->setFlowSteps($currentSteps);

$flowControl->isAllowed('step_d', 'flow_a'); //true
$flowControl->isAllowed('step_a', 'flow_a'); //false
$flowControl->isAllowed('step_c', 'flow_a'); //true
$flowControl->isAllowed('step_a', 'flow_b'); //true
$flowControl->isAllowed('step_b', 'flow_b'); //false

$moves = array(
    'flow_a' => 'step_d',
    'flow_b' => 'step_b',
);

$validMoves = $flowControl->resolveValid($moves); //array('flow_a' => 'step_d')

Credits

Brought to you by : Devhelp.pl (http://devhelp.pl), (*6)

The Versions

04/10 2014

dev-master

9999999-dev http://devhelp.pl

component that allows to control state changes in the flow.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Paweł Barański
by devhelp.pl

flow

04/10 2014

1.0

1.0.0.0 http://devhelp.pl

component that allows to control state changes in the flow.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Paweł Barański
by devhelp.pl

flow