ezcWorkflowDefinitionStorageXml::loadByName PHP Method

loadByName() public method

When the $workflowVersion argument is omitted, the most recent version is loaded.
public loadByName ( string $workflowName, integer $workflowVersion ) : ezcWorkflow
$workflowName string
$workflowVersion integer
return ezcWorkflow
    public function loadByName($workflowName, $workflowVersion = 0)
    {
        if ($workflowVersion == 0) {
            // Load the latest version of the workflow definition by default.
            $workflowVersion = $this->getCurrentVersion($workflowName);
        }
        $filename = $this->getFilename($workflowName, $workflowVersion);
        // Load the document.
        $document = new DOMDocument();
        if (is_readable($filename)) {
            libxml_use_internal_errors(true);
            $loaded = @$document->load($filename);
            if ($loaded === false) {
                $message = '';
                foreach (libxml_get_errors() as $error) {
                    $message .= $error->message;
                }
                throw new ezcWorkflowDefinitionStorageException(sprintf('Could not load workflow "%s" (version %d) from "%s".%s', $workflowName, $workflowVersion, $filename, $message != '' ? "\n" . $message : ''));
            }
        } else {
            throw new ezcWorkflowDefinitionStorageException(sprintf('Could not read file "%s".', $filename));
        }
        return $this->loadFromDocument($document);
    }

Usage Example

示例#1
0
 public function testLoadWorkflowWithSubWorkflowAndVariablePassing()
 {
     $definition = new ezcWorkflowDefinitionStorageXml(dirname(dirname(dirname(__FILE__))) . '/Workflow/tests/data/');
     $workflow = $definition->loadByName('IncrementVariable');
     $this->definition->save($workflow);
     $this->setUpWorkflowWithSubWorkflowAndVariablePassing();
     $this->definition->save($this->workflow);
     $this->execution->workflow = $this->workflow;
     $this->execution->start();
     $this->assertEquals($this->readExpected('WorkflowWithSubWorkflowAndVariablePassing'), $this->readActual());
 }
All Usage Examples Of ezcWorkflowDefinitionStorageXml::loadByName