yokai-php / sonata-workflow

Integrate Symfony workflow component in Sonata Admin
MIT License
22 stars 11 forks source link

Multiple workflow support #32

Closed tonyellow closed 2 years ago

tonyellow commented 3 years ago

I have multiple workflows configured for some entities. Symfony 4 has support for it, this plugin does not, is that correct? I can not find a way to pass a specific workflow to this manager. Thanks in advance!

yann-eugone commented 3 years ago

Did you had a look to the "workflow_name" option of the extension constructor in README ?

When you have multiple workflow on your entities, you cannot register a global extension. You have to register the extension as many time as you want fore each workflow you want to cover.

Let say you have 2 workflow for your PullRequest entity (workflow_a & workflow_b), you will end with something like :

    admin.extension.pull_request_workflow.workflow_a:
        class: Yokai\SonataWorkflow\Admin\Extension\WorkflowExtension
        public: true
        arguments:
            - '@workflow.registry'
            - workflow_name: workflow_a

    admin.extension.pull_request_workflow.workflow_b:
        class: Yokai\SonataWorkflow\Admin\Extension\WorkflowExtension
        public: true
        arguments:
            - '@workflow.registry'
            - workflow_name: workflow_b

sonata_admin:
    extensions:
        admin.extension.pull_request_workflow.workflow_a:
            admins:
                - admin.pull_request
        admin.extension.pull_request_workflow.workflow_b:
            admins:
                - admin.pull_request
yann-eugone commented 2 years ago

Considering the issues as answered