Exemplo n.º 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dbName = $input->getArgument('dbname');
     $path = $input->getOption('path');
     $extensionKey = $input->getOption('extension-key');
     $connectionParams = array('dbname' => $dbName, 'user' => $input->getOption('user'), 'password' => $input->getOption('password'), 'host' => $input->getOption('host'), 'driver' => $input->getOption('driver'), 'port' => $input->getOption('port'));
     $config = Setup::createAnnotationMetadataConfiguration(array('.'), false);
     $em = EntityManager::create($connectionParams, $config);
     $em->getConfiguration()->setMetadataDriverImpl(new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($em->getConnection()->getSchemaManager()));
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($em);
     if (is_null($extensionKey)) {
         $extensionKey = $dbName;
         if (self::DEFAULT_PATH != $path) {
             $extensionKey = array_pop(explode(DIRECTORY_SEPARATOR, $path));
         }
     }
     $exporter = new ExtbaseExporter($cmf);
     $exporter->setExtensionKey($extensionKey);
     $exporter->setPath($input->getOption('path'));
     self::mapDefaultInputOptions($exporter, $input);
     $output->writeln(sprintf('Exporting database schema "<info>%s</info>".', $dbName));
     $result = $exporter->exportJson();
     foreach ($exporter->getLogs() as $log) {
         $output->writeln($log);
     }
     return $result ? 0 : 1;
 }
 /**
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getContainer()->get('doctrine')->getManager($input->getOption('em'));
     $path = $input->getOption('path') ? $input->getOption('path') : $this->getContainer()->getParameter('kernel.cache_dir');
     if ($input->getOption('from-database')) {
         $em->getConfiguration()->setMetadataDriverImpl(new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($em->getConnection()->getSchemaManager()));
     }
     $emName = $input->getOption('em');
     $emName = $emName ? $emName : 'default';
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($em);
     $exporter = new ExtbaseExporter($cmf);
     $exporter->setExtensionKey($input->getArgument('extension-key'));
     $exporter->setPath($path);
     \EdRush\Extbaser\Command\ExportExtbaseCommand::mapDefaultInputOptions($exporter, $input);
     $output->writeln(sprintf('Importing mapping information from "<info>%s</info>" entity manager', $emName));
     $result = $exporter->exportJson();
     foreach ($exporter->getLogs() as $log) {
         $output->writeln($log);
     }
     return $result ? 0 : 1;
 }