workflower-bundle icon indicating copy to clipboard operation
workflower-bundle copied to clipboard

problem load services workflower-bundle

Open wladimiravila opened this issue 10 years ago • 1 comments

Hello, I'm try to start a new symfony project with workflowerBundle and symfony 2.7.3 , but i have a little problem

my composer file: "phpmentors/workflower": "^1.0", "phpmentors/workflower-bundle": "^1.0"

my AppKernel : ... new PHPMentors\WorkflowerBundle\PHPMentorsWorkflowerBundle()

in my app/config/services.yml

imports: - { resource: "@PHPMentorsWorkflowerBundle/Resources/config/services.xml" }

but when I try run my app generate the next problem

RuntimeException in CheckReferenceValidityPass.php line 100: The definition "phpmentors_workflower.doctrine_lifecycle_listener" has a reference to an abstract definition "phpmentors_workflower.workflow_serializer". Abstract definitions cannot be the target of references.

can you help me?, I will like create a new application using your great bundle

do you have a little example working with your bundle?

regards!

wladimiravila avatar Aug 19 '15 01:08 wladimiravila

Sorry for lack of documentation. Here is a getting started guide. I hope this can help you.

Here is a workflow LoanRequestProcess,

  • Design a workflow in BPMN 2.0 definition
    • See the supported workflow elements
    • Write conditions in connecting objects as expressions for Symfony ExpressionLanguage
      • Process data which are provided by ProcessContextInterface can be referred as $foo === true
    • Store the workflow as LoanRequestProcess.bpmn in your BPMN 2.0 definition directory
  • Design an entity LoanRequestProcess
    • Implement ProcessContextInterface and WorkflowSerializableInterface
    • Add properties for your application as BPMS such like $currentActivity if necessary
    • See LoanRequestProcess in this comment
  • Design domain services to start processes, allocate/start/complete work items, etc.
    • Implement ProcessAwareInterface
    • WorkItemContextInterface objects will be mostly created in controllers, commands, and listeners
    • See LoanRequestProcessCompletionUsecase in this comment
  • Configure the service container
    • Map workflows to domain services
    • See services.yml in this comment

LoanRequestProcess.php:

...
use PHPMentors\Workflower\Persistence\WorkflowSerializableInterface;
use PHPMentors\Workflower\Process\ProcessContextInterface;
use PHPMentors\Workflower\Workflow\Workflow;
...
class LoanRequestProcess implements ProcessContextInterface, WorkflowSerializableInterface
{
    ...
    /**
     * @var Workflow
     */
    private $workflow;

    /**
     * @var string
     *
     * @Column(type="blob", name="serialized_workflow")
     */
    private $serializedWorkflow;
    ...
    /**
     * {@inheritdoc}
     */
    public function getProcessData()
    {
        return array(
            'foo` => $this->foo,
            'bar` => $this->bar,
            ...
        );
    }

    /**
     * {@inheritdoc}
     */
    public function setWorkflow(Workflow $workflow)
    {
        $this->workflow = $workflow;
    }

    /**
     * {@inheritdoc}
     */
    public function getWorkflow()
    {
        return $this->workflow;
    }

    /**
     * {@inheritdoc}
     */
    public function setSerializedWorkflow($workflow)
    {
        $this->serializedWorkflow = $workflow;
    }

    /**
     * {@inheritdoc}
     */
    public function getSerializedWorkflow()
    {
        if (is_resource($this->serializedWorkflow)) {
            return stream_get_contents($this->serializedWorkflow, -1, 0);
        } else {
            return $this->serializedWorkflow;
        }
    }
    ...

LoanRequestProcessCompletionUsecase.php:

...
use PHPMentors\DomainKata\Usecase\CommandUsecaseInterface;
use PHPMentors\Workflower\Process\Process;
use PHPMentors\Workflower\Process\ProcessAwareInterface;
use PHPMentors\Workflower\Process\WorkItemContextInterface;
use PHPMentors\Workflower\Workflow\Activity\ActivityInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
...
class LoanRequestProcessCompletionUsecase implements CommandUsecaseInterface, ProcessAwareInterface
{
    ...
    /**
     * @var Process
     */
    private $process;

    ...
    /**
     * {@inheritdoc}
     */
    public function setProcess(Process $process)
    {
        $this->process = $process;
    }
    ...

    /**
     * {@inheritdoc}
     */
    public function run(EntityInterface $entity)
    {
        assert($entity instanceof WorkItemContextInterface);

        $this->process->completeWorkItem($entity);
        ...

services.yml:

...
    app.loan_request_process_completion_usecase:
        class: "%app.loan_request_process_completion_usecase.class%"
        tags:
            - { name: phpmentors_workflower.process_aware, workflow: LoanRequestProcess, context: app }
        ...

iteman avatar Aug 19 '15 03:08 iteman