Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3925

How to configure a Symfony workflow

$
0
0

I work on Symfony 4.2 version I made an Workflow Service, who has three places draft, reviewed and published

namespace App\Service;

use App\Entity\Article;
use Symfony\Component\Workflow\Exception\LogicException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class WorkflowService extends AbstractController
{
    function articleWorkflow(Article $article)
    {
        $post = $article;

        $workflow = $this->container->get('workflow.article_publishing');

        $workflow->can($post, 'publish');
        $workflow->can($post, 'to_review');

        try {
            $workflow->apply($post, 'to_review');
        } catch (LogicException $exception) {
            sprintf('%s', $exception->getMessage());
        }

        $transitions = $workflow->getEnabledTransitions($post);
    }

}

I add to conf/products/framework.yaml this lines of code. But i don't understand what is currentPlace in the code. I worked by this example https://symfony.com/doc/4.2/workflow.html

workflows:
        article_publishing:
            type: 'workflow'
            audit_trail:
                enabled: true
            marking_store:
                type: 'multiple_state'
                arguments:
                    - 'currentPlace'
            supports:
                - App\Entity\Article
            initial_marking: draft
            places:
                -draft
                -reviewed
                -published
            transitions:
                to_review:
                    from: draft
                    to:   reviewed
                publish:
                    from: reviewed
                    to:   published

But when I refresh the site I get this error

   Warning: array_map(): Argument #2 should be an array

Error


Viewing all articles
Browse latest Browse all 3925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>