Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Pôle IS
Bundles Symfony 2
plantuml-bundle
Commits
07decdd8
Commit
07decdd8
authored
May 13, 2016
by
Guillaume Perréal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Amélioration du modèle BaseArraow
Gère explicitement les cardinalités et terminaisons de lien.
parent
1f48e47d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
78 additions
and
140 deletions
+78
-140
Doctrine/AssociationDecorator.php
Doctrine/AssociationDecorator.php
+14
-14
Factory/FilterFactory.php
Factory/FilterFactory.php
+0
-117
Model/Arrow/BaseArrow.php
Model/Arrow/BaseArrow.php
+61
-6
Model/Arrow/ExtendsClass.php
Model/Arrow/ExtendsClass.php
+1
-1
Model/Arrow/ImplementsInterface.php
Model/Arrow/ImplementsInterface.php
+1
-1
Model/Arrow/UsesTrait.php
Model/Arrow/UsesTrait.php
+1
-1
No files found.
Doctrine/AssociationDecorator.php
View file @
07decdd8
...
...
@@ -50,35 +50,35 @@ class AssociationDecorator extends AbstractDoctrineDecorator
return
;
}
$link
=
"->"
;
$linkSource
=
''
;
$linkTarget
=
">"
;
if
(
$association
[
"isCascadeRemove"
])
{
$link
=
"o"
.
$link
;
$link
Source
=
"o"
;
}
$
leftLabel
=
""
;
$
rightLabel
=
""
;
$
sourceCardinality
=
""
;
$
targetCardinality
=
""
;
switch
(
$association
[
"type"
])
{
case
ClassMetadata
::
ONE_TO_ONE
:
$
leftLabel
=
'1'
;
$
rightLabel
=
'1'
;
$
sourceCardinality
=
'1'
;
$
targetCardinality
=
'1'
;
break
;
case
ClassMetadata
::
ONE_TO_MANY
:
$
leftLabel
=
'1'
;
$
rightLabel
=
'*'
;
$
sourceCardinality
=
'1'
;
$
targetCardinality
=
'*'
;
break
;
case
ClassMetadata
::
MANY_TO_MANY
:
$
leftLabel
=
'*'
;
$
rightLabel
=
'*'
;
$
sourceCardinality
=
'*'
;
$
targetCardinality
=
'*'
;
break
;
case
ClassMetadata
::
MANY_TO_ONE
:
$
leftLabel
=
'*'
;
$
rightLabel
=
'1'
;
$
sourceCardinality
=
'*'
;
$
targetCardinality
=
'1'
;
break
;
}
$link
=
sprintf
(
'"%s" %s "%s"'
,
$leftLabel
,
$link
,
$rightLabel
);
$node
->
addArrow
(
new
BaseArrow
(
$node
,
$target
,
$link
,
$association
[
"fieldName"
]
.
" >"
)
new
BaseArrow
(
$node
,
$target
,
"--"
,
$association
[
"fieldName"
]
.
" >"
,
$linkSource
,
$linkTarget
,
$sourceCardinality
,
$targetCardinality
)
);
}
}
Factory/FilterFactory.php
deleted
100644 → 0
View file @
1f48e47d
<?php
/*
* © 2016 IRSTEA
* Guillaume Perréal <guillaume.perreal@irstea.fr>
* Tous droits réservés.
*/
namespace
Irstea\PlantUmlBundle\Factory
;
use
Irstea\PlantUmlBundle\Model\ClassFilterInterface
;
use
Irstea\PlantUmlBundle\Model\Filter\AcceptAllFilter
;
use
Irstea\PlantUmlBundle\Model\Filter\ClassFilter
;
use
Irstea\PlantUmlBundle\Model\Filter\Composite\AllFilter
;
use
Irstea\PlantUmlBundle\Model\Filter\DirectoryFilter
;
use
Irstea\PlantUmlBundle\Model\Filter\NamespaceFilter
;
use
Symfony\Component\HttpKernel\KernelInterface
;
/**
* Description of FilterFactory
*
* @author Guillaume Perréal <guillaume.perreal@irstea.fr>
*/
class
FilterFactory
{
/**
* @var KernelInterface
*/
private
$kernel
;
public
function
__construct
(
KernelInterface
$kernel
)
{
$this
->
kernel
=
$kernel
;
}
/**
* @param array $include
* @param array $exclude
* @return ClassFilterInterface
*/
public
function
create
(
$include
=
[],
$exclude
=
[])
{
$filters
=
[];
if
(
!
empty
(
$include
))
{
$this
->
appendFilters
(
$filters
,
$include
,
false
);
}
if
(
!
empty
(
$exclude
))
{
$this
->
appendFilters
(
$filters
,
$exclude
,
true
);
}
switch
(
count
(
$filters
))
{
case
0
:
$filter
=
AcceptAllFilter
::
instance
();
break
;
case
1
:
$filter
=
$filters
[
0
];
break
;
default
:
$filter
=
new
AllFilter
(
$filters
);
}
return
$filter
;
}
protected
function
appendFilters
(
array
&
$filters
,
array
$config
,
$notFound
)
{
if
(
!
empty
(
$config
[
'directories'
]))
{
$paths
=
$this
->
expandBundlePaths
(
$config
[
'directories'
]);
$filters
[]
=
new
DirectoryFilter
(
$paths
,
$notFound
);
}
if
(
!
empty
(
$config
[
'namespaces'
]))
{
$namespaces
=
$this
->
expandBundleNamespaces
(
$config
[
'namespaces'
]);
$filters
[]
=
new
NamespaceFilter
(
$namespaces
,
$notFound
);
}
if
(
!
empty
(
$config
[
'classes'
]))
{
$classes
=
$this
->
expandBundleNamespaces
(
$config
[
'classes'
]);
$filters
[]
=
new
ClassFilter
(
$classes
,
$notFound
);
}
}
/**
* @param array $paths
* @return array
*/
protected
function
expandBundlePaths
(
array
$paths
)
{
$actualPaths
=
[];
foreach
(
$paths
as
$path
)
{
if
(
preg_match
(
'/^@(\w+)(.*)$/'
,
$path
,
$groups
))
{
$bundle
=
$this
->
kernel
->
getBundle
(
$groups
[
1
]);
$path
=
$bundle
->
getPath
()
.
$groups
[
2
];
}
$actualPaths
[]
=
realpath
(
$path
);
}
return
$actualPaths
;
}
/**
* @param array $paths
* @return array
*/
protected
function
expandBundleNamespaces
(
array
$names
)
{
$actualNames
=
[];
foreach
(
$names
as
$name
)
{
if
(
preg_match
(
'/^@(\w+)(.*)$/'
,
$name
,
$groups
))
{
$bundle
=
$this
->
kernel
->
getBundle
(
$groups
[
1
]);
$name
=
$bundle
->
getNamespace
()
.
$groups
[
2
];
}
$actualNames
[]
=
$name
;
}
return
$actualNames
;
}
}
Model/Arrow/BaseArrow.php
View file @
07decdd8
...
...
@@ -34,12 +34,49 @@ class BaseArrow implements ArrowInterface
*/
private
$link
;
public
function
__construct
(
NodeInterface
$source
,
NodeInterface
$target
,
$link
=
"--"
,
$label
=
null
)
{
/**
* @var string
*/
private
$linkSource
;
/**
* @var string
*/
private
$linkTarget
;
/**
* @var string
*/
private
$sourceCardinality
;
/**
* @var string
*/
private
$targetCardinality
;
/**
* @var int
*/
static
private
$splitCount
=
0
;
public
function
__construct
(
NodeInterface
$source
,
NodeInterface
$target
,
$link
=
"--"
,
$label
=
null
,
$linkSource
=
''
,
$linkTarget
=
''
,
$sourceCardinality
=
''
,
$targetCardinality
=
''
)
{
$this
->
source
=
$source
;
$this
->
target
=
$target
;
$this
->
link
=
$link
;
$this
->
label
=
$label
;
$this
->
link
=
$link
;
$this
->
label
=
$label
;
$this
->
linkSource
=
$linkSource
;
$this
->
linkTarget
=
$linkTarget
;
$this
->
sourceCardinality
=
$sourceCardinality
;
$this
->
targetCardinality
=
$targetCardinality
;
}
public
function
writeTo
(
WriterInterface
$writer
)
...
...
@@ -60,9 +97,27 @@ class BaseArrow implements ArrowInterface
return
$this
;
}
protected
function
writeLinkTo
(
WriterInterface
$writer
)
protected
function
writeLinkTo
(
WriterInterface
$writer
,
$linkSource
=
null
,
$linkTarget
=
null
)
{
$writer
->
writeFormatted
(
" %s "
,
$this
->
link
);
$this
->
writeSourceCardinalityTo
(
$writer
);
$writer
->
writeFormatted
(
" %s%s%s "
,
$linkSource
?:
$this
->
linkSource
,
$this
->
link
,
$linkTarget
?:
$this
->
linkTarget
);
$this
->
writeTargetCardinalityTo
(
$writer
);
return
$this
;
}
protected
function
writeSourceCardinalityTo
(
WriterInterface
$writer
)
{
if
(
$this
->
sourceCardinality
!==
''
)
{
$writer
->
writeFormatted
(
' "%s"'
,
$this
->
sourceCardinality
);
}
return
$this
;
}
protected
function
writeTargetCardinalityTo
(
WriterInterface
$writer
)
{
if
(
$this
->
targetCardinality
!==
''
)
{
$writer
->
writeFormatted
(
'"%s" '
,
$this
->
targetCardinality
);
}
return
$this
;
}
}
Model/Arrow/ExtendsClass.php
View file @
07decdd8
...
...
@@ -19,6 +19,6 @@ class ExtendsClass extends BaseArrow
{
public
function
__construct
(
WritableNodeInterface
$source
,
WritableNodeInterface
$target
)
{
parent
::
__construct
(
$target
,
$source
,
"
<|
--"
);
parent
::
__construct
(
$target
,
$source
,
"--
"
,
null
,
"<|
"
);
}
}
Model/Arrow/ImplementsInterface.php
View file @
07decdd8
...
...
@@ -20,6 +20,6 @@ class ImplementsInterface extends BaseArrow
{
public
function
__construct
(
WritableNodeInterface
$source
,
Interface_
$target
)
{
parent
::
__construct
(
$target
,
$source
,
"
<|
.."
);
parent
::
__construct
(
$target
,
$source
,
"..
"
,
null
,
"<|
"
);
}
}
Model/Arrow/UsesTrait.php
View file @
07decdd8
...
...
@@ -20,6 +20,6 @@ class UsesTrait extends BaseArrow
{
public
function
__construct
(
WritableNodeInterface
$source
,
Trait_
$trait
)
{
parent
::
__construct
(
$trait
,
$source
,
"
<|
--"
);
parent
::
__construct
(
$trait
,
$source
,
"--
"
,
null
,
"<|
"
);
}
}
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