vendor/doctrine/doctrine-bundle/Command/Proxy/ConvertMappingDoctrineCommand.php line 19

Open in your IDE?
  1. <?php
  2. namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;
  3. use Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand;
  4. use Doctrine\ORM\Tools\Export\Driver\AbstractExporter;
  5. use Doctrine\ORM\Tools\Export\Driver\XmlExporter;
  6. use Doctrine\ORM\Tools\Export\Driver\YamlExporter;
  7. use Symfony\Component\Console\Input\InputInterface;
  8. use Symfony\Component\Console\Input\InputOption;
  9. use Symfony\Component\Console\Output\OutputInterface;
  10. use function assert;
  11. /**
  12.  * Convert Doctrine ORM metadata mapping information between the various supported
  13.  * formats.
  14.  */
  15. class ConvertMappingDoctrineCommand extends ConvertMappingCommand
  16. {
  17.     /**
  18.      * {@inheritDoc}
  19.      */
  20.     protected function configure()
  21.     {
  22.         parent::configure();
  23.         $this
  24.             ->setName('doctrine:mapping:convert');
  25.         if ($this->getDefinition()->hasOption('em')) {
  26.             return;
  27.         }
  28.         $this->addOption('em'nullInputOption::VALUE_OPTIONAL'The entity manager to use for this command');
  29.     }
  30.     /**
  31.      * {@inheritDoc}
  32.      */
  33.     protected function execute(InputInterface $inputOutputInterface $output)
  34.     {
  35.         DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
  36.         return parent::execute($input$output);
  37.     }
  38.     /**
  39.      * @param string $toType
  40.      * @param string $destPath
  41.      *
  42.      * @return AbstractExporter
  43.      */
  44.     protected function getExporter($toType$destPath)
  45.     {
  46.         $exporter parent::getExporter($toType$destPath);
  47.         assert($exporter instanceof AbstractExporter);
  48.         if ($exporter instanceof XmlExporter) {
  49.             $exporter->setExtension('.orm.xml');
  50.         } elseif ($exporter instanceof YamlExporter) {
  51.             $exporter->setExtension('.orm.yml');
  52.         }
  53.         return $exporter;
  54.     }
  55. }