public function fire() { $this->info('Starting proxy generation....'); // flush all generated and cached entities, etc \D2Cache::flushAll(); try { $metadata = $this->d2em->getMetadataFactory()->getAllMetadata(); } catch (\Doctrine\Common\Persistence\Mapping\MappingException $e) { if ($this->option('verbose') == 3) { throw $e; } $this->error("Caught Doctrine\\Common\\Persistence\\Mapping\\MappingException: " . $e->getMessage()); $this->info("Re-optimizing:"); $this->call('optimize'); $this->comment("*** You must now rerun this artisan command ***"); exit(-1); } if (empty($metadata)) { $this->error('No metadata found to generate entities.'); return -1; } $directory = Config::get('d2doctrine.paths.proxies'); if (!$directory) { $this->error('The proxy directory has not been set.'); return -1; } $this->info('Processing entities:'); foreach ($metadata as $item) { $this->line($item->name); } $this->d2em->getProxyFactory()->generateProxyClasses($metadata, $directory); $this->info('Proxies have been created.'); }
public function fire() { $this->info('Starting entities generation....'); // flush all generated and cached entities, etc \D2Cache::flushAll(); $cmf = new DisconnectedClassMetadataFactory(); $cmf->setEntityManager($this->d2em); $metadata = $cmf->getAllMetadata(); if (empty($metadata)) { $this->error('No metadata found to generate entities.'); return -1; } $directory = Config::get('d2doctrine.paths.entities'); if (!$directory) { $this->error('The entity directory has not been set.'); return -1; } $entityGenerator = new EntityGenerator(); $entityGenerator->setGenerateAnnotations($this->option('generate-annotations')); $entityGenerator->setGenerateStubMethods($this->option('generate-methods')); $entityGenerator->setRegenerateEntityIfExists($this->option('regenerate-entities')); $entityGenerator->setUpdateEntityIfExists($this->option('update-entities')); $entityGenerator->setNumSpaces($this->option('num-spaces')); $entityGenerator->setBackupExisting(!$this->option('no-backup')); $this->info('Processing entities:'); foreach ($metadata as $item) { $this->line($item->name); } try { $entityGenerator->generate($metadata, $directory); $this->info('Entities have been created.'); } catch (\ErrorException $e) { if ($this->option('verbose') == 3) { throw $e; } $this->error("Caught ErrorException: " . $e->getMessage()); $this->info("Re-optimizing:"); $this->call('optimize'); $this->comment("*** You must now rerun this artisan command ***"); exit(-1); } }
public function fire() { $this->info('Starting repository generation....'); // flush all generated and cached entities, etc \D2Cache::flushAll(); try { $metadatas = $this->d2em->getMetadataFactory()->getAllMetadata(); } catch (\Doctrine\Common\Persistence\Mapping\MappingException $e) { if ($this->option('verbose') == 3) { throw $e; } $this->error("Caught Doctrine\\Common\\Persistence\\Mapping\\MappingException: " . $e->getMessage()); $this->info("Re-optimizing:"); $this->call('optimize'); $this->comment("*** You must now rerun this artisan command ***"); exit(-1); } if (empty($metadatas)) { $this->error('No metadata found to generate entities.'); return -1; } $directory = Config::get('d2bdoctrine.paths.repositories'); if (!$directory) { $this->error('The entity directory has not been set.'); return -1; } $numRepositories = 0; $generator = new EntityRepositoryGenerator(); foreach ($metadatas as $metadata) { if ($metadata->customRepositoryClassName) { $this->line(sprintf('Processing repository "<info>%s</info>"', $metadata->customRepositoryClassName)); $generator->writeEntityRepositoryClass($metadata->customRepositoryClassName, $directory); $numRepositories++; } } if ($numRepositories) { $this->info('Repositories have been created.'); } else { $this->info('No Repository classes were found to be processed.'); } }