Commit 8e3d291b authored by Guillaume Perréal's avatar Guillaume Perréal
Browse files

Trie les noeuds par type.

parent e5959457
......@@ -122,9 +122,11 @@ class ClassVisitor implements ClassVisitorInterface, UmlComponentInterface
{
$this->outputNamespacesTo($stream, $this->namespaces);
usort($this->nodes, 'Irstea\PlantUmlBundle\Model\Node\BaseNode::compare');
foreach ($this->nodes as $node) {
$node->outputTo($stream);
}
foreach ($this->arrows as $arrow) {
$arrow->outputTo($stream);
}
......
......@@ -37,18 +37,24 @@ class BaseNode implements UmlNodeInterface
*/
private $stereotypes;
/**
* @var int
*/
private $ordering;
/**
* @param string $name
* @param string $nodeType
* @param array $classifiers
* @param array $stereotypes
*/
function __construct($name, $nodeType, array $classifiers = [], array $stereotypes = [])
function __construct($name, $nodeType, array $classifiers = [], array $stereotypes = [], $ordering = 0)
{
$this->name = $name;
$this->nodeType = $nodeType;
$this->classifiers = $classifiers;
$this->stereotypes = $stereotypes;
$this->ordering = $ordering;
}
public function outputTo($stream)
......@@ -96,4 +102,12 @@ class BaseNode implements UmlNodeInterface
{
// NOP
}
static public function compare(BaseNode $a, BaseNode $b)
{
if ($a->ordering === $b->ordering) {
return strcmp($a->name, $b->name);
}
return $a->ordering - $b->ordering;
}
}
......@@ -23,6 +23,6 @@ class Class_ extends BaseNode
} elseif ($isFinal) {
$classifiers[] = 'final';
}
parent::__construct($name, "class", $classifiers);
parent::__construct($name, "class", $classifiers, [], $isAbstract ? 0 : ($isFinal ? 20 : 10));
}
}
......@@ -17,6 +17,6 @@ class Interface_ extends BaseNode
{
public function __construct($name)
{
parent::__construct($name, 'interface', [], ['interface']);
parent::__construct($name, 'interface', [], [], -20);
}
}
......@@ -17,6 +17,6 @@ class Trait_ extends BaseNode
{
public function __construct($name)
{
parent::__construct($name, 'class', [], ['trait']);
parent::__construct($name, 'class', [], ['trait'], -10);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment