src/Infrastructure/Workflow/Guard.php
public function accept(StatefulSubjectInterface $subject)
    {
        $execution_context = $subject->getExecutionContext();
        $parameters = $execution_context->getParameters();

        if (is_array($parameters)) {
            $params = $parameters;
        } elseif (is_object($parameters) && is_callable(array($parameters, 'toArray'))) {
            $params = $parameters->toArray();
        } else {
            throw new RuntimeError(
                'The $subject->getExecutionContext()->getParameters() must return array or object with toArray method.'
            );
        }

        $transition_acceptable = $this->expression_service->evaluate(
            $this->options->get('expression'),
            array_merge(
                $params,
                [
                    'subject' => $subject,
                    'current_user' => $this->environment->getUser(),
                ]
            )
        );

        return (bool)$transition_acceptable;
    }
public function accept(StatefulSubjectInterface $subject)
    {
        $execution_context = $subject->getExecutionContext();
        $parameters = $execution_context->getParameters();

        if (is_array($parameters)) {
            $params = $parameters;
        } elseif (is_object($parameters) && is_callable(array($parameters, 'toArray'))) {
            $params = $parameters->toArray();
        } else {
            throw new RuntimeError(
                'The $subject->getExecutionContext()->getParameters() must return array or object with toArray method.'
            );
        }

        $transition_acceptable = $this->expression_service->evaluate(
            $this->options->get('expression'),
            array_merge(
                $params,
                [
                    'subject' => $subject,
                    'current_user' => $this->environment->getUser(),
                ]
            )
        );

        return (bool)$transition_acceptable;
    }
public function accept ( StatefulSubjectInterface $ subject ) { $ execution_context = $ subject -> getExecutionContext ( ) ; $ parameters = $ execution_context -> getParameters ( ) ; if ( is_array ( $ parameters ) ) { $ params = $ parameters ; } elseif ( is_object ( $ parameters ) && is_callable ( array ( $ parameters , 'toArray' ) ) ) { $ params = $ parameters -> toArray ( ) ; } else { throw new RuntimeError ( 'The $subject->getExecutionContext()->getParameters() must return array or object with toArray method.' ) ; } $ transition_acceptable = $ this -> expression_service -> evaluate ( $ this -> options -> get ( 'expression' ) , array_merge ( $ params , [ 'subject' => $ subject , 'current_user' => $ this -> environment -> getUser ( ) , ] ) ) ; return ( bool ) $ transition_acceptable ; }
Evaluates the configured expression for the given subject. The expression may
use the current user as "current_user" and the subject as "subject".

@param StatefulSubjectInterface $subject

@return boolean true if transition is acceptable
Evaluates the configured expression for the given subject . The expression may use the current user as current_user and the subject as subject .