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": "88337e7a-eb75-4af1-bd1c-f1c3527f2faa",
    "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": {
        "b69d3a50-210c-43cd-b00d-0fbaa1902a3a": {
            "id": "b69d3a50-210c-43cd-b00d-0fbaa1902a3a",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_1_task",
            "to": "foo_2_task"
        },
        "2d32cc9d-d741-48f9-b60a-7f9316fc5477": {
            "id": "2d32cc9d-d741-48f9-b60a-7f9316fc5477",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "foo_3_task"
        },
        "86f646f9-2392-4390-804e-658b9a24f9b8": {
            "id": "86f646f9-2392-4390-804e-658b9a24f9b8",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "bar_2_task"
        },
        "ea9a5afb-2110-4b49-9d3b-6dd460bebfd4": {
            "id": "ea9a5afb-2110-4b49-9d3b-6dd460bebfd4",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "bar_1_task",
            "to": "bar_2_task"
        },
        "eec3195d-96ac-48da-b8da-91c1ad93431d": {
            "id": "eec3195d-96ac-48da-b8da-91c1ad93431d",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "foo_1_task"
        },
        "903179cd-c210-4c59-8738-9c72bea5b1e1": {
            "id": "903179cd-c210-4c59-8738-9c72bea5b1e1",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "bar_1_task"
        }
    },
    "outTransitions": {
        "foo_1_task": [
            "b69d3a50-210c-43cd-b00d-0fbaa1902a3a"
        ],
        "foo_2_task": [
            "2d32cc9d-d741-48f9-b60a-7f9316fc5477",
            "86f646f9-2392-4390-804e-658b9a24f9b8"
        ],
        "bar_1_task": [
            "ea9a5afb-2110-4b49-9d3b-6dd460bebfd4"
        ]
    },
    "inTransitions": {
        "foo_2_task": [
            "b69d3a50-210c-43cd-b00d-0fbaa1902a3a"
        ],
        "foo_3_task": [
            "2d32cc9d-d741-48f9-b60a-7f9316fc5477"
        ],
        "bar_2_task": [
            "86f646f9-2392-4390-804e-658b9a24f9b8",
            "ea9a5afb-2110-4b49-9d3b-6dd460bebfd4"
        ],
        "foo_1_task": [
            "eec3195d-96ac-48da-b8da-91c1ad93431d"
        ],
        "bar_1_task": [
            "903179cd-c210-4c59-8738-9c72bea5b1e1"
        ]
    }
}