Giter VIP home page Giter VIP logo

laravel-workflow's Introduction

Laravel workflow Build Status

Use the Symfony Workflow component in Laravel

Installation

composer require brexis/laravel-workflow

For laravel <= 5.4

Add a ServiceProvider to your providers array in config/app.php:

<?php

'providers' => [
    ...
    Brexis\LaravelWorkflow\WorkflowServiceProvider::class,

]

Add the Workflow facade to your facades array:

<?php
    ...
    'Workflow' => Brexis\LaravelWorkflow\Facades\WorkflowFacade::class,

Configuration

Publish the config file

    php artisan vendor:publish --provider="Brexis\LaravelWorkflow\WorkflowServiceProvider"

Configure your workflow in config/workflow.php

<?php

return [
    'straight'   => [
        'type'          => 'workflow', // or 'state_machine'
        'marking_store' => [
            'type'      => 'multiple_state',
            'arguments' => ['currentPlace']
        ],
        'supports'      => ['App\BlogPost'],
        'places'        => ['draft', 'review', 'rejected', 'published'],
        'transitions'   => [
            'to_review' => [
                'from' => 'draft',
                'to'   => 'review'
            ],
            'publish' => [
                'from' => 'review',
                'to'   => 'published'
            ],
            'reject' => [
                'from' => 'review',
                'to'   => 'rejected'
            ]
        ],
    ]
];

Use the WorkflowTrait inside supported classes

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Brexis\LaravelWorkflow\Traits\WorkflowTrait;

class BlogPost extends Model
{
  use WorkflowTrait;

}

Usage

<?php

use App\BlogPost;
use Workflow;

$post = BlogPost::find(1);
$workflow = Workflow::get($post);
// if more than one workflow is defined for the BlogPost class
$workflow = Workflow::get($post, $workflowName);

$workflow->can($post, 'publish'); // False
$workflow->can($post, 'to_review'); // True
$transitions = $workflow->getEnabledTransitions($post);

// Apply a transition
$workflow->apply($post, 'to_review');
$post->save(); // Don't forget to persist the state

// Using the WorkflowTrait
$post->workflow_can('publish'); // True
$post->workflow_can('to_review'); // False

// Get the post transitions
foreach ($post->workflow_transitions() as $transition) {
    echo $transition->getName();
}
// if more than one workflow is defined for the BlogPost class
foreach ($post->workflow_transitions($workflowName) as $transition) {
    echo $transition->getName();
}

// Apply a transition
$post->workflow_apply('publish');
$post->save();

Use the events

This package provides a list of events fired during a transition

    Brexis\LaravelWorkflow\Events\Guard
    Brexis\LaravelWorkflow\Events\Leave
    Brexis\LaravelWorkflow\Events\Transition
    Brexis\LaravelWorkflow\Events\Enter
    Brexis\LaravelWorkflow\Events\Entered

You can subscribe to an event

<?php

namespace App\Listeners;

use Brexis\LaravelWorkflow\Events\GuardEvent;

class BlogPostWorkflowSubscriber
{
    /**
     * Handle workflow guard events.
     */
    public function onGuard(GuardEvent $event) {
        /** Symfony\Component\Workflow\Event\GuardEvent */
        $originalEvent = $event->getOriginalEvent();

        /** @var App\BlogPost $post */
        $post = $originalEvent->getSubject();
        $title = $post->title;

        if (empty($title)) {
            // Posts with no title should not be allowed
            $originalEvent->setBlocked(true);
        }
    }

    /**
     * Handle workflow leave event.
     */
    public function onLeave($event) {}

    /**
     * Handle workflow transition event.
     */
    public function onTransition($event) {}

    /**
     * Handle workflow enter event.
     */
    public function onEnter($event) {}

    /**
     * Handle workflow entered event.
     */
    public function onEntered($event) {}

    /**
     * Register the listeners for the subscriber.
     *
     * @param  Illuminate\Events\Dispatcher  $events
     */
    public function subscribe($events)
    {
        $events->listen(
            'Brexis\LaravelWorkflow\Events\GuardEvent',
            'App\Listeners\BlogPostWorkflowSubscriber@onGuard'
        );

        $events->listen(
            'Brexis\LaravelWorkflow\Events\LeaveEvent',
            'App\Listeners\BlogPostWorkflowSubscriber@onLeave'
        );

        $events->listen(
            'Brexis\LaravelWorkflow\Events\TransitionEvent',
            'App\Listeners\BlogPostWorkflowSubscriber@onTransition'
        );

        $events->listen(
            'Brexis\LaravelWorkflow\Events\EnterEvent',
            'App\Listeners\BlogPostWorkflowSubscriber@onEnter'
        );

        $events->listen(
            'Brexis\LaravelWorkflow\Events\EnteredEvent',
            'App\Listeners\BlogPostWorkflowSubscriber@onEntered'
        );
    }

}

Dump Workflows

Symfony workflow uses GraphvizDumper to create the workflow image. You may need to install the dot command of Graphviz

