vendor/sonata-project/easy-extends-bundle/src/Command/DumpMappingCommand.php line 25

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Sonata Project package.
  4.  *
  5.  * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Sonata\EasyExtendsBundle\Command;
  11. use Doctrine\ORM\Tools\Export\ClassMetadataExporter;
  12. use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
  13. use Symfony\Component\Console\Input\InputArgument;
  14. use Symfony\Component\Console\Input\InputInterface;
  15. use Symfony\Component\Console\Output\OutputInterface;
  16. /**
  17.  * Generate Application entities from bundle entities.
  18.  *
  19.  * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
  20.  */
  21. class DumpMappingCommand extends ContainerAwareCommand
  22. {
  23.     /**
  24.      * {@inheritdoc}
  25.      */
  26.     protected function configure()
  27.     {
  28.         $this->setName('sonata:easy-extends:dump-mapping');
  29.         $this->setDescription('Dump some mapping information (debug only)');
  30.         $this->addArgument('manager'InputArgument::OPTIONAL'The manager name to use'false);
  31.         $this->addArgument('model'InputArgument::OPTIONAL'The class to dump'false);
  32.     }
  33.     /**
  34.      * {@inheritdoc}
  35.      */
  36.     protected function execute(InputInterface $inputOutputInterface $output)
  37.     {
  38.         $factory $this->getContainer()->get('doctrine')->getManager($input->getArgument('manager'))->getMetadataFactory();
  39.         $metadata $factory->getMetadataFor($input->getArgument('model'));
  40.         $cme = new ClassMetadataExporter();
  41.         $exporter $cme->getExporter('php');
  42.         $output->writeln($exporter->exportClassMetadata($metadata));
  43.         $output->writeln('Done!');
  44.     }
  45. }