Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pôle IS
Bundles Symfony 2
plantuml-bundle
Commits
762ddf49
Commit
762ddf49
authored
Mar 11, 2016
by
Guillaume Perréal
Browse files
Première version du support des attributs et des méthodes.
parent
bd67bea6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Command/GenerateCommand.php
View file @
762ddf49
...
...
@@ -17,10 +17,12 @@ use Irstea\PlantUmlBundle\Finder\FilteringFinder;
use
Irstea\PlantUmlBundle\Finder\FinderInterface
;
use
Irstea\PlantUmlBundle\Model\ClassFilterInterface
;
use
Irstea\PlantUmlBundle\Model\ClassVisitor
;
use
Irstea\PlantUmlBundle\Model\Decorator\AttributeDecorator
;
use
Irstea\PlantUmlBundle\Model\Decorator\CompositeDecorator
;
use
Irstea\PlantUmlBundle\Model\Decorator\FilteringDecorator
;
use
Irstea\PlantUmlBundle\Model\Decorator\InheritanceDecorator
;
use
Irstea\PlantUmlBundle\Model\Decorator\InterfaceDecorator
;
use
Irstea\PlantUmlBundle\Model\Decorator\MethodDecorator
;
use
Irstea\PlantUmlBundle\Model\Decorator\NullDecorator
;
use
Irstea\PlantUmlBundle\Model\Decorator\TraitDecorator
;
use
Irstea\PlantUmlBundle\Model\DecoratorInterface
;
...
...
@@ -205,12 +207,18 @@ class GenerateCommand extends ContainerAwareCommand
return
new
InterfaceDecorator
();
case
'traits'
:
return
new
TraitDecorator
();
case
'attributes'
:
return
new
AttributeDecorator
();
case
'methods'
:
return
new
MethodDecorator
();
case
'entity'
:
return
new
EntityDecorator
(
$this
->
entityManager
->
getMetadataFactory
());
case
'associations'
:
return
new
AssociationDecorator
(
$this
->
entityManager
->
getMetadataFactory
());
case
'fields'
:
return
new
FieldDecorator
(
$this
->
entityManager
->
getMetadataFactory
());
default
:
return
NullDecorator
::
instance
();
}
}
...
...
DependencyInjection/Configuration.php
View file @
762ddf49
...
...
@@ -48,6 +48,8 @@ class Configuration implements ConfigurationInterface
{
$node
=
(
new
TreeBuilder
())
->
root
(
'graphs'
);
$decorators
=
[
'inheritance'
,
'traits'
,
'interfaces'
,
'entity'
,
'associations'
,
'properties'
,
'methods'
,
'fields'
,
'attributes'
];
$node
->
useAttributeAsKey
(
'name'
)
->
prototype
(
'array'
)
...
...
@@ -85,9 +87,9 @@ class Configuration implements ConfigurationInterface
->
addDefaultsIfNotSet
()
->
children
()
->
arrayNode
(
'decorators'
)
->
defaultValue
(
[
'inheritance'
,
'traits'
,
'interfaces'
,
'entity'
,
'associations'
,
'properties'
,
'methods'
,
'fields'
]
)
->
defaultValue
(
$decorators
)
->
prototype
(
'enum'
)
->
values
(
[
'inheritance'
,
'traits'
,
'interfaces'
,
'entity'
,
'associations'
,
'properties'
,
'methods'
,
'fields'
]
)
->
values
(
$decorators
)
->
end
()
->
end
()
->
append
(
$this
->
buildFilterNode
(
'include'
))
...
...
Model/Decorator/AttributeDecorator.php
0 → 100644
View file @
762ddf49
<?php
/*
* © 2016 IRSTEA
* Guillaume Perréal <guillaume.perreal@irstea.fr>
* Tous droits réservés.
*/
namespace
Irstea\PlantUmlBundle\Model\Decorator
;
use
Irstea\PlantUmlBundle\Model\ClassVisitorInterface
;
use
Irstea\PlantUmlBundle\Model\DecoratorInterface
;
use
Irstea\PlantUmlBundle\Model\Node\Member\Member
;
use
Irstea\PlantUmlBundle\Model\Node\Member\MemberInterface
;
use
Irstea\PlantUmlBundle\Model\NodeInterface
;
use
ReflectionClass
;
use
ReflectionProperty
;
/**
* Description of AttributeDecorator
*
* @author Guillaume Perréal <guillaume.perreal@irstea.fr>
*/
class
AttributeDecorator
implements
DecoratorInterface
{
public
function
decorate
(
ReflectionClass
$class
,
NodeInterface
$node
,
ClassVisitorInterface
$visitor
)
{
foreach
(
$class
->
getProperties
()
as
$property
)
{
/* @var $property ReflectionProperty */
$node
->
addAttribute
(
new
Member
(
$property
->
getName
(),
false
,
$property
->
isPrivate
()
?
MemberInterface
::
PRIVATE_
:
$property
->
isProtected
()
?
MemberInterface
::
PROTECTED_
:
$property
->
isPublic
()
?
MemberInterface
::
PUBLIC_
:
MemberInterface
::
UNKNOWN
)
);
}
}
}
Model/Decorator/MethodDecorator.php
0 → 100644
View file @
762ddf49
<?php
/*
* © 2016 IRSTEA
* Guillaume Perréal <guillaume.perreal@irstea.fr>
* Tous droits réservés.
*/
namespace
Irstea\PlantUmlBundle\Model\Decorator
;
use
Irstea\PlantUmlBundle\Model\ClassVisitorInterface
;
use
Irstea\PlantUmlBundle\Model\DecoratorInterface
;
use
Irstea\PlantUmlBundle\Model\Node\Member\Member
;
use
Irstea\PlantUmlBundle\Model\Node\Member\MemberInterface
;
use
Irstea\PlantUmlBundle\Model\NodeInterface
;
use
ReflectionClass
;
use
ReflectionMethod
;
/**
* Description of AttributeDecorator
*
* @author Guillaume Perréal <guillaume.perreal@irstea.fr>
*/
class
MethodDecorator
implements
DecoratorInterface
{
public
function
decorate
(
ReflectionClass
$class
,
NodeInterface
$node
,
ClassVisitorInterface
$visitor
)
{
foreach
(
$class
->
getMethods
()
as
$method
)
{
/* @var $method ReflectionMethod */
if
(
$method
->
getDeclaringClass
()
!=
$class
)
{
continue
;
}
$node
->
addMethod
(
new
Member
(
$method
->
getName
()
.
'(...)'
,
''
,
$method
->
isPrivate
()
?
MemberInterface
::
PRIVATE_
:
(
$method
->
isProtected
()
?
MemberInterface
::
PROTECTED_
:
(
$method
->
isPublic
()
?
MemberInterface
::
PUBLIC_
:
MemberInterface
::
UNKNOWN
))
)
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment