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": "66b0068c-b72f-42a5-bc24-375f353555ff",
    "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": {
        "d9f2d05b-09ff-4466-a277-af0d73a89a70": {
            "id": "d9f2d05b-09ff-4466-a277-af0d73a89a70",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_1_task",
            "to": "foo_2_task"
        },
        "8919999c-9535-4bee-ad2c-e1274a573bd4": {
            "id": "8919999c-9535-4bee-ad2c-e1274a573bd4",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "foo_3_task"
        },
        "52c54cf6-5d41-423f-a6d0-3638067af588": {
            "id": "52c54cf6-5d41-423f-a6d0-3638067af588",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "foo_2_task",
            "to": "bar_2_task"
        },
        "89d8b613-b3aa-4db3-8242-29fbd9710c82": {
            "id": "89d8b613-b3aa-4db3-8242-29fbd9710c82",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "from": "bar_1_task",
            "to": "bar_2_task"
        },
        "7c67cbad-3250-4c69-983f-cf4429a41bcf": {
            "id": "7c67cbad-3250-4c69-983f-cf4429a41bcf",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "foo_1_task"
        },
        "ebfd01fe-238d-444f-a071-9b54002e619e": {
            "id": "ebfd01fe-238d-444f-a071-9b54002e619e",
            "weight": 1,
            "async": false,
            "active": true,
            "schema": "http:\/\/pvm.forma-pro.com\/schemas\/Transition.json",
            "to": "bar_1_task"
        }
    },
    "outTransitions": {
        "foo_1_task": [
            "d9f2d05b-09ff-4466-a277-af0d73a89a70"
        ],
        "foo_2_task": [
            "8919999c-9535-4bee-ad2c-e1274a573bd4",
            "52c54cf6-5d41-423f-a6d0-3638067af588"
        ],
        "bar_1_task": [
            "89d8b613-b3aa-4db3-8242-29fbd9710c82"
        ]
    },
    "inTransitions": {
        "foo_2_task": [
            "d9f2d05b-09ff-4466-a277-af0d73a89a70"
        ],
        "foo_3_task": [
            "8919999c-9535-4bee-ad2c-e1274a573bd4"
        ],
        "bar_2_task": [
            "52c54cf6-5d41-423f-a6d0-3638067af588",
            "89d8b613-b3aa-4db3-8242-29fbd9710c82"
        ],
        "foo_1_task": [
            "7c67cbad-3250-4c69-983f-cf4429a41bcf"
        ],
        "bar_1_task": [
            "ebfd01fe-238d-444f-a071-9b54002e619e"
        ]
    }
}