|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
/* |
|
|
4 |
* This file is part of the Symfony package. |
|
|
5 |
* |
|
|
6 |
* (c) Fabien Potencier <fabien@symfony.com> |
|
|
7 |
* |
|
|
8 |
* For the full copyright and license information, please view the LICENSE |
|
|
9 |
* file that was distributed with this source code. |
|
|
10 |
*/ |
|
|
11 |
|
|
|
12 |
namespace Symfony\Bundle\DoctrineBundle\Command\Proxy; |
|
|
13 |
|
|
|
14 |
use Symfony\Component\Console\Input\InputArgument; |
|
|
15 |
use Symfony\Component\Console\Input\InputOption; |
|
|
16 |
use Symfony\Component\Console\Input\InputInterface; |
|
|
17 |
use Symfony\Component\Console\Output\OutputInterface; |
|
|
18 |
use Symfony\Component\Console\Output\Output; |
|
|
19 |
use Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand; |
|
|
20 |
use Doctrine\ORM\Tools\Export\Driver\XmlExporter; |
|
|
21 |
use Doctrine\ORM\Tools\Export\Driver\YamlExporter; |
|
|
22 |
|
|
|
23 |
/** |
|
|
24 |
* Convert Doctrine ORM metadata mapping information between the various supported |
|
|
25 |
* formats. |
|
|
26 |
* |
|
|
27 |
* @author Fabien Potencier <fabien@symfony.com> |
|
|
28 |
* @author Jonathan H. Wage <jonwage@gmail.com> |
|
|
29 |
*/ |
|
|
30 |
class ConvertMappingDoctrineCommand extends ConvertMappingCommand |
|
|
31 |
{ |
|
|
32 |
protected function configure() |
|
|
33 |
{ |
|
|
34 |
parent::configure(); |
|
|
35 |
$this |
|
|
36 |
->setName('doctrine:mapping:convert') |
|
|
37 |
->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command') |
|
|
38 |
->setHelp(<<<EOT |
|
|
39 |
The <info>doctrine:mapping:convert</info> command converts mapping information |
|
|
40 |
between supported formats: |
|
|
41 |
|
|
|
42 |
<info>php app/console doctrine:mapping:convert xml /path/to/output</info> |
|
|
43 |
EOT |
|
|
44 |
); |
|
|
45 |
} |
|
|
46 |
|
|
|
47 |
protected function execute(InputInterface $input, OutputInterface $output) |
|
|
48 |
{ |
|
|
49 |
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em')); |
|
|
50 |
|
|
|
51 |
return parent::execute($input, $output); |
|
|
52 |
} |
|
|
53 |
|
|
|
54 |
|
|
|
55 |
protected function getExporter($toType, $destPath) |
|
|
56 |
{ |
|
|
57 |
$exporter = parent::getExporter($toType, $destPath); |
|
|
58 |
if ($exporter instanceof XmlExporter) { |
|
|
59 |
$exporter->setExtension('.orm.xml'); |
|
|
60 |
} elseif ($exporter instanceof YamlExporter) { |
|
|
61 |
$exporter->setExtension('.orm.yml'); |
|
|
62 |
} |
|
|
63 |
|
|
|
64 |
return $exporter; |
|
|
65 |
} |
|
|
66 |
} |