php artisan workflow:dump workflow_name --class App\\BlogPost

You can change the image format with the --format option. By default the format is png.

php artisan workflow:dump workflow_name --format=jpg

laravel-workflow's People

Contributors

arjanwestdorp avatar aymanterra avatar brexis avatar kblais avatar laurenkt avatar lguima avatar psmeets-devnl avatar symplworks avatar uniconstructor avatar zerodahero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-workflow's Issues

PR#22 broke the correct definition of workflow's multiple from.

I'm not sure what bug this should have fixed but it broke something else.

Instead of having 1 transition with multiple froms you get 2 transition with 1 from. This way you can't force a transition to have multiple froms.

This changed should be reverted or it a better fix should be created.

To be as precise as possible when using the example config:

<?php

return [
    'straight'   => [
        'type'          => 'state_machine',
        'marking_store' => [
            'type'      => 'single_state',
            'arguments' => ['currentPlace']
        ],
        'supports'      => ['App\Payment'],
        'places'        => ['initial', 'payment', 'waiting'],
        'transitions'   => [
            'transitions'   => [
                'payment_state'      => [
                    'from' => 'initial',
                    'to'   => 'payment',
                ],
                'waiting_state'      => [
                    'from' => [
                        'initial',
                        'payment',
                    ],
                    'to'   => 'waiting',
                ],
            ],
        ],
    ]
];

This is wat i expect:

{Symfony\Component\Workflow\Transition} [3]
 name = "waiting_state"
 froms = {array} [2]
  0 = "initial"
  1 = "payment"
 tos = {array} [1]
  0 = "waiting"

And this is what i get:

{Symfony\Component\Workflow\Transition} [3]
 name = "waiting_state"
 froms = {array} [1]
  0 = "initial"
 tos = {array} [1]
  0 = "waiting"
{Symfony\Component\Workflow\Transition} [3]
 name = "waiting_state"
 froms = {array} [1]
  0 = "payment"
 tos = {array} [1]
  0 = "waiting"

For now I am reverting back to 1.2.0 as this works there.

Originally posted by @MyDigitalLife in https://github.com/_render_node/MDEyOklzc3VlQ29tbWVudDQxNzI5MjMyOA==/timeline/issue_comment#issuecomment-417292328

PR#22 breaks the SINGLE transition with multi-froms into 2 individual transitions with single-from , and this act broke the assumption of workflow requiring all froms to be fulfilled before leaving the place.

Now fulfilling any one of the froms will make it transition and it's obviously incorrect. Also I've reverted the code back to its previous state and it worked perfectly & correctly.

Please revert PR#22 to make workflow usable according to the specs again. The main point here is that multi-from doesn't mean "fulfilling any of the them" but "fulfilling ALL of them".

Thanks very much.

Deprecations (Workflow >= 4.1)

Hi again,

With Workflow 4.1+, we get an 2 Deprecated Errors:

PHP Deprecated:  "Symfony/Component/Workflow/SupportStrategy/ClassInstanceSupportStrategy" is deprecated since Symfony 4.1. Use "Symfony/Component/Workflow/SupportStrategy/InstanceOfSupportStrategy" instead. in /home/olivier/dev/support/laravel/vendor/symfony/workflow/SupportStrategy/ClassInstanceSupportStrategy.php on line 14
PHP Deprecated:  The "Symfony/Component/Workflow/Registry::add()" method is deprecated since Symfony 4.1. Use addWorkflow() instead. in /home/olivier/dev/support/laravel/vendor/symfony/workflow/Registry.php on line 34

I may provide a PR. A new version may be required to handle the dependency version.

Does not work multiple "from"

<?php

return [
    'straight'   => [
        'type'          => 'state_machine',
        'marking_store' => [
            'type'      => 'single_state',
            'arguments' => ['currentPlace']
        ],
        'supports'      => ['App\Payment'],
        'places'        => ['initial', 'payment', 'waiting'],
        'transitions'   => [
            'transitions'   => [
                'payment_state'      => [
                    'from' => 'initial',
                    'to'   => 'payment',
                ],
                'waiting_state'      => [
                    'from' => [
                        'initial',
                        'payment',
                    ],
                    'to'   => 'waiting',
                ],
            ],
        ],
    ]
];

proposal

Laravel 5.7 not installing brexis/laravel-workflow

