array(50, 50), self::TYPE_STARTEVENT => array(36, 36), self::TYPE_TASK => array(100, 80), ); /** * @var Element */ private $parent = null; private $maxChildCount = 1; public function __construct($id, $name, $type) { $this->id = $id; $this->name = $name; $this->type = $type; } public function getChildCount() { $all = Flow::getAll(); $currentMax = 1; if(empty($this->outgoing)) { return 0; } foreach($this->outgoing as $outgoing) { $tmpChildCount = $outgoing->getChildCount(); if($tmpChildCount > $currentMax) { $currentMax = $tmpChildCount; } } return $childCount; } /* public function updateChilds() { if($this->maxChildCount < $childCount) { $this->maxChildCount = $childCount; if($this->parent !== null) { $this->parent->adjustMaxChild($childCount); } } } */ public function setParent(Element &$parent) { $this->parent = &$parent; } public function addOutgoing($childObj) { $this->outgoing[] = $childObj; } public function addIncoming($childObj) { $this->incoming[] = $childObj; } public function addChild(Element $child) { $child->setParent($this); $child->addIncoming($this); $this->addOutgoing($child); } public function getId() { return $this->id; } public function getName() { return $this->id; } /** * @param $xml \DOMDocument */ public function addXML($xml) { $process = $xml->getElementsByTagName('bpmn:process')[0]; $block = $xml->createElement('bpmn:'.$this->type); $block->setAttribute('id', $this->getId()); $block->setAttribute('name',$this->getName()); $process->appendChild($block); foreach($this->incoming as $incoming) { $flow = $xml->createElement('bpmn:incoming', Flow::getId($incoming->getId(), $this->id)); $block->appendChild($flow); } foreach($this->outgoing as $outgoing) { $flow = $xml->createElement('bpmn:outgoing', Flow::getId($this->id, $outgoing->getId())); $block->appendChild($flow); } } }