|
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
|
|
|
|