Ejemplo n.º 1
0
 public function generateSchemaSql($return)
 {
     $entityManager = EntityHelper::getEntityManager();
     $cacheDriver = $entityManager->getConfiguration()->getMetadataCacheImpl();
     if ($cacheDriver && !$cacheDriver instanceof ApcCache) {
         $cacheDriver->deleteAll();
     }
     // force "disconnected" generation of entities
     $reload = false;
     EntityGeneration::generate(null, $reload);
     if ($reload) {
         $this->reload();
     }
     $metadatas = $entityManager->getMetadataFactory()->getAllMetadata();
     $tool = new SchemaTool($entityManager);
     $queries = $tool->getUpdateSchemaSql($metadatas);
     $filter = array_map('preg_quote', $GLOBALS['DOCTRINE_MANAGED_TABLE']);
     $filter = implode('|', $filter);
     $filter = sprintf('~^(CREATE|ALTER|DROP) TABLE (%s)~', $filter);
     $queries = array_filter($queries, function ($query) use($filter) {
         return preg_match($filter, $query);
     });
     return $this->appendQueries($return, $queries);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     EntityGeneration::generate($output);
 }