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": "ea589dc2-4dde-49a5-8f45-5becdec044c4",
    "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": {
        "9c9201ba-0180-47e2-9784-a1792683e929": {
            "id": "9c9201ba-0180-47e2-9784-a1792683e929",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_1_task",
            "to": "foo_2_task"
        },
        "ad8fc19c-752f-4fab-b78c-12afeb0e4bc9": {
            "id": "ad8fc19c-752f-4fab-b78c-12afeb0e4bc9",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "foo_3_task"
        },
        "dec73616-8cad-4131-898e-70933c3d0a2a": {
            "id": "dec73616-8cad-4131-898e-70933c3d0a2a",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "bar_2_task"
        },
        "2bf88ebe-9bfd-4e89-bc1e-a9b83efc39a2": {
            "id": "2bf88ebe-9bfd-4e89-bc1e-a9b83efc39a2",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "bar_1_task",
            "to": "bar_2_task"
        },
        "a24b88b0-b6c4-4f50-90b2-074526837c12": {
            "id": "a24b88b0-b6c4-4f50-90b2-074526837c12",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "foo_1_task"
        },
        "2d620a0e-1654-4435-9dc2-b119888916a5": {
            "id": "2d620a0e-1654-4435-9dc2-b119888916a5",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "bar_1_task"
        }
    },
    "outTransitions": {
        "foo_1_task": [
            "9c9201ba-0180-47e2-9784-a1792683e929"
        ],
        "foo_2_task": [
            "ad8fc19c-752f-4fab-b78c-12afeb0e4bc9",
            "dec73616-8cad-4131-898e-70933c3d0a2a"
        ],
        "bar_1_task": [
            "2bf88ebe-9bfd-4e89-bc1e-a9b83efc39a2"
        ]
    },
    "inTransitions": {
        "foo_2_task": [
            "9c9201ba-0180-47e2-9784-a1792683e929"
        ],
        "foo_3_task": [
            "ad8fc19c-752f-4fab-b78c-12afeb0e4bc9"
        ],
        "bar_2_task": [
            "dec73616-8cad-4131-898e-70933c3d0a2a",
            "2bf88ebe-9bfd-4e89-bc1e-a9b83efc39a2"
        ],
        "foo_1_task": [
            "a24b88b0-b6c4-4f50-90b2-074526837c12"
        ],
        "bar_1_task": [
            "2d620a0e-1654-4435-9dc2-b119888916a5"
        ]
    }
}