当前位置: 首页>>代码示例>>PHP>>正文


PHP EntityGenerator::setClassToExtend方法代码示例

本文整理汇总了PHP中Doctrine\ORM\Tools\EntityGenerator::setClassToExtend方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityGenerator::setClassToExtend方法的具体用法?PHP EntityGenerator::setClassToExtend怎么用?PHP EntityGenerator::setClassToExtend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ORM\Tools\EntityGenerator的用法示例。


在下文中一共展示了EntityGenerator::setClassToExtend方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testEntityExtendsStdClass

 public function testEntityExtendsStdClass()
 {
     $this->_generator->setClassToExtend('stdClass');
     $metadata = $this->generateBookEntityFixture();
     $book = $this->newInstance($metadata);
     $this->assertInstanceOf('stdClass', $book);
 }
开发者ID:naumangcu,项目名称:doctrine2,代码行数:7,代码来源:EntityGeneratorTest.php

示例2: run

 /**
  * @inheritdoc
  */
 public function run()
 {
     $printer = $this->getPrinter();
     $arguments = $this->getArguments();
     $from = $arguments['from'];
     $dest = realpath($arguments['dest']);
     $entityGenerator = new EntityGenerator();
     $entityGenerator->setGenerateAnnotations(false);
     $entityGenerator->setGenerateStubMethods(true);
     $entityGenerator->setRegenerateEntityIfExists(false);
     $entityGenerator->setUpdateEntityIfExists(true);
     if (isset($arguments['extend']) && $arguments['extend']) {
         $entityGenerator->setClassToExtend($arguments['extend']);
     }
     if (isset($arguments['num-spaces']) && $arguments['extend']) {
         $entityGenerator->setNumSpaces($arguments['num-spaces']);
     }
     $reader = new ClassMetadataReader();
     $reader->setEntityManager($this->getConfiguration()->getAttribute('em'));
     $reader->addMappingSource($from);
     $metadatas = $reader->getMetadatas();
     foreach ($metadatas as $metadata) {
         $printer->writeln(sprintf('Processing entity "%s"', $printer->format($metadata->name, 'KEYWORD')));
     }
     $entityGenerator->generate($metadatas, $dest);
     $printer->write(PHP_EOL);
     $printer->writeln(sprintf('Entity classes generated to "%s"', $printer->format($dest, 'KEYWORD')));
 }
开发者ID:andreia,项目名称:doctrine,代码行数:31,代码来源:GenerateEntitiesTask.php

示例3: execute

 /**
  * @see Console\Command\Command
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $em = $this->getHelper('em')->getEntityManager();
     if (\Zend_Registry::isRegistered(\LoSo_Zend_Application_Bootstrap_SymfonyContainerBootstrap::getRegistryIndex()) && ($container = \Zend_Registry::get(\LoSo_Zend_Application_Bootstrap_SymfonyContainerBootstrap::getRegistryIndex())) instanceof \Symfony\Component\DependencyInjection\ContainerInterface) {
         $mappingPaths = $container->getParameter('doctrine.orm.mapping_paths');
         $entitiesPaths = $container->getParameter('doctrine.orm.entities_paths');
     } else {
         $doctrineConfig = \Zend_Registry::get('doctrine.config');
         $mappingPaths = $doctrineConfig['doctrine.orm.mapping_paths'];
         $entitiesPaths = $doctrineConfig['doctrine.orm.entities_paths'];
     }
     $cmf = new DisconnectedClassMetadataFactory($em);
     $metadatas = $cmf->getAllMetadata();
     foreach ($mappingPaths as $namespace => $mappingPath) {
         // Process destination directory
         $destPath = realpath($entitiesPaths[$namespace]);
         if (!file_exists($destPath)) {
             throw new \InvalidArgumentException(sprintf("Entities destination directory '<info>%s</info>' does not exist.", $destPath));
         } else {
             if (!is_writable($destPath)) {
                 throw new \InvalidArgumentException(sprintf("Entities destination directory '<info>%s</info>' does not have write permissions.", $destPath));
             }
         }
         $moduleMetadatas = MetadataFilter::filter($metadatas, $namespace);
         if (count($moduleMetadatas)) {
             // 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'));
             if (($extend = $input->getOption('extend')) !== null) {
                 $entityGenerator->setClassToExtend($extend);
             }
             foreach ($moduleMetadatas as $metadata) {
                 $output->write(sprintf('Processing entity "<info>%s</info>"', $metadata->name) . PHP_EOL);
             }
             // Generating Entities
             $entityGenerator->generate($moduleMetadatas, $destPath);
             $this->_processNamespaces($destPath, $namespace);
             // Outputting information message
             $output->write(sprintf('Entity classes generated to "<info>%s</INFO>"', $destPath) . PHP_EOL);
         } else {
             $output->write('No Metadata Classes to process.' . PHP_EOL);
         }
     }
     /*$output->write(PHP_EOL . 'Reset database.' . PHP_EOL);
     
             $metadatas = $em->getMetadataFactory()->getAllMetadata();
             $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em);
             $output->write('Dropping database schema...' . PHP_EOL);
             $schemaTool->dropSchema($metadatas);
             $output->write('Database schema dropped successfully!' . PHP_EOL);
             $output->write('Creating database schema...' . PHP_EOL);
             $schemaTool->createSchema($metadatas);
             $output->write('Database schema created successfully!' . PHP_EOL);*/
 }