I attempted to run composer require brexis/laravel-workflow in my Laravel 5.7 and got the following errors:
Using version ^1.2 for brexis/laravel-workflow ./composer.json has been updated Loading composer repositories with package informationUpdating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages. Problem 1 - Conclusion: don't install brexis/laravel-workflow 1.2.2 - Conclusion: don't install brexis/laravel-workflow 1.2.1 - Conclusion: remove laravel/framework v5.7.5 - Installation request for brexis/laravel-workflow ^1.2 -> satisfiable by brexis/laravel-workflow[1.2.0 , 1.2.1, 1.2.2]. - Conclusion: don't install laravel/framework v5.7.5 - brexis/laravel-workflow 1.2.0 requires illuminate/console 5.3.* || 5.4.* || 5.5.* || 5.6.* -> satisfi able by illuminate/console[5.3.x-dev, 5.4.x-dev, 5.5.x-dev, 5.6.x-dev, v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5 .4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5. 33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.6.0, v5.6.1, v5.6.10, v5.6.1 1, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.2 3, v5.6.24, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.3 5, v5.6.36, v5.6.37, v5.6.38, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9]. - don't install illuminate/console 5.6.x-dev|don't install laravel/framework v5.7.5 - don't install illuminate/console v5.6.0|don't install laravel/framework v5.7.5 - don't install illuminate/console v5.6.1|don't install laravel/framework v5.7.5 - don't install illuminate/console v5.6.10|don't install laravel/framework v5.7.5 - don't install illuminate/console v5.6.11|don't install laravel/framework v5.7.5 - don't install illuminate/console v5.6.12|don't install laravel/framework v5.7.5 - don't install illuminate/console v5.6.13|don't install laravel/framework v5.7.5 - don't install illuminate/console v5.6.14|don't install laravel/framework v5.7.5 - don't install illuminate/console v5.6.15|don't install laravel/framework v5.7.5 - don't install illuminate/console v5.6.16|don't install laravel/framework v5.7.5 - don't install illuminate/console v5.6.17|don't install laravel/framework v5.7.5 - don't install illuminate/console v5.6.19|don't install laravel/framework v5.7.5 - don't install illuminate/console v5.6.2|don't install laravel/framework v5.7.5 - don't install illuminate/console v5.6.20|don't install laravel/framework v5.7.5 - don't install illuminate/console v5.6.21|don't install laravel/framework v5.7.5 - don't install illuminate/console v5.6.22|don't install laravel/framework v5.7.5
Is brexis/laravel-workflow going to be compatible with 5.7 soon?

Can't install this using composer

I've been trying for a week to install this on laravel 5.5. I keep getting an error that I need to have an updated version of the symfony/event-dispatcher. I try updating the event-dispatcher and I get an error about guzzle/guzzle 3.9.3 install. I have that installed for a different package but I also have guzzlehttp v6 installed for other packages. I can't remove guzzle but would seriously like to try using this package to create workflows in my app. Do you have any helpful suggestions for me @brexis ?

I know it is a composer issue and will post something on stackoverflow but I also want to know if it will work on laravel 5.5

Thanks

Abandoned?

So its been almost a months after I made my first pull request and have not gotten any response back yet. If this repo is no longer being maintained can we mark it as that? If its not abandoned can we maybe add someone with more time so that we have somebody that can review, merge and release other then @brexis?

Load Config from Database

Hi,
I'm using Laravel 5.6,
How can i fill transitions config from database?
I want to save my transitions on database and fill config file from that?
Is it possible to load a model in an anonymous function?

Thanks in advance

how to initial workflow when i create new database record? ("Call to a member function getTos() on null" Error)

Hi
when I try to use a workflow, I get an error like this:

Call to a member function getTos() on null

my config/workflow.php file :

<?php

return [
    'straight'   => [
        'type'          => 'workflow',
        'marking_store' => [
            'type'      => 'multiple_state',
            'arguments' => ['state']
        ],
        'supports'      => ["App\Task"],
        'places'        => ['draft', 'review', 'publish'],
        'transitions'   => [
            'drafting' => [
                'from' => 'draft',
                'to'   => 'review',
            ],
            'reviewing' => [
                'from' => 'review',
                'to'   => 'publish',
            ]
        ],
    ]
];

my Controller :

public function store(Request $request)
    {
        // validate the given request
        $data = $this->validate($request, [
            'title' => 'required|string|max:255',
        ]);



        // create a new incomplete task with the given title
        $task = Auth::user()->tasks()->create([
            'title' => $data['title'],
        ]);

        $task->workflow_apply('drafting');

        // flash a success message to the session
        session()->flash('status', 'Task Created!');

        // redirect to tasks index
        return redirect('/tasks');
    }

how i can initialize state of my task when i create new task?

Unable to find a workflow for class "App\BlogPost"

I followed all instructions, using laravel 6.6.2 and exection occurs Unable to find a workflow for class "App\BlogPost". .
laravel

I also want to mension that I couldn' find any database schema for blog_posts.
Would you like to give a link about it for more details?

Unable to listen transition guard event, and How guard is working here?

i follow the read me instruction, #53
still not able to connect how will it listen the events.
here is my listner,

<?php 
namespace App\Listeners;

use Brexis\LaravelWorkflow\Events\GuardEvent;

class ApprovalWorkflowListeners
{
    /**
     * Handle workflow guard events.
     */
    public function onGuard(GuardEvent $event) {
        /** Symfony\Component\Workflow\Event\GuardEvent */
        $originalEvent = $event->getOriginalEvent();
dd($originalEvent);
        /** @var App\BlogPost $post */
        $post = $originalEvent->getSubject();
        $title = $post->title;

        if (empty($title)) {
            // Posts with no title should not be allowed
            $originalEvent->setBlocked(true);
        }
    }

