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


PHP EntityGenerator::setAnnotationPrefix方法代码示例

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


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

示例1: setUp

 /**
  * @inheritdoc
  */
 public function setUp()
 {
     $this->_namespace = uniqid('doctrine_');
     $this->_tmpDir = \sys_get_temp_dir() . DIRECTORY_SEPARATOR . $this->_namespace;
     \mkdir($this->_tmpDir);
     $this->_generator = new EntityGenerator();
     $this->_generator->setAnnotationPrefix("");
     $this->_generator->setGenerateAnnotations(true);
     $this->_generator->setGenerateStubMethods(true);
     $this->_generator->setRegenerateEntityIfExists(false);
     $this->_generator->setUpdateEntityIfExists(true);
     $this->_generator->setFieldVisibility(EntityGenerator::FIELD_VISIBLE_PROTECTED);
     $this->_repositoryGenerator = new EntityRepositoryGenerator();
 }
开发者ID:selimcr,项目名称:servigases,代码行数:17,代码来源:EntityRepositoryGeneratorTest.php

示例2: getEntityGenerator

 protected function getEntityGenerator()
 {
     $entityGenerator = new EntityGenerator();
     $entityGenerator->setGenerateAnnotations(false);
     $entityGenerator->setGenerateStubMethods(true);
     $entityGenerator->setRegenerateEntityIfExists(false);
     $entityGenerator->setUpdateEntityIfExists(true);
     $entityGenerator->setNumSpaces(4);
     $entityGenerator->setAnnotationPrefix('ORM\\');
     return $entityGenerator;
 }
开发者ID:laubosslink,项目名称:lab,代码行数:11,代码来源:DoctrineCommand.php

示例3: getEntityGenerator

 protected function getEntityGenerator()
 {
     $entityGenerator = new EntityGenerator();
     if (version_compare(DoctrineVersion::VERSION, "2.0.2-DEV") >= 0) {
         $entityGenerator->setAnnotationPrefix("orm:");
     }
     $entityGenerator->setGenerateAnnotations(false);
     $entityGenerator->setGenerateStubMethods(true);
     $entityGenerator->setRegenerateEntityIfExists(false);
     $entityGenerator->setUpdateEntityIfExists(true);
     $entityGenerator->setNumSpaces(4);
     return $entityGenerator;
 }
开发者ID:rfc1483,项目名称:symfony,代码行数:13,代码来源:DoctrineCommand.php

示例4: testMappedSuperclassAnnotationGeneration

 /**
  * @group DDC-3272
  */
 public function testMappedSuperclassAnnotationGeneration()
 {
     $metadata = new ClassMetadataInfo($this->_namespace . '\\EntityGeneratorBook');
     $metadata->namespace = $this->_namespace;
     $metadata->isMappedSuperclass = true;
     $this->_generator->setAnnotationPrefix('ORM\\');
     $this->_generator->writeEntityClass($metadata, $this->_tmpDir);
     $this->newInstance($metadata);
     // force instantiation (causes autoloading to kick in)
     $driver = new AnnotationDriver(new AnnotationReader(), array());
     $cm = new ClassMetadata($metadata->name);
     $cm->initializeReflection(new RuntimeReflectionService());
     $driver->loadMetadataForClass($cm->name, $cm);
     $this->assertTrue($cm->isMappedSuperclass);
 }
开发者ID:selimcr,项目名称:servigases,代码行数:18,代码来源:EntityGeneratorTest.php

示例5: testLoadPrefixedMetadata

 public function testLoadPrefixedMetadata()
 {
     $this->_generator->setAnnotationPrefix('ORM\\');
     $metadata = $this->generateBookEntityFixture();
     $reader = new \Doctrine\Common\Annotations\AnnotationReader();
     $driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, array());
     $book = $this->newInstance($metadata);
     $cm = new \Doctrine\ORM\Mapping\ClassMetadata($metadata->name);
     $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     $driver->loadMetadataForClass($cm->name, $cm);
     $this->assertEquals($cm->columnNames, $metadata->columnNames);
     $this->assertEquals($cm->getTableName(), $metadata->getTableName());
     $this->assertEquals($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks);
     $this->assertEquals($cm->identifier, $metadata->identifier);
     $this->assertEquals($cm->idGenerator, $metadata->idGenerator);
     $this->assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName);
 }
