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
6b09c22c
Commit
6b09c22c
authored
Jul 04, 2019
by
Guillaume Perréal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Léger refactoring de la RenderCommand.
parent
ba187cf5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
27 deletions
+88
-27
src/Command/RenderCommand.php
src/Command/RenderCommand.php
+80
-27
src/Resources/config/services.yml
src/Resources/config/services.yml
+8
-0
No files found.
src/Command/RenderCommand.php
View file @
6b09c22c
...
...
@@ -22,7 +22,8 @@ namespace Irstea\PlantUmlBundle\Command;
use
Irstea\PlantUmlBundle\Model\Graph
;
use
Irstea\PlantUmlBundle\Writer\StreamWriter
;
use
Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand
;
use
Psr\Container\ContainerInterface
;
use
Symfony\Component\Console\Command\Command
;
use
Symfony\Component\Console\Input\InputArgument
;
use
Symfony\Component\Console\Input\InputInterface
;
use
Symfony\Component\Console\Input\InputOption
;
...
...
@@ -34,12 +35,76 @@ use Symfony\Component\Process\ExecutableFinder;
/**
* Description of ImportAffiliationCommand.
*/
class
RenderCommand
extends
ContainerAware
Command
class
RenderCommand
extends
Command
{
protected
function
configure
()
/**
* @var string
*/
private
const
CMD_NAME
=
'irstea:plantuml:render'
;
/**
* @var ContainerInterface
*/
private
$container
;
/**
* @var string[]
*/
private
$graphNames
;
/**
* @var string
*/
private
$defaultFormat
;
/**
* @var string
*/
private
$defaultOutput
;
/**
* @var string
*/
private
$javaBinary
;
/**
* @var string
*/
private
$plantUmlJar
;
/**
* @var string
*/
private
$dotBinary
;
/**
* RenderCommand constructor.
* @param ContainerInterface $container
* @param array $graphNames
* @param string $defaultFormat
* @param string $defaultOutput
* @param string $javaBinary
* @param string $plantUmlJar
* @param string $dotBinary
*/
public
function
__construct
(
ContainerInterface
$container
,
array
$graphNames
,
string
$defaultFormat
,
string
$defaultOutput
,
string
$javaBinary
,
string
$plantUmlJar
,
string
$dotBinary
)
{
parent
::
__construct
(
self
::
CMD_NAME
);
$this
->
container
=
$container
;
$this
->
graphNames
=
$graphNames
;
$this
->
defaultFormat
=
$defaultFormat
;
$this
->
defaultOutput
=
$defaultOutput
;
$this
->
javaBinary
=
$javaBinary
;
$this
->
plantUmlJar
=
$plantUmlJar
;
$this
->
dotBinary
=
$dotBinary
;
}
/**
* {@inheritDoc}
*/
protected
function
configure
():
void
{
$this
->
setName
(
'irstea:plantuml:render'
)
->
setName
(
self
::
CMD_NAME
)
->
setDescription
(
"Créer la page d'un graphe ou plusieurs graphes."
)
->
addOption
(
'output'
,
'o'
,
InputOption
::
VALUE_REQUIRED
,
'Répertoire de destination.'
)
->
addOption
(
'format'
,
'f'
,
InputOption
::
VALUE_REQUIRED
,
'Format du fichier à générer'
)
...
...
@@ -47,15 +112,13 @@ class RenderCommand extends ContainerAwareCommand
}
/**
* @param InputInterface $input
* @param OutputInterface $output
* @SuppressWarnings(UnusedFormalParameter)
* {@inheritDoc}
*/
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
)
{
$graphs
=
$input
->
getArgument
(
'graph'
)
?:
$this
->
g
etContainer
()
->
getParameter
(
'irstea_plant_uml.graph_keys'
)
;
$format
=
$input
->
getOption
(
'format'
)
?:
$this
->
getContainer
()
->
getParameter
(
'irstea_plant_uml.output.f
ormat
'
)
;
$outputDir
=
$input
->
getOption
(
'output'
)
?:
$this
->
getContainer
()
->
getParameter
(
'irstea_plant_uml.output.directory'
)
;
$graphs
=
$input
->
getArgument
(
'graph'
)
?:
$this
->
g
raphNames
;
$format
=
$input
->
getOption
(
'format'
)
?:
$this
->
defaultF
ormat
;
$outputDir
=
$input
->
getOption
(
'output'
)
?:
$this
->
defaultOutput
;
$io
=
new
SymfonyStyle
(
$input
,
$output
);
...
...
@@ -64,7 +127,7 @@ class RenderCommand extends ContainerAwareCommand
$io
->
section
(
"Graphe:
$name
"
);
$graph
=
$this
->
getC
ontainer
()
->
get
(
"irstea_plant_uml.graph.
$name
"
);
$graph
=
$this
->
c
ontainer
->
get
(
"irstea_plant_uml.graph.
$name
"
);
$this
->
renderGraph
(
$graph
,
$target
,
$format
,
$io
);
}
...
...
@@ -117,26 +180,16 @@ class RenderCommand extends ContainerAwareCommand
*/
private
function
startProcess
(
$target
,
$format
):
array
{
$ctn
=
$this
->
getContainer
();
$javaBin
=
$this
->
findExecutable
(
$ctn
->
getParameter
(
'irstea_plant_uml.binaries.java'
));
$dotBin
=
$this
->
findExecutable
(
$ctn
->
getParameter
(
'irstea_plant_uml.binaries.dot'
));
$cmd
=
sprintf
(
'%s -jar %s -graphvizdot %s -pipe -t %s'
,
$this
->
findExecutable
(
$this
->
javaBinary
),
$this
->
plantUmlJar
,
$this
->
findExecutable
(
$this
->
dotBinary
),
$format
);
$fs
=
new
Filesystem
();
$fs
->
mkdir
(
dirname
(
$target
));
$cmd
=
implode
(
' '
,
[
$javaBin
,
'-jar'
,
$ctn
->
getParameter
(
'irstea_plant_uml.binaries.plamtuml_jar'
),
'-graphvizdot'
,
$dotBin
,
'-pipe'
,
'-t'
.
$format
,
]
);
$desc
=
[
// stdin
[
'pipe'
,
'r'
],
...
...
src/Resources/config/services.yml
View file @
6b09c22c
...
...
@@ -88,6 +88,14 @@ services:
class
:
Irstea\PlantUmlBundle\Command\RenderCommand
lazy
:
true
public
:
false
arguments
:
-
'
@service_container'
-
'
%irstea_plant_uml.graph_keys%'
-
'
%irstea_plant_uml.output.format%'
-
'
%irstea_plant_uml.output.directory%'
-
'
%irstea_plant_uml.binaries.java%'
-
'
%irstea_plant_uml.binaries.plamtuml_jar%'
-
'
%irstea_plant_uml.binaries.dot%'
tags
:
-
{
name
:
console.command
}
...
...
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