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": "c288f1e6-6b2c-46ad-b659-f251ea3bcb94",
    "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": {
        "822894d9-2942-4d4e-9bc5-aaf0de127c61": {
            "id": "822894d9-2942-4d4e-9bc5-aaf0de127c61",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_1_task",
            "to": "foo_2_task"
        },
        "84f4633b-dfec-410a-9377-3aee1111bdd7": {
            "id": "84f4633b-dfec-410a-9377-3aee1111bdd7",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "foo_3_task"
        },
        "c03da425-9107-4caa-88f6-ce787a5fbce7": {
            "id": "c03da425-9107-4caa-88f6-ce787a5fbce7",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "bar_2_task"
        },
        "2dfbc2dc-b535-4d08-9bd8-be5f26f3202f": {
            "id": "2dfbc2dc-b535-4d08-9bd8-be5f26f3202f",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "bar_1_task",
            "to": "bar_2_task"
        },
        "2588ddeb-25db-4860-be7f-e192062ddd31": {
            "id": "2588ddeb-25db-4860-be7f-e192062ddd31",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "foo_1_task"
        },
        "c990d3a9-044a-4385-847e-b613ed0d5527": {
            "id": "c990d3a9-044a-4385-847e-b613ed0d5527",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "bar_1_task"
        }
    },
    "outTransitions": {
        "foo_1_task": [
            "822894d9-2942-4d4e-9bc5-aaf0de127c61"
        ],
        "foo_2_task": [
            "84f4633b-dfec-410a-9377-3aee1111bdd7",
            "c03da425-9107-4caa-88f6-ce787a5fbce7"
        ],
        "bar_1_task": [
            "2dfbc2dc-b535-4d08-9bd8-be5f26f3202f"
        ]
    },
    "inTransitions": {
        "foo_2_task": [
            "822894d9-2942-4d4e-9bc5-aaf0de127c61"
        ],
        "foo_3_task": [
            "84f4633b-dfec-410a-9377-3aee1111bdd7"
        ],
        "bar_2_task": [
            "c03da425-9107-4caa-88f6-ce787a5fbce7",
            "2dfbc2dc-b535-4d08-9bd8-be5f26f3202f"
        ],
        "foo_1_task": [
            "2588ddeb-25db-4860-be7f-e192062ddd31"
        ],
        "bar_1_task": [
            "c990d3a9-044a-4385-847e-b613ed0d5527"
        ]
    }
}