当前位置: 首页>>代码示例>>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;未经允许,请勿转载。