Completed
Push — 2.x ( dc834d...91b37b )
by
unknown
02:07
created

DumpMappingCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 2 Features 1
Metric Value
c 4
b 2
f 1
dl 0
loc 12
rs 9.4285
cc 1
eloc 7
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
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 Sonata\EasyExtendsBundle\Command;
13
14
use Doctrine\ORM\Tools\Export\ClassMetadataExporter;
15
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
16
use Symfony\Component\Console\Input\InputArgument;
17
use Symfony\Component\Console\Input\InputInterface;
18
use Symfony\Component\Console\Output\OutputInterface;
19
20
/**
21
 * Generate Application entities from bundle entities.
22
 *
23
 * @author Thomas Rabaix <[email protected]>
24
 */
25
class DumpMappingCommand extends ContainerAwareCommand
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30
    protected function configure()
31
    {
32
        $this->setName('sonata:easy-extends:dump-mapping');
33
        $this->setDescription('Dump some mapping information (debug only)');
34
35
        $this->addArgument('manager', InputArgument::OPTIONAL, 'The manager name to use', false);
36
        $this->addArgument('model', InputArgument::OPTIONAL, 'The class to dump', false);
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    protected function execute(InputInterface $input, OutputInterface $output)
43
    {
44
        $factory = $this->getContainer()->get('doctrine')->getManager($input->getArgument('manager'))->getMetadataFactory();
45
46
        $metadata = $factory->getMetadataFor($input->getArgument('model'));
47
48
        $cme = new ClassMetadataExporter();
49
        $exporter = $cme->getExporter('php');
50
51
        $output->writeln($exporter->exportClassMetadata($metadata));
52
        $output->writeln('Done!');
53
    }
54
}
55