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": "8ffe1eff-79cb-4de3-96ae-a7219a7d8078",
    "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": {
        "246491b0-7134-41b9-ac56-7207fb473634": {
            "id": "246491b0-7134-41b9-ac56-7207fb473634",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_1_task",
            "to": "foo_2_task"
        },
        "83edacf2-06bf-4773-a078-99861addf08a": {
            "id": "83edacf2-06bf-4773-a078-99861addf08a",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "foo_3_task"
        },
        "da8f9a86-cb38-410e-894a-6cee81d039c6": {
            "id": "da8f9a86-cb38-410e-894a-6cee81d039c6",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "bar_2_task"
        },
        "7a9af5ee-6fbf-4231-8456-4a386a09887e": {
            "id": "7a9af5ee-6fbf-4231-8456-4a386a09887e",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "bar_1_task",
            "to": "bar_2_task"
        },
        "16b6598f-4443-4984-9bd1-01c960beb764": {
            "id": "16b6598f-4443-4984-9bd1-01c960beb764",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "foo_1_task"
        },
        "5c7c83ab-1dca-4c13-a779-9d8aba3a50a1": {
            "id": "5c7c83ab-1dca-4c13-a779-9d8aba3a50a1",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "bar_1_task"
        }
    },
    "outTransitions": {
        "foo_1_task": [
            "246491b0-7134-41b9-ac56-7207fb473634"
        ],
        "foo_2_task": [
            "83edacf2-06bf-4773-a078-99861addf08a",
            "da8f9a86-cb38-410e-894a-6cee81d039c6"
        ],
        "bar_1_task": [
            "7a9af5ee-6fbf-4231-8456-4a386a09887e"
        ]
    },
    "inTransitions": {
        "foo_2_task": [
            "246491b0-7134-41b9-ac56-7207fb473634"
        ],
        "foo_3_task": [
            "83edacf2-06bf-4773-a078-99861addf08a"
        ],
        "bar_2_task": [
            "da8f9a86-cb38-410e-894a-6cee81d039c6",
            "7a9af5ee-6fbf-4231-8456-4a386a09887e"
        ],
        "foo_1_task": [
            "16b6598f-4443-4984-9bd1-01c960beb764"
        ],
        "bar_1_task": [
            "5c7c83ab-1dca-4c13-a779-9d8aba3a50a1"
        ]
    }
}