/** * Get a workflow by its name * * @param string $name Name that the workflow is referenced by * * @return AbstractWorkflow Workflow with the given if exists */ public function getWorkflow($name) { // First check if the workflow is in the the built list if (array_key_exists($name, $this->workflows)) { return $this->workflows[$name]; } elseif (array_key_exists($name, $this->workflowDefinitions)) { // If not check if the definition is in the list, and build it if it is $builder = new WorkflowBuilder($this->workflowDefinitions[$name]->getName()); $builder->contextClass($this->workflowDefinitions[$name]->getContextClass()); $builder = $this->workflowDefinitions[$name]->build($builder); $this->workflows[$name] = $builder->build(); return $this->workflows[$name]; } else { // If not that either, throw error throw new WorkflowNotFoundException($name, array_keys($this->workflowDefinitions)); } }
/** * @expectedException \TyHand\WorkflowBundle\Exceptions\ContextDoesNotImplementInterfaceException * @expectedExceptionMessage Context class "DateTime" does not implement required interface "TyHand\WorkflowBundle\Workflow\Context\ContextInterface" */ public function testContextClassMissingInterfaceException() { $builder = new WorkflowBuilder('test'); $builder->contextClass('TyHand\\WorkflowBundle\\Tests\\DummyContext'); $builder->contextClass('DateTime'); }