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
|
|
|
protected function configure() |
19
|
|
|
{ |
20
|
|
|
$this->setName('yuml:mappings') |
21
|
|
|
->setDescription('Generate an image from yuml.me of doctrine metadata') |
22
|
|
|
->addOption( |
23
|
|
|
'filename', |
24
|
|
|
'f', |
25
|
|
|
InputOption::VALUE_REQUIRED, |
26
|
|
|
'Output filename', |
27
|
|
|
'yuml-mapping.png' |
28
|
|
|
); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
32
|
|
|
{ |
33
|
|
|
/** @var YumlClient $yumlClient */ |
34
|
|
|
$yumlClient = $this->getContainer()->get('onurb_yuml.client'); |
35
|
|
|
$filename = $input->getOption('filename'); |
36
|
|
|
|
37
|
|
|
$showDetailParam = $this->getContainer()->getParameter('onurb_yuml.show_fields_description'); |
38
|
|
|
$colorsParam = $this->getContainer()->getParameter('onurb_yuml.colors'); |
39
|
|
|
$notesParam = $this->getContainer()->getParameter('onurb_yuml.notes'); |
40
|
|
|
|
41
|
|
|
$graphUrl = $yumlClient->getGraphUrl($yumlClient->makeDslText($showDetailParam, $colorsParam, $notesParam)); |
42
|
|
|
$yumlClient->downloadImage($graphUrl, $filename); |
43
|
|
|
|
44
|
|
|
$output->writeln(sprintf('Downloaded <info>%s</info> to <info>%s</info>', $graphUrl, $filename)); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|