當前位置: 首頁>>代碼示例>>PHP>>正文


PHP EntityGenerator::setBackupExisting方法代碼示例

本文整理匯總了PHP中Doctrine\ORM\Tools\EntityGenerator::setBackupExisting方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityGenerator::setBackupExisting方法的具體用法?PHP EntityGenerator::setBackupExisting怎麽用?PHP EntityGenerator::setBackupExisting使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\ORM\Tools\EntityGenerator的用法示例。


在下文中一共展示了EntityGenerator::setBackupExisting方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: initGenerator

 protected function initGenerator()
 {
     $this->generator->setGenerateAnnotations(true);
     $this->generator->setBackupExisting(false);
     $this->generator->setGenerateStubMethods(true);
     $this->generator->setRegenerateEntityIfExists(true);
     $this->generator->setUpdateEntityIfExists(false);
     if ($this->parentClassName != null) {
         $this->generator->setClassToExtend($this->parentClassName);
     }
     return $this->generator;
 }
開發者ID:bitweb,項目名稱:doctrine-entity-generator-module,代碼行數:12,代碼來源:EntityGeneratorService.php

示例2: testRegenerateEntityClass

 public function testRegenerateEntityClass()
 {
     $metadata = $this->generateBookEntityFixture();
     $this->loadEntityClass($metadata);
     $className = basename(str_replace('\\', '/', $metadata->name));
     $path = $this->_tmpDir . '/' . $this->_namespace . '/' . $className . '.php';
     $classTest = file_get_contents($path);
     $this->_generator->setRegenerateEntityIfExists(true);
     $this->_generator->setBackupExisting(false);
     $this->_generator->writeEntityClass($metadata, $this->_tmpDir);
     $classNew = file_get_contents($path);
     $this->assertSame($classTest, $classNew);
 }
開發者ID:selimcr,項目名稱:servigases,代碼行數:13,代碼來源:EntityGeneratorTest.php

示例3: fire

 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);
     }
 }
開發者ID:jeanbelhache,項目名稱:doctrine2-l5,代碼行數:42,代碼來源:Entities.php

示例4: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getHelper('em')->getEntityManager();
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($em);
     $metadatas = $cmf->getAllMetadata();
     $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter'));
     // Process destination directory
     $destPath = realpath($input->getArgument('dest-path'));
     if (!file_exists($destPath)) {
         throw new \InvalidArgumentException(sprintf("Entities destination directory '<info>%s</info>' does not exist.", $input->getArgument('dest-path')));
     }
     if (!is_writable($destPath)) {
         throw new \InvalidArgumentException(sprintf("Entities destination directory '<info>%s</info>' does not have write permissions.", $destPath));
     }
     if (count($metadatas)) {
         // Create EntityGenerator
         $entityGenerator = new EntityGenerator();
         $entityGenerator->setGenerateAnnotations($input->getOption('generate-annotations'));
         $entityGenerator->setGenerateStubMethods($input->getOption('generate-methods'));
         $entityGenerator->setRegenerateEntityIfExists($input->getOption('regenerate-entities'));
         $entityGenerator->setUpdateEntityIfExists($input->getOption('update-entities'));
         $entityGenerator->setNumSpaces($input->getOption('num-spaces'));
         $entityGenerator->setBackupExisting(!$input->getOption('no-backup'));
         if (($extend = $input->getOption('extend')) !== null) {
             $entityGenerator->setClassToExtend($extend);
         }
         foreach ($metadatas as $metadata) {
             $output->writeln(sprintf('Processing entity "<info>%s</info>"', $metadata->name));
         }
         // Generating Entities
         $entityGenerator->generate($metadatas, $destPath);
         // Outputting information message
         $output->writeln(PHP_EOL . sprintf('Entity classes generated to "<info>%s</INFO>"', $destPath));
     } else {
         $output->writeln('No Metadata Classes to process.');
     }
 }
開發者ID:Dren-x,項目名稱:mobitnew,代碼行數:41,代碼來源:GenerateEntitiesCommand.php

示例5: getEntityGenerator

 protected function getEntityGenerator()
 {
     $entityGenerator = new EntityGenerator();
     $entityGenerator->setGenerateStubMethods(true);
     $entityGenerator->setRegenerateEntityIfExists(true);
     $entityGenerator->setBackupExisting(true);
     return $entityGenerator;
 }
開發者ID:tigerman,項目名稱:doctrine-generate-models-bundle,代碼行數:8,代碼來源:GenerateModelsDoctrineCommand.php

示例6: generateEntities

 /**
  * Generate entity classes
  *
  * @param array $metadata            
  */
 protected function generateEntities(array $metadata)
 {
     $generator = new EntityGenerator();
     $generator->setGenerateAnnotations(true);
     $generator->setGenerateStubMethods(true);
     $generator->setRegenerateEntityIfExists(false);
     $generator->setUpdateEntityIfExists(true);
     $generator->setBackupExisting(false);
     if (null !== ($superclass = $this->getSuperclass())) {
         $generator->setClassToExtend($superclass);
     }
     /* @var $classMetadata \Doctrine\ORM\Mapping\ClassMetadata */
     foreach ($metadata as $classMetadata) {
         $className = end(explode('\\', $classMetadata->getName()));
         $classMetadata->setCustomRepositoryClass($this->getNsRepository() . $className);
         if (null !== ($prefix = $this->getSequencePrefix())) {
             $classMetadata->setSequenceGeneratorDefinition(array('sequenceName' => strtoupper($prefix . '_' . $className)));
         }
     }
     $generator->generate($metadata, $this->getDirectory());
 }
開發者ID:globtec,項目名稱:doctrine-generator,代碼行數:26,代碼來源:Generator.php


注:本文中的Doctrine\ORM\Tools\EntityGenerator::setBackupExisting方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。