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": "cb33d998-c7cc-4165-a8a8-8d0ac889841a",
    "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": {
        "a284f4df-ef62-4418-9b99-c6b399bad2f9": {
            "id": "a284f4df-ef62-4418-9b99-c6b399bad2f9",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_1_task",
            "to": "foo_2_task"
        },
        "e9a24aac-0c0a-45e1-bb89-90a464a61b5d": {
            "id": "e9a24aac-0c0a-45e1-bb89-90a464a61b5d",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "foo_3_task"
        },
        "1fe7adf2-fc9a-403a-a676-e24c5886916e": {
            "id": "1fe7adf2-fc9a-403a-a676-e24c5886916e",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "bar_2_task"
        },
        "8fe57dd9-9994-4cc2-8aab-cccb1327bd02": {
            "id": "8fe57dd9-9994-4cc2-8aab-cccb1327bd02",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "bar_1_task",
            "to": "bar_2_task"
        },
        "413a288b-7525-4007-af7e-8767ba011c5c": {
            "id": "413a288b-7525-4007-af7e-8767ba011c5c",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "foo_1_task"
        },
        "e5777169-f8c6-43b0-ab03-18d45833881a": {
            "id": "e5777169-f8c6-43b0-ab03-18d45833881a",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "bar_1_task"
        }
    },
    "outTransitions": {
        "foo_1_task": [
            "a284f4df-ef62-4418-9b99-c6b399bad2f9"
        ],
        "foo_2_task": [
            "e9a24aac-0c0a-45e1-bb89-90a464a61b5d",
            "1fe7adf2-fc9a-403a-a676-e24c5886916e"
        ],
        "bar_1_task": [
            "8fe57dd9-9994-4cc2-8aab-cccb1327bd02"
        ]
    },
    "inTransitions": {
        "foo_2_task": [
            "a284f4df-ef62-4418-9b99-c6b399bad2f9"
        ],
        "foo_3_task": [
            "e9a24aac-0c0a-45e1-bb89-90a464a61b5d"
        ],
        "bar_2_task": [
            "1fe7adf2-fc9a-403a-a676-e24c5886916e",
            "8fe57dd9-9994-4cc2-8aab-cccb1327bd02"
        ],
        "foo_1_task": [
            "413a288b-7525-4007-af7e-8767ba011c5c"
        ],
        "bar_1_task": [
            "e5777169-f8c6-43b0-ab03-18d45833881a"
        ]
    }
}