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": "f8dfc489-f28d-4494-8638-d4df3ef5950c",
    "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": {
        "3d5bc0c3-37a1-4497-b1a6-da1eb042be77": {
            "id": "3d5bc0c3-37a1-4497-b1a6-da1eb042be77",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_1_task",
            "to": "foo_2_task"
        },
        "ff9ca0d9-0319-420c-8890-b8bd1788d4db": {
            "id": "ff9ca0d9-0319-420c-8890-b8bd1788d4db",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "foo_3_task"
        },
        "f572e38f-a97e-4fbc-99ff-1bf19a945b86": {
            "id": "f572e38f-a97e-4fbc-99ff-1bf19a945b86",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "bar_2_task"
        },
        "bc6ea2e1-e32d-4143-88cf-28ced829f00f": {
            "id": "bc6ea2e1-e32d-4143-88cf-28ced829f00f",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "bar_1_task",
            "to": "bar_2_task"
        },
        "43ea2e21-2ac8-45fe-8b82-60b58fad8526": {
            "id": "43ea2e21-2ac8-45fe-8b82-60b58fad8526",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "foo_1_task"
        },
        "2078bd9b-364c-437e-a3b1-6f9758701070": {
            "id": "2078bd9b-364c-437e-a3b1-6f9758701070",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "bar_1_task"
        }
    },
    "outTransitions": {
        "foo_1_task": [
            "3d5bc0c3-37a1-4497-b1a6-da1eb042be77"
        ],
        "foo_2_task": [
            "ff9ca0d9-0319-420c-8890-b8bd1788d4db",
            "f572e38f-a97e-4fbc-99ff-1bf19a945b86"
        ],
        "bar_1_task": [
            "bc6ea2e1-e32d-4143-88cf-28ced829f00f"
        ]
    },
    "inTransitions": {
        "foo_2_task": [
            "3d5bc0c3-37a1-4497-b1a6-da1eb042be77"
        ],
        "foo_3_task": [
            "ff9ca0d9-0319-420c-8890-b8bd1788d4db"
        ],
        "bar_2_task": [
            "f572e38f-a97e-4fbc-99ff-1bf19a945b86",
            "bc6ea2e1-e32d-4143-88cf-28ced829f00f"
        ],
        "foo_1_task": [
            "43ea2e21-2ac8-45fe-8b82-60b58fad8526"
        ],
        "bar_1_task": [
            "2078bd9b-364c-437e-a3b1-6f9758701070"
        ]
    }
}