raoul2000\workflow\source\file\GraphmlLoader::convert PHP Method

convert() public method

Convert a graphml file describing a workflow into an array suitable to create a workflow object.
public convert ( string $graphmlFile )
$graphmlFile string the path to the graphml file to process
    public function convert($graphmlFile)
    {
        $this->_dom = new \DOMDocument();
        $this->_dom->load($graphmlFile);
        $this->_xp = new \DOMXPath($this->_dom);
        $this->_xp->registerNamespace('ns', 'http://graphml.graphdrawing.org/xmlns');
        $this->_xp->registerNamespace('y', 'http://www.yworks.com/xml/graphml');
        $this->extractYedProperties();
        if (!isset($this->_yedProperties['w-intial-node-id'])) {
            throw new WorkflowException("Missing custom workflow property : 'initialStatusId'");
        }
        $workflow = $this->collectWorkflowProperties();
        $nodes = $this->collectNodes();
        $edges = $this->collectTransitions();
        //return ['nodes'=> $nodes, 'edges' => $edges];
        return $this->createWorkflowDefinition($workflow, $nodes, $edges);
    }

Usage Example

 public function testParseFail4()
 {
     $this->specify('convertion fails when more then one workflow (graph) is defined', function () {
         $this->setExpectedException('raoul2000\\workflow\\base\\WorkflowException', "more than one workflow found");
         $l = new GraphmlLoader();
         $filename = Yii::getAlias('@tests/codeception/unit/models/workflow-04.graphml');
         $l->convert($filename);
     });
 }