/**
  * 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);
 }
Esempio n. 2
0
<?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();
Esempio n. 3
0
$signals->connect('afterExecutionStarted', array($receiver, 'afterExecutionStarted'));
$signals->connect('afterExecutionSuspended', array($receiver, 'afterExecutionSuspended'));
$signals->connect('afterExecutionResumed', array($receiver, 'afterExecutionResumed'));
$signals->connect('afterExecutionCancelled', array($receiver, 'afterExecutionCancelled'));
$signals->connect('afterExecutionEnded', array($receiver, 'afterExecutionEnded'));
$signals->connect('beforeNodeActivated', array($receiver, 'beforeNodeActivated'));
$signals->connect('afterNodeActivated', array($receiver, 'afterNodeActivated'));
$signals->connect('afterNodeExecuted', array($receiver, 'afterNodeExecuted'));
$signals->connect('afterRolledBackServiceObject', array($receiver, 'afterRolledBackServiceObject'));
$signals->connect('afterThreadStarted', array($receiver, 'afterThreadStarted'));
$signals->connect('afterThreadEnded', array($receiver, 'afterThreadEnded'));
$signals->connect('beforeVariableSet', array($receiver, 'beforeVariableSet'));
$signals->connect('afterVariableSet', array($receiver, 'afterVariableSet'));
$signals->connect('beforeVariableUnset', array($receiver, 'beforeVariableUnset'));
$signals->connect('afterVariableUnset', array($receiver, 'afterVariableUnset'));
// 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;
// Register SignalSlot workflow engine plugin.
$plugin = new ezcWorkflowSignalSlotPlugin();
$plugin->signals = $signals;
$execution->addPlugin($plugin);
// Start workflow execution.
$id = $execution->start();
Esempio n. 4
0
 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());
 }
Esempio n. 5
0
<?php

// Set up database connection.
$db = ezcDbFactory::create('mysql://test@localhost/test');
// Set up database-based workflow executer.
$execution = new ezcWorkflowDatabaseExecution($db, $id);
// Resume workflow execution.
$execution->resume(array('choice' => true));
Esempio n. 6
0
<?php

// Set up database connection.
$db = ezcDbFactory::create('mysql://test@localhost/test');
// Set up database-based workflow executer.
$execution = new ezcWorkflowDatabaseExecution($db, $id);
// Cancel workflow execution.
$execution->cancel();
Esempio n. 7
0
<?php

// Set up the logfile writer.
$writer = new ezcLogUnixFileWriter('/tmp/workflow.log');
$log = ezcLog::getInstance();
$mapper = $log->getMapper();
$filter = new ezcLogFilter();
$rule = new ezcLogFilterRule($filter, $writer, true);
$mapper->appendRule($rule);
// 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;
// Attach logfile writer as a listener.
$execution->addListener(new ezcWorkflowEventLogListener($log));
// Start workflow execution.
$id = $execution->start();