Commit cb08244c authored by Guillaume Perréal's avatar Guillaume Perréal

irstea:plantuml:render -vv affiche la configuration utilisée.

parent 2e1b1619
......@@ -66,6 +66,12 @@ class RenderCommand extends ContainerAwareCommand
{
$io->writeln("Fichier de sortie: <comment>$target</comment>");
if (OutputInterface::VERBOSITY_VERY_VERBOSE <= $io->getVerbosity()) {
$desc = [];
$graph->toConfig($desc);
$io->writeln(json_encode($desc, JSON_PRETTY_PRINT));
}
$io->write("Exploration des classes: ");
$graph->visitAll();
$io->writeln("<info>Ok</info>.");
......
......@@ -81,4 +81,9 @@ class AssociationDecorator extends AbstractDoctrineDecorator
new BaseArrow($node, $target, "--", $association["fieldName"]." >", $linkSource, $linkTarget, $sourceCardinality, $targetCardinality)
);
}
public function toConfig(array &$conf)
{
$conf['decorators'][] = 'associations';
}
}
......@@ -15,6 +15,7 @@ namespace Irstea\PlantUmlBundle\Doctrine;
*/
class DoctrineNamespace extends \Irstea\PlantUmlBundle\Model\Namespace_\MappedNamespace
{
const CONF_TYPE = 'entities';
const SEPARATOR = '::';
public function __construct(\Doctrine\ORM\EntityManagerInterface $em)
......
......@@ -34,4 +34,9 @@ class EntityDecorator extends AbstractDoctrineDecorator
$class
);
}
public function toConfig(array &$conf)
{
$conf['decorators'][] = 'entity';
}
}
......@@ -36,4 +36,9 @@ class EntityFinder implements FinderInterface
}
return new ArrayIterator($classes);
}
public function toConfig(array &$conf)
{
$conf['type'] = 'entities';
}
}
......@@ -50,4 +50,9 @@ class FieldDecorator extends AbstractDoctrineDecorator
$isIdentifier
));
}
public function toConfig(array &$conf)
{
$conf['decorators'][] = 'fields';
}
}
......@@ -74,6 +74,12 @@ class ClassFinder implements FinderInterface
}
return new ArrayIterator($this->classes);
}
public function toConfig(array &$conf)
{
$conf['type'] = 'classes';
$conf['directories'] = $this->directories;
}
}
function irstea_plantmul_include($filepath)
......
......@@ -38,4 +38,10 @@ class FilteringFinder implements FinderInterface
{
return new CallbackFilterIterator($this->inner->getIterator(), [$this->filter, 'accept']);
}
public function toConfig(array &$conf)
{
$this->inner->toConfig($conf);
$this->filter->toConfig($conf);
}
}
......@@ -8,10 +8,14 @@
namespace Irstea\PlantUmlBundle\Finder;
use Irstea\PlantUmlBundle\Model\ToConfigInterface;
use IteratorAggregate;
use Traversable;
/**
*
* @author Guillaume Perréal <guillaume.perreal@irstea.fr>
*/
interface FinderInterface extends \Traversable, \IteratorAggregate
interface FinderInterface extends Traversable, IteratorAggregate, ToConfigInterface
{
}
......@@ -14,7 +14,7 @@ use ReflectionClass;
*
* @author Guillaume Perréal <guillaume.perreal@irstea.fr>
*/
interface ClassFilterInterface
interface ClassFilterInterface extends ToConfigInterface
{
/**
* @param ReflectionClass $class
......
......@@ -123,4 +123,17 @@ class ClassVisitor implements ClassVisitorInterface
{
return $this->rootNamespace->writeTo($writer);
}
/**
* @param array $conf
*/
public function toConfig(array &$conf)
{
$conf['layout'] = [];
$conf['decoration'] = [];
$this->filter->toConfig($conf['layout']);
$this->rootNamespace->toConfig($conf['layout']);
$this->decorator->toConfig($conf['decoration']);
}
}
......@@ -14,7 +14,7 @@ use Irstea\PlantUmlBundle\Writer\WritableInterface;
*
* @author Guillaume Perréal <guillaume.perreal@irstea.fr>
*/
interface ClassVisitorInterface extends WritableInterface
interface ClassVisitorInterface extends WritableInterface, ToConfigInterface
{
/**
* @param ReflectionClass|string
......
......@@ -44,4 +44,9 @@ class AttributeDecorator implements DecoratorInterface
);
}
}
public function toConfig(array &$conf)
{
$conf['decorators'][] = 'attributes';
}
}
......@@ -43,4 +43,11 @@ class CompositeDecorator implements DecoratorInterface
}
return $this;
}
public function toConfig(array &$conf)
{
foreach($this->decorators as $decorator) {
$decorator->toConfig($conf);
}
}
}
......@@ -48,4 +48,10 @@ class FilteringDecorator implements DecoratorInterface
}
return $this;
}
public function toConfig(array &$conf)
{
$this->filter->toConfig($conf);
$this->next->toConfig($conf);
}
}
......@@ -34,4 +34,9 @@ class InheritanceDecorator extends AbstractRelationDecorator
{
return new ExtendsClass($source, $target);
}
public function toConfig(array &$conf)
{
$conf['decorators'][] = 'inheritance';
}
}
......@@ -51,4 +51,9 @@ class InterfaceDecorator extends AbstractRelationDecorator
{
return new ImplementsInterface($source, $target);
}
public function toConfig(array &$conf)
{
$conf['decorators'][] = 'interfaces';
}
}
......@@ -68,4 +68,9 @@ class MethodDecorator implements DecoratorInterface
$property = $class->getProperty($name);
return $property->isStatic() == $method->isStatic();
}
public function toConfig(array &$conf)
{
$conf['decorators'][] = 'methods';
}
}
......@@ -26,4 +26,8 @@ class NullDecorator implements DecoratorInterface
{
return $this;
}
public function toConfig(array &$conf)
{
}
}
......@@ -39,4 +39,9 @@ class TraitDecorator extends AbstractRelationDecorator
{
return new UsesTrait($source, $target);
}
public function toConfig(array &$conf)
{
$conf['decorators'][] = 'traits';
}
}
......@@ -14,7 +14,12 @@ use ReflectionClass;
*
* @author Guillaume Perréal <guillaume.perreal@irstea.fr>
*/
interface DecoratorInterface
interface DecoratorInterface extends ToConfigInterface
{
/**
* @param ReflectionClass $class
* @param NodeInterface $node
* @param ClassVisitorInterface $visitor
*/
public function decorate(ReflectionClass $class, NodeInterface $node, ClassVisitorInterface $visitor);
}
......@@ -45,6 +45,15 @@ abstract class AbstractListFilter implements ClassFilterInterface
return $this->notFound;
}
public function toConfig(array &$conf)
{
$key = $this->notFound ? 'exclude' : 'include';
if (!array_key_exists($key, $conf)) {
$conf[$key] = [];
}
$conf[$key][static::CONF_TYPE] = $this->allowed;
}
/**
* @param string $value
* @return string
......
......@@ -24,4 +24,8 @@ class AcceptAllFilter implements ClassFilterInterface
{
return true;
}
public function toConfig(array &$conf)
{
}
}
......@@ -17,6 +17,8 @@ use ReflectionClass;
*/
class ClassFilter extends AbstractListFilter
{
const CONF_TYPE = 'classes';
protected function extract(ReflectionClass $class)
{
return $class->getName();
......
......@@ -27,4 +27,11 @@ abstract class AbstractCompositeFilter implements ClassFilterInterface
{
$this->filters = $filters;
}
public function toConfig(array &$conf)
{
foreach($this->filters as $filter) {
$filter->toConfig($conf);
}
}
}
......@@ -17,6 +17,8 @@ use ReflectionClass;
*/
class DirectoryFilter extends AbstractListFilter
{
const CONF_TYPE = 'directories';
protected function extract(ReflectionClass $class)
{
return dirname($class->getFileName());
......
......@@ -17,6 +17,8 @@ use ReflectionClass;
*/
class NamespaceFilter extends AbstractListFilter
{
const CONF_TYPE = 'namespaces';
protected function extract(ReflectionClass $class)
{
return $class->getNamespaceName();
......
......@@ -48,4 +48,14 @@ class Graph implements GraphInterface
$writer->write("@enduml@\n");
return $this;
}
/**
* @param array $conf
*/
public function toConfig(array &$conf)
{
$conf['sources'] = [];
$this->finder->toConfig($conf['sources']);
$this->visitor->toConfig($conf);
}
}
......@@ -14,7 +14,7 @@ use Irstea\PlantUmlBundle\Writer\WritableInterface;
*
* @author Guillaume Perréal <guillaume.perreal@irstea.fr>
*/
interface GraphInterface extends WritableInterface
interface GraphInterface extends WritableInterface, ToConfigInterface
{
/**
* @return void
......
......@@ -14,7 +14,7 @@ use Irstea\PlantUmlBundle\Writer\WritableInterface;
*
* @author Guillaume Perréal <guillaume.perreal@irstea.fr>
*/
interface NamespaceInterface extends WritableInterface
interface NamespaceInterface extends WritableInterface, ToConfigInterface
{
/**
* @param string $namespaceName
......
......@@ -54,4 +54,9 @@ abstract class AbstractNamespace implements WritableInterface, NamespaceInterfac
{
return empty($this->nodes);
}
public function toConfig(array &$conf)
{
$conf['namespace'] = static::CONF_TYPE;
}
}
......@@ -15,6 +15,7 @@ namespace Irstea\PlantUmlBundle\Model\Namespace_;
*/
class BundleNamespace extends MappedNamespace
{
const CONF_TYPE = 'bundles';
const SEPARATOR = '::';
public function __construct(array $bundles)
......
......@@ -18,6 +18,7 @@ use Irstea\PlantUmlBundle\Writer\WriterInterface;
*/
class FlatNamespace extends AbstractNamespace
{
const CONF_TYPE = 'flat';
const SEPARATOR = 'none';
/**
......
......@@ -18,6 +18,8 @@ use Irstea\PlantUmlBundle\Writer\WriterInterface;
*/
class RootNamespace extends AbstractNamespace
{
const CONF_TYPE = 'php';
/**
* @var ArrowInterface[]
*/
......
<?php
/*
* © 2016 IRSTEA
* Guillaume Perréal <guillaume.perreal@irstea.fr>
* Tous droits réservés.
*/
namespace Irstea\PlantUmlBundle\Model;
/**
*
* @author Guillaume Perréal <guillaume.perreal@irstea.fr>
*/
interface ToConfigInterface
{
/**
* @param array $conf
*/
public function toConfig(array &$conf);
}
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