/** * {@inheritDoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $application = $this->getApplication(); #source $source = $input->getOption('source-em') ?: 'default'; $emSource = $application->getKernel()->getContainer()->get('doctrine')->getManager($source); $helperSet = $application->getHelperSet(); $helperSet->set(new ConnectionHelper($emSource->getConnection()), 'source-db'); $helperSet->set(new EntityManagerHelper($emSource), 'source-em'); #audit $audit = $input->getOption('audit-em') ?: 'audit'; $emAudit = $application->getKernel()->getContainer()->get('doctrine')->getManager($audit); $helperSet->set(new ConnectionHelper($emAudit->getConnection()), 'audit-db'); $helperSet->set(new EntityManagerHelper($emAudit), 'audit-em'); $sourceEmHelper = $this->getHelper('source-em'); $auditEmHelper = $this->getHelper('audit-em'); /* @var $em \Doctrine\ORM\EntityManager */ $sourceEm = $sourceEmHelper->getEntityManager(); $auditEm = $auditEmHelper->getEntityManager(); $sourceMetadatas = $sourceEm->getMetadataFactory()->getAllMetadata(); if (!empty($sourceMetadatas)) { // Create SchemaTool $auditTool = new SchemaTool($auditEm, $sourceEm); return $this->execSchemaCommand($input, $output, $auditTool, $sourceMetadatas); } else { $output->writeln('No Metadata Classes to process.'); return 0; } return parent::execute($input, $output); }