Grouping

The example shows how to organize some nodes into logical groups. It is just a visual thing.

Setup


mkdir ~/pvm-grouping
cd ~/pvm-grouping
composer req formapro/pvm:0.4.x-dev makasim/values:0.5.x-dev

# create such file with the code below
php grouping.php

Result

grouping.php


<?php
use Formapro\Pvm\ProcessBuilder;

require_once 
__DIR__.'/vendor/autoload.php';

$process = (new ProcessBuilder())
    ->
createNode('foo_1_task''a_behavior')->setOption('group''foo')->end()
    ->
createNode('foo_2_task''a_behavior')->setOption('group''foo')->end()
    ->
createNode('foo_3_task''a_behavior')->setOption('group''foo')->end()
    ->
createNode('bar_1_task''a_behavior')->setOption('group''bar')->end()
    ->
createNode('bar_2_task''a_behavior')->setOption('group''bar')->end()
    ->
createTransition('foo_1_task''foo_2_task')->end()
    ->
createTransition('foo_2_task''foo_3_task')->end()
    ->
createTransition('foo_2_task''bar_2_task')->end()
    ->
createTransition('bar_1_task''bar_2_task')->end()
    ->
createStartTransition('foo_1_task')->end()
    ->
createStartTransition('bar_1_task')->end()

    ->
getProcess()
;

{
    "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Process.json",
    "id": "78fcf42e-5be9-4417-a3d4-d5dcd951ae1e",
    "nodes": {
        "foo_1_task": {
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Node.json",
            "id": "foo_1_task",
            "behavior": "a_behavior",
            "option": {
                "group": "foo"
            }
        },
        "foo_2_task": {
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Node.json",
            "id": "foo_2_task",
            "behavior": "a_behavior",
            "option": {
                "group": "foo"
            }
        },
        "foo_3_task": {
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Node.json",
            "id": "foo_3_task",
            "behavior": "a_behavior",
            "option": {
                "group": "foo"
            }
        },
        "bar_1_task": {
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Node.json",
            "id": "bar_1_task",
            "behavior": "a_behavior",
            "option": {
                "group": "bar"
            }
        },
        "bar_2_task": {
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Node.json",
            "id": "bar_2_task",
            "behavior": "a_behavior",
            "option": {
                "group": "bar"
            }
        }
    },
    "transitions": {
        "d10adc9a-5a9b-4e56-a328-adc428d68260": {
            "id": "d10adc9a-5a9b-4e56-a328-adc428d68260",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_1_task",
            "to": "foo_2_task"
        },
        "0a3d453e-0f92-4f34-9b12-dcda8997ed02": {
            "id": "0a3d453e-0f92-4f34-9b12-dcda8997ed02",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "foo_3_task"
        },
        "d4f4131e-ccf1-4d35-8447-f141116839b8": {
            "id": "d4f4131e-ccf1-4d35-8447-f141116839b8",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "bar_2_task"
        },
        "0f1dec04-47a3-4969-b09a-7ac6cbcfafe0": {
            "id": "0f1dec04-47a3-4969-b09a-7ac6cbcfafe0",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "bar_1_task",
            "to": "bar_2_task"
        },
        "060d2bce-cb64-4afc-80ba-dedd5a4d0460": {
            "id": "060d2bce-cb64-4afc-80ba-dedd5a4d0460",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "foo_1_task"
        },
        "c8dc4ad1-1822-4e35-bd07-02cf15da98dd": {
            "id": "c8dc4ad1-1822-4e35-bd07-02cf15da98dd",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "bar_1_task"
        }
    },
    "outTransitions": {
        "foo_1_task": [
            "d10adc9a-5a9b-4e56-a328-adc428d68260"
        ],
        "foo_2_task": [
            "0a3d453e-0f92-4f34-9b12-dcda8997ed02",
            "d4f4131e-ccf1-4d35-8447-f141116839b8"
        ],
        "bar_1_task": [
            "0f1dec04-47a3-4969-b09a-7ac6cbcfafe0"
        ]
    },
    "inTransitions": {
        "foo_2_task": [
            "d10adc9a-5a9b-4e56-a328-adc428d68260"
        ],
        "foo_3_task": [
            "0a3d453e-0f92-4f34-9b12-dcda8997ed02"
        ],
        "bar_2_task": [
            "d4f4131e-ccf1-4d35-8447-f141116839b8",
            "0f1dec04-47a3-4969-b09a-7ac6cbcfafe0"
        ],
        "foo_1_task": [
            "060d2bce-cb64-4afc-80ba-dedd5a4d0460"
        ],
        "bar_1_task": [
            "c8dc4ad1-1822-4e35-bd07-02cf15da98dd"
        ]
    }
}