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": "e9545db7-de23-4033-b319-1661d3bce929",
    "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": {
        "8c5f2cc9-7c51-4358-8c79-b230c6a984de": {
            "id": "8c5f2cc9-7c51-4358-8c79-b230c6a984de",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_1_task",
            "to": "foo_2_task"
        },
        "ddc4149e-ca17-43c0-8bf7-d0f8a2f99746": {
            "id": "ddc4149e-ca17-43c0-8bf7-d0f8a2f99746",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "foo_3_task"
        },
        "7320ba51-2785-4fae-8fba-e3a734ecadd1": {
            "id": "7320ba51-2785-4fae-8fba-e3a734ecadd1",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "bar_2_task"
        },
        "51c55879-ca6c-4ab9-bb64-0f293241472d": {
            "id": "51c55879-ca6c-4ab9-bb64-0f293241472d",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "bar_1_task",
            "to": "bar_2_task"
        },
        "d0079f8d-366f-4b45-8f98-f206c3c1d07b": {
            "id": "d0079f8d-366f-4b45-8f98-f206c3c1d07b",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "foo_1_task"
        },
        "86366b30-5a2a-41c2-ba26-79060b51f3d5": {
            "id": "86366b30-5a2a-41c2-ba26-79060b51f3d5",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "bar_1_task"
        }
    },
    "outTransitions": {
        "foo_1_task": [
            "8c5f2cc9-7c51-4358-8c79-b230c6a984de"
        ],
        "foo_2_task": [
            "ddc4149e-ca17-43c0-8bf7-d0f8a2f99746",
            "7320ba51-2785-4fae-8fba-e3a734ecadd1"
        ],
        "bar_1_task": [
            "51c55879-ca6c-4ab9-bb64-0f293241472d"
        ]
    },
    "inTransitions": {
        "foo_2_task": [
            "8c5f2cc9-7c51-4358-8c79-b230c6a984de"
        ],
        "foo_3_task": [
            "ddc4149e-ca17-43c0-8bf7-d0f8a2f99746"
        ],
        "bar_2_task": [
            "7320ba51-2785-4fae-8fba-e3a734ecadd1",
            "51c55879-ca6c-4ab9-bb64-0f293241472d"
        ],
        "foo_1_task": [
            "d0079f8d-366f-4b45-8f98-f206c3c1d07b"
        ],
        "bar_1_task": [
            "86366b30-5a2a-41c2-ba26-79060b51f3d5"
        ]
    }
}