开发者ID:naumangcu,项目名称:doctrine2,代码行数:17,代码来源:EntityGeneratorTest.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: testExportDirectoryAndFilesAreCreated

 public function testExportDirectoryAndFilesAreCreated()
 {
     $this->_deleteDirectory(__DIR__ . '/export/' . $this->_getType());
     $type = $this->_getType();
     $metadataDriver = $this->_createMetadataDriver($type, __DIR__ . '/' . $type);
     $em = $this->_createEntityManager($metadataDriver);
     $cmf = $this->_createClassMetadataFactory($em, $type);
     $metadata = $cmf->getAllMetadata();
     $metadata[0]->name = 'Doctrine\\Tests\\ORM\\Tools\\Export\\ExportedUser';
     $this->assertEquals('Doctrine\\Tests\\ORM\\Tools\\Export\\ExportedUser', $metadata[0]->name);
     $type = $this->_getType();
     $cme = new ClassMetadataExporter();
     $exporter = $cme->getExporter($type, __DIR__ . '/export/' . $type);
     if ($type === 'annotation') {
         $entityGenerator = new EntityGenerator();
         $entityGenerator->setAnnotationPrefix("");
         $exporter->setEntityGenerator($entityGenerator);
     }
     $this->_extension = $exporter->getExtension();
     $exporter->setMetadata($metadata);
     $exporter->export();
     if ($type == 'annotation') {
         $this->assertTrue(file_exists(__DIR__ . '/export/' . $type . '/' . str_replace('\\', '/', 'Doctrine\\Tests\\ORM\\Tools\\Export\\ExportedUser') . $this->_extension));
     } else {
         $this->assertTrue(file_exists(__DIR__ . '/export/' . $type . '/Doctrine.Tests.ORM.Tools.Export.ExportedUser' . $this->_extension));
     }
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:27,代码来源:AbstractClassMetadataExporterTest.php

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

示例9: generateClasses

 /**
  * Generate the model class for Raptor
  * Genera las clases modelos para las clases schema especificadas
  * Los modelos seran generados en el namespace especificado
  * Tenga en cuenta que un SchemaClass no es lo mismo que los nombres
  * de las tablas, es una representacion que brinda doctrine para tablas en la base de datos
  * 
  * $this->getStore()->generateClasses('\example\exampleBundle','Persona');
  * 
  * @param string $namespace el namespace del bundle donde seran creados los modelos
  * @param array $schemaClass un array con todos los schemaClass que seran generados los modelos
  */
 public function generateClasses($namespace, $schemaClass)
 {
     $clases = $schemaClass;
     // custom datatypes (not mapped for reverse engineering)
     $this->entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('set', 'string');
     $this->entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
     // fetch metadata
     $driver = new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($this->entityManager->getConnection()->getSchemaManager());
     $this->entityManager->getConfiguration()->setMetadataDriverImpl($driver);
     $cmf = new \Doctrine\ORM\Tools\DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($this->entityManager);
     // we must set the EntityManager
     $classes = $driver->getAllClassNames();
     $metadata = array();
     $rep = new EntityRepositoryGenerator();
     foreach ($clases as $class) {
         //any unsupported table/schema could be handled here to exclude some classes
         if (true) {
             $meta = $cmf->getMetadataFor($class);
             $association = new ItemList($meta->associationMappings);
             $me = $this;
             $association->each(function ($k, $v, $l) use(&$me) {
                 $v['targetEntity'] = $me->translateSchemas($v['targetEntity']);
                 $v['sourceEntity'] = $me->translateSchemas($v['sourceEntity']);
                 $l->set($k, $v);
             });
             $meta->associationMappings = $association->getArray();
             $real = $this->translateSchemas($class);
             $meta->name = $namespace . $this->namespaceSeparator . 'Model' . $this->namespaceSeparator . 'Entity' . $this->namespaceSeparator . $real;
             $meta->namespace = $namespace . $this->namespaceSeparator . 'Model' . $this->namespaceSeparator . 'Entity';
             // $meta->namespace='Entities\\'.$class;
             $meta->customRepositoryClassName = $namespace . $this->namespaceSeparator . 'Model' . $this->namespaceSeparator . 'Repository' . $this->namespaceSeparator . $real . 'Repository';
             //TODO buscar entidades ya creadas
             foreach ($meta->associationMappings as $key => $value) {
                 $names = $this->entityManager->getConfiguration()->getEntityNamespaces();
                 $target = $meta->associationMappings[$key]['targetEntity'];
                 $found = false;
                 foreach ($names as $routes) {
                     if ($routes[0] == '\\') {
                         $bundleRoute = substr($routes, 1);
                     } else {
                         $bundleRoute = $routes;
                     }
                     $fileroute = __DIR__ . "/../../../src/" . str_replace('\\', DIRECTORY_SEPARATOR, $bundleRoute);
                     $fileroute .= DIRECTORY_SEPARATOR . $target . ".php";
                     if (file_exists($fileroute)) {
                         $found = true;
                         $target = $bundleRoute . $this->namespaceSeparator . $value['targetEntity'];
                     }
                 }
                 if ($found) {
                     //$target = $namespace . $this->namespaceSeparator . 'Entity' . $this->namespaceSeparator . $value['targetEntity'];
                     $meta->associationMappings[$key]['targetEntity'] = $target;
                 } else {
                     $meta->associationMappings[$key]['targetEntity'] = $namespace . $this->namespaceSeparator . 'Model' . $this->namespaceSeparator . 'Entity' . $this->namespaceSeparator . $value['targetEntity'];
                 }
             }
             $metadata[] = $meta;
             $rep->writeEntityRepositoryClass($namespace . $this->namespaceSeparator . 'Model' . $this->namespaceSeparator . 'Repository' . $this->namespaceSeparator . $real . 'Repository', \Raptor\Core\Location::get(\Raptor\Core\Location::SRC));
         }
     }
     $generator = new EntityGenerator();
     $generator->setAnnotationPrefix('');
     // edit: quick fix for No Metadata Classes to process
     $generator->setUpdateEntityIfExists(true);
     // only update if class already exists
     $generator->setRegenerateEntityIfExists(true);
     // this will overwrite the existing classes
     $generator->setGenerateStubMethods(true);
     $generator->setGenerateAnnotations(true);
     //$y=new Doctrine\ORM\Tools\Export\Driver\YamlExporter(__DIR__ . '/Entities/yml');
     //$y->setMetadata($metadata);
     //$y->export();
     $generator->generate($metadata, \Raptor\Core\Location::get(\Raptor\Core\Location::SRC));
 }
开发者ID:williamamed,项目名称:Raptor2,代码行数:87,代码来源:Store.php

示例10: getEntityGenerator

 /**
  * Get entity generator.
  *
  * @return EntityGenerator
  */
 protected static function getEntityGenerator()
 {
     $entityGenerator = new EntityGenerator();
     $entityGenerator->setGenerateAnnotations(true);
     $entityGenerator->setGenerateStubMethods(true);
     $entityGenerator->setRegenerateEntityIfExists(true);
     $entityGenerator->setUpdateEntityIfExists(true);
     $entityGenerator->setNumSpaces(4);
     $entityGenerator->setAnnotationPrefix(self::$annotationPrefix);
     return $entityGenerator;
 }
开发者ID:chalasr,项目名称:doctrine-test-util,代码行数:16,代码来源:EntityCreator.php

示例11: generador

 /**
  * Entidades::generador()
  * 
  * Genera el proceso correspondiente 
  * @param array $metadata
  * @return void
  */
 private function generador($metadata = false)
 {
     $generator = new EntityGenerator();
     $generator->setAnnotationPrefix('');
     // edit: quick fix for No Metadata Classes to process
     $generator->setUpdateEntityIfExists(true);
     // only update if class already exists
     $generator->setRegenerateEntityIfExists(true);
     // this will overwrite the existing classes
     $generator->setGenerateStubMethods(true);
     $generator->setGenerateAnnotations(true);
     $generator->generate($metadata, dirname($this->dirEntidades));
 }
开发者ID:NeuralFramework,项目名称:NeuralPHPv4,代码行数:20,代码来源:Entidades.php


注:本文中的Doctrine\ORM\Tools\EntityGenerator::setAnnotationPrefix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。