开发者ID:0mars,项目名称:losolib,代码行数:61,代码来源:BuildCommand.php

示例4: 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

示例5: execute

 /**
  * @see Console\Command\Command
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\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.", $destPath));
     } else {
         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'));
         if (($extend = $input->getOption('extend')) !== null) {
             $entityGenerator->setClassToExtend($extend);
         }
         foreach ($metadatas as $metadata) {
             $output->write(sprintf('Processing entity "<info>%s</info>"', $metadata->name) . PHP_EOL);
         }
         // Generating Entities
         $entityGenerator->generate($metadatas, $destPath);
         // Outputting information message
         $output->write(PHP_EOL . sprintf('Entity classes generated to "<info>%s</INFO>"', $destPath) . PHP_EOL);
     } else {
         $output->write('No Metadata Classes to process.' . PHP_EOL);
     }
 }
开发者ID:michaelnavarro,项目名称:zc,代码行数:41,代码来源:GenerateEntitiesCommand.php

示例6: getEntityGenerator

 /**
  * Get a Doctrine EntityGenerator instance.
  *
  * @param string|null $classToExtend
  *
  * @return EntityGenerator
  */
 protected function getEntityGenerator($classToExtend = null)
 {
     $entityGenerator = new EntityGenerator();
     if (!is_null($classToExtend)) {
         $entityGenerator->setClassToExtend($classToExtend);
     }
     $entityGenerator->setGenerateAnnotations(true);
     $entityGenerator->setGenerateStubMethods(true);
     $entityGenerator->setRegenerateEntityIfExists(false);
     $entityGenerator->setUpdateEntityIfExists(true);
     $entityGenerator->setNumSpaces(4);
     $entityGenerator->setAnnotationPrefix('ORM\\');
     return $entityGenerator;
 }
开发者ID:axelvnk,项目名称:KunstmaanBundlesCMS,代码行数:21,代码来源:KunstmaanGenerator.php

示例7: getEntityGenerator

 /**
  * @return \Doctrine\ORM\Tools\EntityGenerator
  */
 protected function getEntityGenerator()
 {
     $entityGenerator = new EntityGenerator();
     $entityGenerator->setClassToExtend('Kunstmaan\\AdminBundle\\Entity\\AbstractEntity');
     $entityGenerator->setGenerateAnnotations(true);
     $entityGenerator->setGenerateStubMethods(true);
     $entityGenerator->setRegenerateEntityIfExists(false);
     $entityGenerator->setUpdateEntityIfExists(true);
     $entityGenerator->setNumSpaces(4);
     $entityGenerator->setAnnotationPrefix('ORM\\');
     return $entityGenerator;
 }
开发者ID:axelvnk,项目名称:KunstmaanBundlesCMS,代码行数:15,代码来源:DoctrineEntityGenerator.php

示例8: 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::setClassToExtend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。