Skip to content

Add the event event for conditioned transition #173

@caleeli

Description

@caleeli

As a developer I want to catch when a Sequence flow is activated so I can execute additional logic to the Flow, like evaluate expressions and assign values to variables.

To do that, add the following behavior to the FlowInterface:

interface FlowInterface extends EntityInterface, ObservableInterface
{
    const EVENT_FLOW_ACTIVATED = 'EVENT_FLOW_ACTIVATED';

    /**
     * Register the flow events during the process building
     */
    public function registerFlowEvents();

    /**
     * Get the transition object that is triggered when
     * this flow is activated.
     *
     * @return TransitionInterface
     */
    public function getTransition();

    /**
     * Set the transition object that triggers this flow object
     *
     * @return void
     */
    public function setTransition(TransitionInterface $transition);
}

Example of use in a extension of class Flow

class ExtendedFlow extends Flow
{
  use ListenFlowOperations;
}
trait ListenFlowOperations
{
    protected function initListenFlowOperations()
    {
        $this->attachEvent(Flow::EVENT_FLOW_ACTIVATED, function () {
            // do the operations
        });
    }
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions