1
|
|
|
<?php |
2
|
|
|
namespace Onurb\Bundle\YumlBundle\Command; |
3
|
|
|
|
4
|
|
|
use Onurb\Bundle\YumlBundle\Yuml\YumlClient; |
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
6
|
|
|
use Symfony\Component\Console\Input\InputOption; |
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
8
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Generate and save Yuml images for metadata graphs. |
12
|
|
|
* |
13
|
|
|
* @license MIT |
14
|
|
|
* @author Glynn Forrest <[email protected]> |
15
|
|
|
**/ |
16
|
|
|
class YumlCommand extends ContainerAwareCommand |
17
|
|
|
{ |
18
|
1 |
|
protected function configure() |
19
|
|
|
{ |
20
|
1 |
|
$this->setName('yuml:mappings') |
21
|
1 |
|
->setDescription('Generate an image from yuml.me of doctrine metadata') |
22
|
1 |
|
->addOption( |
23
|
1 |
|
'filename', |
24
|
1 |
|
'f', |
25
|
1 |
|
InputOption::VALUE_REQUIRED, |
26
|
1 |
|
'Output filename', |
27
|
1 |
|
'yuml-mapping.png' |
28
|
|
|
); |
29
|
1 |
|
} |
30
|
|
|
|
31
|
1 |
|
protected function execute(InputInterface $input, OutputInterface $output) |
32
|
|
|
{ |
33
|
|
|
/** @var YumlClient $yumlClient */ |
34
|
1 |
|
$yumlClient = $this->getContainer()->get('onurb_yuml.client'); |
35
|
1 |
|
$filename = $input->getOption('filename'); |
36
|
|
|
|
37
|
1 |
|
$showDetailParam = $this->getContainer()->getParameter('onurb_yuml.show_fields_description'); |
38
|
1 |
|
$colorsParam = $this->getContainer()->getParameter('onurb_yuml.colors'); |
39
|
1 |
|
$notesParam = $this->getContainer()->getParameter('onurb_yuml.notes'); |
40
|
1 |
|
$styleParam = $this->getContainer()->getParameter('onurb_yuml.style'); |
41
|
1 |
|
$extensionParam = $this->getContainer()->getParameter('onurb_yuml.extension'); |
42
|
1 |
|
$direction = $this->getContainer()->getParameter('onurb_yuml.direction'); |
43
|
1 |
|
$scale = $this->getContainer()->getParameter('onurb_yuml.scale'); |
44
|
|
|
|
45
|
1 |
|
$graphUrl = $yumlClient->getGraphUrl( |
46
|
1 |
|
$yumlClient->makeDslText($showDetailParam, $colorsParam, $notesParam), |
47
|
1 |
|
$styleParam, |
48
|
1 |
|
$extensionParam, |
49
|
1 |
|
$direction, |
50
|
1 |
|
$scale |
51
|
|
|
); |
52
|
1 |
|
$yumlClient->downloadImage($graphUrl, $filename); |
53
|
|
|
|
54
|
1 |
|
$output->writeln(sprintf('Downloaded <info>%s</info> to <info>%s</info>', $graphUrl, $filename)); |
55
|
1 |
|
} |
56
|
|
|
} |
57
|
|
|
|