    /**
     * Handle workflow leave event.
     */
    public function onLeave($event) {
    	/** Symfony\Component\Workflow\Event\GuardEvent */
        $originalEvent = $event->getOriginalEvent();
dd($originalEvent);
    }

    /**
     * Handle workflow transition event.
     */
    public function onTransition($event) {
    	/** Symfony\Component\Workflow\Event\GuardEvent */
        $originalEvent = $event->getOriginalEvent();
dd($originalEvent);
    }

    /**
     * Handle workflow enter event.
     */
    public function onEnter($event) {
    	/** Symfony\Component\Workflow\Event\GuardEvent */
        $originalEvent = $event->getOriginalEvent();
dd($originalEvent);
    }

    /**
     * Handle workflow entered event.
     */
    public function onEntered($event) {
    	/** Symfony\Component\Workflow\Event\GuardEvent */
        $originalEvent = $event->getOriginalEvent();
dd($originalEvent);
    }

    /**
     * Register the listeners for the subscriber.
     *
     * @param  Illuminate\Events\Dispatcher  $events
     */
    public function subscribe($events)
    {
    	dd($events);
        $events->listen(
            'Brexis\LaravelWorkflow\Events\GuardEvent',
            'App\Listeners\ApprovalWorkflowListeners@onGuard'
        );

        $events->listen(
            'Brexis\LaravelWorkflow\Events\LeaveEvent',
            'App\Listeners\ApprovalWorkflowListeners@onLeave'
        );

        $events->listen(
            'Brexis\LaravelWorkflow\Events\TransitionEvent',
            'App\Listeners\ApprovalWorkflowListeners@onTransition'
        );

        $events->listen(
            'Brexis\LaravelWorkflow\Events\EnterEvent',
            'App\Listeners\ApprovalWorkflowListeners@onEnter'
        );

        $events->listen(
            'Brexis\LaravelWorkflow\Events\EnteredEvent',
            'App\Listeners\ApprovalWorkflowListeners@onEntered'
        );
    }

};

here my workflow config

<?php

return [
    'approval_workflow'   => [
        'type'          => 'workflow', //'state_machine',
        'marking_store' => [
            'type' => 'single_state', // 'multiple_state',
            'arguments' => ['status'],
        ],
        'supports'      => ['App\Plan'],
        'places'        => ['new', 'submitted', 'in_review_work', 'pending_for_review_l1', 'approved_l1', 'review_comments', 'rejected', 'pending_for_review_l2', 'approved_l2'],
        'transitions'   => [
            'submit' => [
                // ''
                'from' => 'new',
                'to'   => 'submitted',
            ],

            'review-pending-l1' =>[
                // 'guard'=> todo
                'from' => 'submitted',
                'to'   => 'pending_for_review_l1',
            ],
            
            'approve-l1' => [
                // 'guard'=> todo
                'from' => ['pending_for_review_l1'],
                'to'   => 'approved_l1',
            ],

            'review-pending-l2' => [
                'from' => ['approved_l1'],
                'to'   => 'pending_for_review_l2',
            ],

            'approve-l2' => [
                'from' => ['pending_for_review_l2'],
                'to'   => 'approved_l2',
            ],

            'review-comment' => [
                // 'guard'=>
                'from' => ['pending_for_review_l1','pending_for_review_l2'],
                'to'   => 'review_comments',
            ],

            'review-work' => [
                'from' => ['submitted','pending_for_review_l1','pending_for_review_l2','review_comments','rejected'],
                'to' => 'in_review_work',
            ],

            'reject' => [
                'from' => ['submitted','pending_for_review_l1','pending_for_review_l2'],
                'to' => 'rejected',
            ]
        ],
    ]
];
  

does event trigger automatically ?
In ApprovalWorkflowListeners onGuard should be called, i could validate and block the txn but no luck.

or we have to define in config like (symphony)
'review-pending-l1' =>[ 'guard'=> "has_role('customer')", 'from' => 'submitted', 'to' => 'pending_for_review_l1', ],
second, how can i implement guard in my workflow based on user role.
ex. if user has customer role he will see only submit only, and if user has managed role he will see approve, review, reject etc

Project activity

There are quite a lot of open issues and PRs and I was wondering if this project is still active. @brexis might it be a good idea to add another maintainer to this project, so more people can check issues and PRs?

I'd be willing to do this and I think there might be others that would like to contribute as well.

Call to undefined method Symfony\Component\Workflow\Registry::addWorkflow() on laravel v5.4

Every thing is fine but when i try to check the condition for it, by
$plan->workflow_can('submit')

it through an error Exception,

