gupalo/bpmnworkflow

v1.0.21 2022-05-15 05:56 UTC

README

Install

composer require gupalo/bpmnworkflow

Example

Register extension

    $walker = new ProcessWalker(new ExtensionHandler([
        new DiscountProcedure(),
        new WithoutDiscountProcedure(),
        new PriceFunction(),
        new LocaleFunction(),
        new EqValueComparison(),
        new LessValueComparison(),
        new MoreValueComparison(),
    ]));

Loader bpmn

    $loader = (new BpmnDirLoader(__DIR__ . '/../BpmnDiagrams')

Context

    $cart = new Example\Cart\Cart(
        items: ['name' => 'cola', 'price' => 800],
        locale: 'en',
        price: 800,
    );
    $context = new DataContext($cart);

Walker

    $workflow = new Workflow($loader, $walker);
    $this->workflow->walk('cart_discount', $context);

Test

For test in main app need install require-dev dependency

composer require phpunit/phpunit --dev

Add to composer.json autoload-dev section

"autoload-dev": {
    "psr-4": {
        "Gupalo\\BpmnWorkflow\\Tests\\": "vendor/gupalo/bpmnworkflow/tests/"
    }
}

Execute

composer dump-autoload
php vendor/bin/phpunit vendor/gupalo/bpmnworkflow