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": "9cb7373b-a879-4cce-8ac5-9f64665bd043",
    "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": {
        "1e292a34-5fd9-4553-8b37-c09a408dc4be": {
            "id": "1e292a34-5fd9-4553-8b37-c09a408dc4be",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_1_task",
            "to": "foo_2_task"
        },
        "09dbf461-3f7b-4c4e-9e52-702780b6feda": {
            "id": "09dbf461-3f7b-4c4e-9e52-702780b6feda",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "foo_3_task"
        },
        "0735e858-ac72-41a2-8005-66a99212c6ba": {
            "id": "0735e858-ac72-41a2-8005-66a99212c6ba",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "bar_2_task"
        },
        "7be0e82c-ea3e-43e4-8ec0-eebf5c3dfae6": {
            "id": "7be0e82c-ea3e-43e4-8ec0-eebf5c3dfae6",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "bar_1_task",
            "to": "bar_2_task"
        },
        "82ebd0ec-2d04-44e0-9402-a6ffd8f1be27": {
            "id": "82ebd0ec-2d04-44e0-9402-a6ffd8f1be27",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "foo_1_task"
        },
        "563945a9-618e-45bf-b0ac-a2fa40bed73c": {
            "id": "563945a9-618e-45bf-b0ac-a2fa40bed73c",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "bar_1_task"
        }
    },
    "outTransitions": {
        "foo_1_task": [
            "1e292a34-5fd9-4553-8b37-c09a408dc4be"
        ],
        "foo_2_task": [
            "09dbf461-3f7b-4c4e-9e52-702780b6feda",
            "0735e858-ac72-41a2-8005-66a99212c6ba"
        ],
        "bar_1_task": [
            "7be0e82c-ea3e-43e4-8ec0-eebf5c3dfae6"
        ]
    },
    "inTransitions": {
        "foo_2_task": [
            "1e292a34-5fd9-4553-8b37-c09a408dc4be"
        ],
        "foo_3_task": [
            "09dbf461-3f7b-4c4e-9e52-702780b6feda"
        ],
        "bar_2_task": [
            "0735e858-ac72-41a2-8005-66a99212c6ba",
            "7be0e82c-ea3e-43e4-8ec0-eebf5c3dfae6"
        ],
        "foo_1_task": [
            "82ebd0ec-2d04-44e0-9402-a6ffd8f1be27"
        ],
        "bar_1_task": [
            "563945a9-618e-45bf-b0ac-a2fa40bed73c"
        ]
    }
}