ErrorException {#1045 ▼ #message: "Call to undefined method Symfony\Component\Workflow\Registry::addWorkflow() (View: D:\Workspace\project\index.bla ▶" #code: 0 #file: "D:\Workspace\AutoMobile\buycopm\vendor\brexis\laravel-workflow\src\WorkflowRegistry.php" #line: 78 -previous: FatalThrowableError {#1111 ▶} ....

here is my config data set

return [ 'approval_workflow' => [ 'type' => 'workflow', //'state_machine', 'marking_store' => [ 'type' => 'single_state', // 'multiple_state', 'arguments' => ['status'], ], 'supports' => ['App\Plan'], 'places' => ['new', 'submit', 'in_review_work', 'pending_for_review_l1', 'approved_l1', 'review_comments', 'rejected', 'pending_for_review_l2', 'approved_l2'], 'transitions' => [ 'submit' => [ 'from' => 'new', 'to' => 'submit', ], 'approve-l1' => [ // 'guard'=> todo 'from' => ['pending_for_review_l1'], 'to' => 'approved_l1', ], 'approve-l2' => [ 'from' => ['pending_for_review_l2'], 'to' => 'approved_l2', ], 'review-comment' => [ // 'guard'=> 'from' => ['pending_for_review_l1','pending_for_review_l2'], 'to' => 'review_comments', ], 'review-work' => [ 'from' => ['submit','pending_for_review_l1','pending_for_review_l2','review_comments','rejected'], 'to' => 'in_review_work', ], 'reject' => [ 'from' => ['pending_for_review_l1','pending_for_review_l2'], 'to' => 'rejected', ] ], ] ];

i could not catch why this error.. any solution.
thanks.

Laravel 5.8 support?

composer require brexis/laravel-workflow

Using version ^1.2 for brexis/laravel-workflow
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install brexis/laravel-workflow 1.2.3
    - Conclusion: don't install brexis/laravel-workflow 1.2.2
    - Conclusion: don't install brexis/laravel-workflow 1.2.1
    - Conclusion: remove laravel/framework v5.8.13
    - Installation request for brexis/laravel-workflow ^1.2 -> satisfiable by brexis/laravel-workflow[1.2.0, 1.2.1, 1.2.2, 1.2.3].
    - Conclusion: don't install laravel/framework v5.8.13
    - brexis/laravel-workflow 1.2.0 requires illuminate/console 5.3.* || 5.4.* || 5.5.* || 5.6.* -> satisfiable by laravel/framework[5.3.x-dev, 5.4.x-dev, 5.5.x-dev, 5.6.x-dev], illuminate/console[5.3.x-dev, 5.4.x-dev, 5.5.x-dev, 5.6.x-dev, v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.5.44, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9].
    - Can only install one of: laravel/framework[5.3.x-dev, v5.8.13].
    - Can only install one of: laravel/framework[5.4.x-dev, v5.8.13].
    - Can only install one of: laravel/framework[5.5.x-dev, v5.8.13].
    - Can only install one of: laravel/framework[5.6.x-dev, v5.8.13].
    - don't install illuminate/console 5.5.x-dev|don't install laravel/framework v5.8.13
    - don't install illuminate/console 5.6.x-dev|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.5.0|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.5.16|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.5.17|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.5.2|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.5.28|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.5.33|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.5.34|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.5.35|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.5.36|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.5.37|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.5.39|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.5.40|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.5.41|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.5.43|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.5.44|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.0|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.1|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.10|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.11|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.12|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.13|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.14|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.15|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.16|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.17|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.19|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.2|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.20|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.21|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.22|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.23|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.24|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.26|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.27|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.28|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.29|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.3|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.30|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.31|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.32|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.33|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.34|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.35|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.36|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.37|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.38|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.39|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.4|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.5|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.6|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.7|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.8|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.6.9|don't install laravel/framework v5.8.13
    - don't install illuminate/console 5.3.x-dev|don't install laravel/framework v5.8.13
    - don't install illuminate/console 5.4.x-dev|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.3.0|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.3.16|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.3.23|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.3.4|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.4.0|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.4.13|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.4.17|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.4.19|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.4.27|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.4.36|don't install laravel/framework v5.8.13
    - don't install illuminate/console v5.4.9|don't install laravel/framework v5.8.13
    - Installation request for laravel/framework (locked at v5.8.13, required as 5.8.*) -> satisfiable by laravel/framework[v5.8.13].


Installation failed, reverting ./composer.json to its original content.

Service Provider's mergeConfigFrom() always mix in the "straight" demo workflow

$this->mergeConfigFrom(

In my opinion the mergeConfigFrom() is not necessary because the config publishing already provides a demo workflow for users to get started. Moreover, merging it in Service Provider actually contaminates the user's workflow config by adding a demo entry ("straight") every time while actually nobody needs it.

Please remove the mergeConfigFrom() from the Service Provider, thanks very much!

Events not firing as expected.

I've set up a workflow similar to the one in the README. I've also set up the listeners similar to the work flow and added some code that should be executed by the listeners.
However it doesn't seem like the events are firing or the listeners are not detecting the fired events.
Is there something else specific that I need to do to get this to work?

Thanks!

Does not install on Laravel 6.15.0

composer require brexis/laravel-workflow
Using version ^1.3 for brexis/laravel-workflow
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Conclusion: don't install brexis/laravel-workflow 1.3.3
- Conclusion: don't install brexis/laravel-workflow 1.3.2
- Conclusion: don't install brexis/laravel-workflow 1.3.1
- Installation request for symfony/workflow (locked at v5.0.4, required as ^5.0) -> satisfiable by symfony/workflow[v5.0.4].
- Conclusion: remove laravel/framework v6.15.0
- Installation request for brexis/laravel-workflow ^1.3 -> satisfiable by brexis/laravel-workflow[1.3.0, 1.3.1, 1.3.2, 1.3.3].
- Conclusion: don't install laravel/framework v6.15.0
- brexis/laravel-workflow 1.3.0 requires illuminate/support 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* -> satisfiable by illuminate/support[5.3.x-dev, 5.4.x-dev, 5.5.x-dev, 5.6.x-dev, 5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, 5.8.x-dev, v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.5.44, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9, v5.7.0, v5.7.1, v5.7.10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.36, v5.8.4, v5.8.8, v5.8.9].
- don't install illuminate/support 5.5.x-dev|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.5.0|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.5.16|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.5.17|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.5.2|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.5.28|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.5.33|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.5.34|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.5.35|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.5.36|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.5.37|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.5.39|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.5.40|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.5.41|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.5.43|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.5.44|don't install laravel/framework v6.15.0
- don't install illuminate/support 5.6.x-dev|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.0|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.1|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.10|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.11|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.12|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.13|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.14|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.15|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.16|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.17|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.19|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.2|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.20|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.21|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.22|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.23|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.24|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.25|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.26|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.27|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.28|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.29|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.3|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.30|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.31|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.32|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.33|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.34|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.35|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.36|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.37|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.38|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.39|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.4|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.5|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.6|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.7|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.8|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.6.9|don't install laravel/framework v6.15.0
- don't install illuminate/support 5.7.17|don't install laravel/framework v6.15.0
- don't install illuminate/support 5.7.18|don't install laravel/framework v6.15.0
- don't install illuminate/support 5.7.19|don't install laravel/framework v6.15.0
- don't install illuminate/support 5.7.x-dev|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.7.0|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.7.1|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.7.10|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.7.11|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.7.15|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.7.2|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.7.20|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.7.21|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.7.22|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.7.23|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.7.26|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.7.27|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.7.28|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.7.3|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.7.4|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.7.5|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.7.6|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.7.7|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.7.8|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.7.9|don't install laravel/framework v6.15.0
- don't install illuminate/support 5.8.x-dev|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.0|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.11|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.12|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.14|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.15|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.17|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.18|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.19|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.2|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.20|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.22|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.24|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.27|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.28|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.29|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.3|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.30|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.31|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.32|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.33|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.34|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.35|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.36|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.4|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.8|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.8.9|don't install laravel/framework v6.15.0
- don't install illuminate/support 5.3.x-dev|don't install laravel/framework v6.15.0
- don't install illuminate/support 5.4.x-dev|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.3.0|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.3.16|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.3.23|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.3.4|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.4.0|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.4.13|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.4.17|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.4.19|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.4.27|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.4.36|don't install laravel/framework v6.15.0
- don't install illuminate/support v5.4.9|don't install laravel/framework v6.15.0
- Installation request for laravel/framework (locked at v6.15.0, required as ^6.2) -> satisfiable by laravel/framework[v6.15.0].

Installation failed, reverting ./composer.json to its original content.

Using workflow_transitions in WorkflowTrait gives exception

Issue :
When more than one workflow is defined for the same class the method workflow_transitions gives exception with message "At least two workflows match this subject. Set a different name on each and use the second (name) argument of this method."

Solution :
Passing workflow name in method argument.

Pull Request :
#34

Package won't work with symfony/workflow < 4.1

While trying to figure an issue I have with the package, I realized it can't work with symfony/workflow < 4.1 since 1.3.0 because of the use of InstanceOfSupportStrategy here :

$this->registry->addWorkflow($workflow, new InstanceOfSupportStrategy($supportStrategy));

This class was introduced in symfony/workflow 4.1 to replace the now-deprecated ClassInstanceSupportStrategy.

So either we define the minimum requirement to "symfony/worflow": "^4.1", or we add a compatibility layer to check if InstanceOfSupportStrategy exists, and if not use the ClassInstanceSupportStrategy.

What do you think about this ?

Pass to workflow:dump custom worflow config file

Hi! I use module structure of app. And each package contains self workflow configurations for own entities.

For load custom config in my app I use:

$registry = new WorkflowRegistry(app('config')->get('another-workflow'));

It would be useful to be able to specify a configuration file for this command.

Don't work config guards

symfony/workflow v4.4.2

https://symfony.com/doc/4.4/workflow.html#blocking-transitions

        'transitions' => [
            'work'=> [
                'guard' => 'subject.canWork()',
                'from' => 'draft',
                'to' => 'work',
            ],
    public function canWork() {
        return false;
    }
$e = Test::find(34089);

$e->workflow_can('work');
// true

$e->workflow_apply('work');
dump($e->status);
//    "status" => "work"

But this method does not call and completely ignores.

Type Error with MultipleStateMarkingStore

Hi,

I'm trying to understand how multiple state marking works, i.e. when there are more than one argument. I cannot find ANY documentation anywhere, no tutorial explains how it is supposed to work, they always define the first argument, and nothing else... Anyway.

I get this error:
TypeError: Argument 2 passed to Symfony/Component/Workflow/MarkingStore/MultipleStateMarkingStore::__construct() must implement interface Symfony/Component/PropertyAccess/PropertyAccessorInterface or be null, string given

Here's the workflow definition (please note that the arguments are just for testing)

'ideas'   => [
        'type'          => 'state_machine', // or 'workflow'
        'marking_store' => [
            'type'      => 'multiple_state',
            'arguments' => ['foo', 'bar']
        ],
        'supports'      => [Idea::class],
        'places'        => [
            'proposal',
            'considered',
            'implementing',
            'added',
            'rejected',
            'abandoned',
            'on_hold'
        ],
        'transitions'   => [
            'consider' => [
                'from' => 'proposal',
                'to'   => 'considered'
            ],
            'implement' => [
                'from' => 'considered',
                'to'   => 'implementing'
            ],
            'add' => [
                'from' => 'implementing',
                'to'   => 'added'
            ],
            'reject' => [
                'from' => ['proposal', 'considered'],
                'to' => 'rejected'
            ],
            'abandon' => [
                'from' => 'implementing',
                'to' => 'abandoned'
            ],
            'hold' => [
                'from' => 'implementing',
                'to' => 'on_hold'
            ],
            'continue' => [
                'from' => 'on_hold',
                'to' => 'implementing'
            ]
        ],
    ]

The migration for the ideas table:

Schema::create('ideas', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('foo')->nullable();
            $table->string('bar')->nullable();
            $table->timestamps();
        });

And the model (very basic):

class Idea extends Model
{
    use WorkflowTrait;  
}

Then, in Tinker:

psysh> $idea = Idea::find(1)
=> Arcesilas\Feedback\Models\Idea {#2946
     id: 1,
     name: "Great Idea",
     foo: null,
     bar: null,
     created_at: "2019-02-21 03:05:05",
     updated_at: "2019-02-21 03:05:05",
   }
psysh> $wf = Workflow::get($idea)
TypeError: Argument 2 passed to Symfony/Component/Workflow/MarkingStore/MultipleStateMarkingStore::__construct() must implement interface Symfony/Component/PropertyAccess/PropertyAccessorInterface or be null, string given

If I change arguments to:

 'arguments' => ['foo']

it works.
Here, the type is state_machine, the error also happens with workflow type.

⚠️ There is also a Deprecated error, which I have omitted (I'm reporting it in another issue, it's related to version 4.2)

v1.1.2 require php ^7.1.3

I'm on PHP 7.0.3.
laravel-workflow 1.1.2 should require php: >=5.5.9 but it include symfony workflow ^3.3 which include symfony/property-access ~2.3|~3.0|~4.0 and this require PHP ^7.1.3
It breaks composer install on my machine.

composer require fail

composer require brexis/laravel-workflow
Using version ^1.2 for brexis/laravel-workflow
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 4 installs, 0 updates, 0 removals

  • Installing symfony/inflector (v4.1.2): Loading from cache
  • Installing symfony/property-access (v4.1.2): Loading from cache
  • Installing symfony/workflow (v4.1.2): Loading from cache
  • Installing brexis/laravel-workflow (1.2.1): Loading from cache
    Writing lock file
    Generating optimized autoload files

Illuminate\Foundation\ComposerScripts::postAutoloadDump
@php artisan ide-helper:generate

Symfony\Component\Debug\Exception\FatalThrowableError : Argument 1 passed to Brexis\LaravelWorkflow\WorkflowRegistry::__construct() must be of the type array, null given, called in /Users/liwei/PhpstormProjects/eCollect/vendor/brexis/laravel-workflow/src/WorkflowServiceProvider.php on line 39

at /Users/liwei/PhpstormProjects/eCollect/vendor/brexis/laravel-workflow/src/WorkflowRegistry.php:44

Workflow $workflowName is not configured

Exception : Workflow workflow_name is not configured.

at /var/www/html/laravel/brexis/vendor/symfony-rot-ebal/laravel-workflow/src/Commands/WorkflowDumpCommand.php:49
45| $class = $this->option('class');
46| $config = Config::get('workflow');
47|
48| if (!isset($config[$workflowName])) {

49| throw new Exception("Workflow $workflowName is not configured.");
50| }
51|
52| if (false === array_search($class, $config[$workflowName]['supports'])) {
53| throw new Exception("Workflow $workflowName has no support for class $class.".

Exception trace:

1 Brexis\LaravelWorkflow\Commands\WorkflowDumpCommand::handle()
/var/www/html/laravel/brexis/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32

2 call_user_func_array([])
/var/www/html/laravel/brexis/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32

Please use the argument -v to see more details.

config path issue

Hi,

I'm using lumen 5.6.

I did the steps ::

  1. composer require : "brexis/laravel-workflow": "^1.2"
  2. bootstrap/app.php :
    I. $app->register(Brexis\LaravelWorkflow\WorkflowServiceProvider::class);
    II. $app->routeMiddleware(['Workflow' => Brexis\LaravelWorkflow\Facades\WorkflowFacade::class,]);

And i publish the vendor using this command

php artisan vendor:publish --provider="Brexis\LaravelWorkflow\WorkflowServiceProvider"

I got a error:

In WorkflowServiceProvider.php line 25:

Call to undefined function Brexis\LaravelWorkflow\config_path()

Kindly clear this issue.

Thanks.

The transition guard event isn't fired

In Brexis\LaravelWorkflow\Events\WorkflowSubscriber::guardEvent() only the general guard event for the workflow is fired, but not the event for the specific transition (workflow.[workflow name].guard.[transition name]).

To allow someone to create a listener for a specific transition guard, the event has to be thrown. I think it's solved by adding this line to the method:

event('workflow.'.$event->getWorkflowName().'.guard.'.$event->getTransition()->getName(), $event);

If you want, I could create a pull request for this. Thanks!

Symfony 4.1 metadata is not accessible

even after changes from New in Symfony 4.1: Workflow improvements were applied:

WorkflowRegistry.php:

use Symfony\Component\Workflow\SupportStrategy\InstanceOfSupportStrategy;
public function add(Workflow $workflow, $supportStrategy)
{
$this->registry->addWorkflow($workflow, new InstanceOfSupportStrategy($supportStrategy));
}

InMemoryMetadataStore {#1152
-workflowMetadata: []
-placesMetadata: []
-transitionsMetadata: SplObjectStorage {#1153
storage: []
}
}
metadata ist defined but MetadataStore stays empty.

Sorry. I tried but was not able to fix it.
Maybe some Symfony-Components to handle metadata are missing.

Simple sample for work with Workflow events

Hi,
does Anyone use this package in their project?
How to use symfony-workflow-events in project?

if anyone create project with this package, is it possible to publish example/project (open-source form) to understand how can we use events in the projects ?

Workflow <my_workflow> has no support for class

when I try to dump a workflow by:
php artisan dump:workflow my_workflow
I get an error like this:
In WorkflowDumpCommand.php line 53:
Workflow <my_workflow> has no support for class

in config there is a row with "supports" parameter and correct value (because workflow is working)
how to solve it?

Understandable example

Hi,
It's possible to publish an understandable example or a complete tutorial?
I don't know what are the fields of BlogPost model. Where are stored workflowName?
Running the sample I receive "publishreject" but I don't understand why?

Thanks.

Usage in blade template

Hi,
this question was actually part of another issue, which has now been marked as being solved. However this part may still be open, that is why I want to repeat it as new issue.

Is There A way To Use:
workflow_can()
workflow_transitions()
workflow_marked_places()
workflow_has_marked_place()

in blade template ?

Like in the example of Symfony https://symfony.com/doc/current/workflow/usage.html

Thank's

How to choose the second tos

config/workflow.php

<?php

return [
    'straight'   => [
        'type'          => 'workflow',
        'marking_store' => [
            'type'      => 'multiple_state',
            'arguments' => ['currentPlace']
        ],
        'supports'      => ['App\BlogPost'],
        'places'        => ['draft', 'review', 'rejected', 'published'],
        'transitions'   => [
            'to_review' => [
                'from' => 'draft',
                'to'   => 'review'
            ],
            'approval' => [
                'from' => 'review',
                'to'   => ['published','rejected']
            ]
        ],
    ]
];

when approval how can i choose 'rejected' without add third transition

$workflow->apply($post, 'approval');

my code just can choose 'published'

Array to String Conversion on save()

I am trying to follow your documentation and am getting an error on $post->save();

Array to string conversion (SQL: update blogposts set updated_at = 2018-04-04 03:09:38, currentPlace = 1 where id = 1)

Can you point me in the right direction.

Sorry if this is a simple question.

Drop support for symfony/workflow 3.2?

The project's current requirements in composer.json allow it to be used with symfony/workflow 3.2.

However, due to #2, the project will no longer work with 3.2.

It will throw the following error (in WorkflowRegistry.php line 63):

[Symfony\Component\Debug\Exception\FatalThrowableError]                                    
Class 'Symfony\Component\Workflow\SupportStrategy\ClassInstanceSupportStrategy' not found

So a decision needs to be made about whether to patch in support for 3.2 again, or revert the change, or drop support for 3.2 from composer.json.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.