brexis / laravel-workflow

Use the Symfony Workflow component in Laravel
MIT License
281 stars 105 forks source link

Don't work config guards #78

Open 4n70w4 opened 4 years ago

4n70w4 commented 4 years ago

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.

4n70w4 commented 4 years ago

https://github.com/symfony/workflow/commit/56696349b428bc34fdd2c0f3148a038aaca1e83e

4n70w4 commented 4 years ago

If you do not want to make support for such a configuration, then at least throw an exception that this is not supported. I had to spend the whole evening to understand why it does not work.