/** * Overides the default start to attach the workflow definition, save it on database and run execution after all. */ public function start($parentId = null, AbstractWorkflowDefinition $workflowDefinition = null) { $this->workflow = $workflowDefinition ?: $this->getWorkflowDefinitionInstance(); $storage = new \ezcWorkflowDatabaseDefinitionStorage($this->db); $storage->save($this->workflow); return parent::start($parentId); }
<?php // Set up database connection. $db = ezcDbFactory::create('mysql://test@localhost/test'); // Set up workflow definition storage (database). $definition = new ezcWorkflowDatabaseDefinitionStorage($db); // Load latest version of workflow named "Test". $workflow = $definition->loadByName('Test'); // Set up database-based workflow executer. $execution = new ezcWorkflowDatabaseExecution($db); // Pass workflow object to workflow executer. $execution->workflow = $workflow; // Start workflow execution. $id = $execution->start();
public function testInteractiveSubWorkflow() { $this->setUpStartInputEnd(); $this->dbStorage->save($this->workflow); $this->setUpWorkflowWithSubWorkflow('StartInputEnd'); $this->dbStorage->save($this->workflow); $execution = new ezcWorkflowDatabaseExecution($this->db); $execution->workflow = $this->workflow; $id = $execution->start(); $this->assertNotNull($id); $this->assertFalse($execution->hasEnded()); $this->assertFalse($execution->isCancelled()); $this->assertFalse($execution->isResumed()); $this->assertTrue($execution->isSuspended()); $execution = new ezcWorkflowDatabaseExecution($this->db, $id); $this->assertFalse($execution->hasEnded()); $this->assertFalse($execution->isCancelled()); $this->assertFalse($execution->isResumed()); $this->assertTrue($execution->isSuspended()); $execution->resume(array('variable' => 'value')); $this->assertTrue($execution->hasEnded()); $this->assertFalse($execution->isCancelled()); $this->assertFalse($execution->isResumed()); $this->assertFalse($execution->isSuspended()); }