1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the Sonata Project package. |
7
|
|
|
* |
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Sonata\EasyExtendsBundle\Command; |
15
|
|
|
|
16
|
|
|
use Doctrine\ORM\Tools\Export\ClassMetadataExporter; |
17
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
18
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
19
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
20
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Generate Application entities from bundle entities. |
24
|
|
|
* |
25
|
|
|
* @author Thomas Rabaix <[email protected]> |
26
|
|
|
*/ |
27
|
|
|
class DumpMappingCommand extends ContainerAwareCommand |
|
|
|
|
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* {@inheritdoc} |
31
|
|
|
*/ |
32
|
|
|
protected function configure(): void |
33
|
|
|
{ |
34
|
|
|
$this->setName('sonata:easy-extends:dump-mapping'); |
35
|
|
|
$this->setDescription('Dump some mapping information (debug only)'); |
36
|
|
|
|
37
|
|
|
$this->addArgument('manager', InputArgument::OPTIONAL, 'The manager name to use'); |
38
|
|
|
$this->addArgument('model', InputArgument::OPTIONAL, 'The class to dump'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritdoc} |
43
|
|
|
*/ |
44
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int |
45
|
|
|
{ |
46
|
|
|
$factory = $this->getContainer() |
47
|
|
|
->get('doctrine') |
48
|
|
|
->getManager($input->getArgument('manager')) |
49
|
|
|
->getMetadataFactory(); |
50
|
|
|
|
51
|
|
|
$metadata = $factory->getMetadataFor($input->getArgument('model')); |
52
|
|
|
|
53
|
|
|
$cme = new ClassMetadataExporter(); |
|
|
|
|
54
|
|
|
$exporter = $cme->getExporter('php'); |
55
|
|
|
|
56
|
|
|
$output->writeln($exporter->exportClassMetadata($metadata)); |
57
|
|
|
$output->writeln('Done!'); |
58
|
|
|
|
59
|
|
|
return 0; |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.