ConvertMappingDoctrineCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Doctrine Bundle
5
 *
6
 * The code was originally distributed inside the Symfony framework.
7
 *
8
 * (c) Fabien Potencier <[email protected]>
9
 * (c) Doctrine Project, Benjamin Eberlei <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace Saxulum\DoctrineOrmCommands\Command\Proxy;
16
17
use Symfony\Component\Console\Input\InputOption;
18
use Symfony\Component\Console\Input\InputInterface;
19
use Symfony\Component\Console\Output\OutputInterface;
20
use Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand;
21
use Doctrine\ORM\Tools\Export\Driver\XmlExporter;
22
use Doctrine\ORM\Tools\Export\Driver\YamlExporter;
23
24
/**
25
 * Convert Doctrine ORM metadata mapping information between the various supported
26
 * formats.
27
 *
28
 * @author Fabien Potencier <[email protected]>
29
 * @author Jonathan H. Wage <[email protected]>
30
 */
31
class ConvertMappingDoctrineCommand extends ConvertMappingCommand
32
{
33
    /**
34
     * {@inheritDoc}
35
     */
36
    protected function configure()
37
    {
38
        parent::configure();
39
        $this
40
            ->setName('doctrine:mapping:convert')
41
            ->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command');
42
    }
43
44
    /**
45
     * {@inheritDoc}
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
     * @param string $toType
56
     * @param string $destPath
57
     *
58
     * @return \Doctrine\ORM\Tools\Export\Driver\AbstractExporter
59
     */
60
    protected function getExporter($toType, $destPath)
61
    {
62
        /** @var $exporter \Doctrine\ORM\Tools\Export\Driver\AbstractExporter */
63
        $exporter = parent::getExporter($toType, $destPath);
64
        if ($exporter instanceof XmlExporter) {
65
            $exporter->setExtension('.orm.xml');
66
        } elseif ($exporter instanceof YamlExporter) {
67
            $exporter->setExtension('.orm.yml');
68
        }
69
70
        return $exporter;
71
    }
72
}
73