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": "36355557-8d81-4db2-800a-ec92b9cece6c",
    "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": {
        "a13b7c45-72ad-4fa9-85ee-b526be4d57f4": {
            "id": "a13b7c45-72ad-4fa9-85ee-b526be4d57f4",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_1_task",
            "to": "foo_2_task"
        },
        "b7d38200-2a0d-4aee-a3b6-74e19041f04c": {
            "id": "b7d38200-2a0d-4aee-a3b6-74e19041f04c",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "foo_3_task"
        },
        "33eea079-641e-4c6a-ae81-0b1575360188": {
            "id": "33eea079-641e-4c6a-ae81-0b1575360188",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "bar_2_task"
        },
        "1f6d9f57-d858-41d0-9c7f-e9f5b1d19d23": {
            "id": "1f6d9f57-d858-41d0-9c7f-e9f5b1d19d23",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "bar_1_task",
            "to": "bar_2_task"
        },
        "c77db063-792a-4cb7-b96b-2eabcbccc2b7": {
            "id": "c77db063-792a-4cb7-b96b-2eabcbccc2b7",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "foo_1_task"
        },
        "2696e95d-8171-4050-ae07-af271687460a": {
            "id": "2696e95d-8171-4050-ae07-af271687460a",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "bar_1_task"
        }
    },
    "outTransitions": {
        "foo_1_task": [
            "a13b7c45-72ad-4fa9-85ee-b526be4d57f4"
        ],
        "foo_2_task": [
            "b7d38200-2a0d-4aee-a3b6-74e19041f04c",
            "33eea079-641e-4c6a-ae81-0b1575360188"
        ],
        "bar_1_task": [
            "1f6d9f57-d858-41d0-9c7f-e9f5b1d19d23"
        ]
    },
    "inTransitions": {
        "foo_2_task": [
            "a13b7c45-72ad-4fa9-85ee-b526be4d57f4"
        ],
        "foo_3_task": [
            "b7d38200-2a0d-4aee-a3b6-74e19041f04c"
        ],
        "bar_2_task": [
            "33eea079-641e-4c6a-ae81-0b1575360188",
            "1f6d9f57-d858-41d0-9c7f-e9f5b1d19d23"
        ],
        "foo_1_task": [
            "c77db063-792a-4cb7-b96b-2eabcbccc2b7"
        ],
        "bar_1_task": [
            "2696e95d-8171-4050-ae07-af271687460a"
        ]
    }
}