Symfony\Component\Workflow\Registry::get PHP Method

get() public method

public get ( object $subject, string | null $workflowName = null ) : Symfony\Component\Workflow\Workflow
$subject object
$workflowName string | null
return Symfony\Component\Workflow\Workflow
    public function get($subject, $workflowName = null)
    {
        $matched = null;
        foreach ($this->workflows as list($workflow, $className)) {
            if ($this->supports($workflow, $className, $subject, $workflowName)) {
                if ($matched) {
                    throw new InvalidArgumentException('At least two workflows match this subject. Set a different name on each and use the second (name) argument of this method.');
                }
                $matched = $workflow;
            }
        }
        if (!$matched) {
            throw new InvalidArgumentException(sprintf('Unable to find a workflow for class "%s".', get_class($subject)));
        }
        return $matched;
    }