/**
* @see ExecutableInterface::execute()
*/
public function execute()
{
if (!$this->isStarted()) {
throw new \Exception('Procedure not started');
}
if (!$this->getCurrentUnitProcedure()) {
$this->setFinished();
return;
}
// Start the next unit procedure?
if ($this->getCurrentUnitProcedure()->isFinished()) {
// Go to next unit procedure if possible
if ($this->unitProcedures->next()) {
$this->getCurrentUnitProcedure()->setEventDispatcher($this->eventDispatcher);
$this->getCurrentUnitProcedure()->start();
} else {
// If last unit procedure is finished
// set the finished flag
$this->setFinished();
}
}
// Execute
if (!$this->finished && $this->getCurrentUnitProcedure()->isStarted()) {
// Perform unit procedure
$this->getCurrentUnitProcedure()->execute();
}
}