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": "4970cf8d-b5b8-4824-8684-44be4382648d",
    "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": {
        "47c3d578-91a5-4bd6-b81c-7894fe98bd74": {
            "id": "47c3d578-91a5-4bd6-b81c-7894fe98bd74",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_1_task",
            "to": "foo_2_task"
        },
        "3995ec0c-d308-4fdd-904f-37e23bca437f": {
            "id": "3995ec0c-d308-4fdd-904f-37e23bca437f",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "foo_3_task"
        },
        "835aa9c3-42da-42fc-8dbc-2a87557b67f4": {
            "id": "835aa9c3-42da-42fc-8dbc-2a87557b67f4",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "bar_2_task"
        },
        "f406c291-c8e4-46d9-9ab9-834f9a5170d9": {
            "id": "f406c291-c8e4-46d9-9ab9-834f9a5170d9",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "bar_1_task",
            "to": "bar_2_task"
        },
        "066a2aef-e59e-4c52-9ea4-ef8dc6206ecc": {
            "id": "066a2aef-e59e-4c52-9ea4-ef8dc6206ecc",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "foo_1_task"
        },
        "310d01c6-7637-4d5c-996c-678ddc1e445e": {
            "id": "310d01c6-7637-4d5c-996c-678ddc1e445e",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "bar_1_task"
        }
    },
    "outTransitions": {
        "foo_1_task": [
            "47c3d578-91a5-4bd6-b81c-7894fe98bd74"
        ],
        "foo_2_task": [
            "3995ec0c-d308-4fdd-904f-37e23bca437f",
            "835aa9c3-42da-42fc-8dbc-2a87557b67f4"
        ],
        "bar_1_task": [
            "f406c291-c8e4-46d9-9ab9-834f9a5170d9"
        ]
    },
    "inTransitions": {
        "foo_2_task": [
            "47c3d578-91a5-4bd6-b81c-7894fe98bd74"
        ],
        "foo_3_task": [
            "3995ec0c-d308-4fdd-904f-37e23bca437f"
        ],
        "bar_2_task": [
            "835aa9c3-42da-42fc-8dbc-2a87557b67f4",
            "f406c291-c8e4-46d9-9ab9-834f9a5170d9"
        ],
        "foo_1_task": [
            "066a2aef-e59e-4c52-9ea4-ef8dc6206ecc"
        ],
        "bar_1_task": [
            "310d01c6-7637-4d5c-996c-678ddc1e445e"
        ]
    }
}