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": "c34ce37e-e15d-4f49-a543-c3f43e4a6e04",
    "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": {
        "893aaa24-bde1-440d-9f95-d5997deec158": {
            "id": "893aaa24-bde1-440d-9f95-d5997deec158",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_1_task",
            "to": "foo_2_task"
        },
        "4b805c31-99c6-4161-9639-eda30fab67f1": {
            "id": "4b805c31-99c6-4161-9639-eda30fab67f1",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "foo_3_task"
        },
        "9a4ef82d-16c3-428c-a36d-00d24a68f09f": {
            "id": "9a4ef82d-16c3-428c-a36d-00d24a68f09f",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "bar_2_task"
        },
        "d900c438-8da0-4f15-94ae-1142ac23dd9b": {
            "id": "d900c438-8da0-4f15-94ae-1142ac23dd9b",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "bar_1_task",
            "to": "bar_2_task"
        },
        "9780fb2c-f9e9-4a02-a501-758243d55bc3": {
            "id": "9780fb2c-f9e9-4a02-a501-758243d55bc3",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "foo_1_task"
        },
        "22d628d2-2042-4fc6-b02b-32eeb7637efb": {
            "id": "22d628d2-2042-4fc6-b02b-32eeb7637efb",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "bar_1_task"
        }
    },
    "outTransitions": {
        "foo_1_task": [
            "893aaa24-bde1-440d-9f95-d5997deec158"
        ],
        "foo_2_task": [
            "4b805c31-99c6-4161-9639-eda30fab67f1",
            "9a4ef82d-16c3-428c-a36d-00d24a68f09f"
        ],
        "bar_1_task": [
            "d900c438-8da0-4f15-94ae-1142ac23dd9b"
        ]
    },
    "inTransitions": {
        "foo_2_task": [
            "893aaa24-bde1-440d-9f95-d5997deec158"
        ],
        "foo_3_task": [
            "4b805c31-99c6-4161-9639-eda30fab67f1"
        ],
        "bar_2_task": [
            "9a4ef82d-16c3-428c-a36d-00d24a68f09f",
            "d900c438-8da0-4f15-94ae-1142ac23dd9b"
        ],
        "foo_1_task": [
            "9780fb2c-f9e9-4a02-a501-758243d55bc3"
        ],
        "bar_1_task": [
            "22d628d2-2042-4fc6-b02b-32eeb7637efb"
        ]
    }
}