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

DumpMappingCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 7
Bugs 3 Features 2
Metric Value
wmc 2
c 7
b 3
f 2
lcom 1
cbo 6
dl 0
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 8 1
A execute() 0 12 1
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