DumpMappingCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 6
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 8 1
A execute() 0 17 1
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
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Bundle\Framework...d\ContainerAwareCommand has been deprecated with message: since Symfony 4.2, use {@see Command} instead.

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.

Loading history...
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();
0 ignored issues
show
Deprecated Code introduced by
The class Doctrine\ORM\Tools\Export\ClassMetadataExporter has been deprecated with message: 2.7 This class is being removed from the ORM and won't have any replacement

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.

Loading history...
54
        $exporter = $cme->getExporter('php');
55
56
        $output->writeln($exporter->exportClassMetadata($metadata));
57
        $output->writeln('Done!');
58
59
        return 0;
60
    }
61
}
62