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


PHP EntityGenerator::writeEntityClass方法代码示例

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


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

示例1: writeEntityClass

 /**
  * @param string $className
  * @param string $newClassName
  * @return string
  */
 private function writeEntityClass($className, $newClassName)
 {
     $cmf = new ClassMetadataFactory();
     $em = $this->_getTestEntityManager();
     $cmf->setEntityManager($em);
     $metadata = $cmf->getMetadataFor($className);
     $metadata->namespace = $this->_namespace;
     $metadata->name = $newClassName;
     $metadata->customRepositoryClassName = $newClassName . "Repository";
     $this->_generator->writeEntityClass($metadata, $this->_tmpDir);
     require $this->_tmpDir . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $newClassName) . ".php";
 }
开发者ID:selimcr,项目名称:servigases,代码行数:17,代码来源:EntityRepositoryGeneratorTest.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: testGenerateEntityWithSequenceGenerator

 /**
  * @group DDC-1784
  */
 public function testGenerateEntityWithSequenceGenerator()
 {
     $metadata = new ClassMetadataInfo($this->_namespace . '\\DDC1784Entity');
     $metadata->namespace = $this->_namespace;
     $metadata->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true));
     $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE);
     $metadata->setSequenceGeneratorDefinition(array('sequenceName' => 'DDC1784_ID_SEQ', 'allocationSize' => 1, 'initialValue' => 2));
     $this->_generator->writeEntityClass($metadata, $this->_tmpDir);
     $filename = $this->_tmpDir . DIRECTORY_SEPARATOR . $this->_namespace . DIRECTORY_SEPARATOR . 'DDC1784Entity.php';
     $this->assertFileExists($filename);
     require_once $filename;
     $reflection = new \ReflectionProperty($metadata->name, 'id');
     $docComment = $reflection->getDocComment();
     $this->assertContains('@Id', $docComment);
     $this->assertContains('@Column(name="id", type="integer")', $docComment);
     $this->assertContains('@GeneratedValue(strategy="SEQUENCE")', $docComment);
     $this->assertContains('@SequenceGenerator(sequenceName="DDC1784_ID_SEQ", allocationSize=1, initialValue=2)', $docComment);
 }
开发者ID:naumangcu,项目名称:doctrine2,代码行数:21,代码来源:EntityGeneratorTest.php

示例4: testGenerateEntityWithMultipleInverseJoinColumns

 /**
  * @group DDC-2079
  */
 public function testGenerateEntityWithMultipleInverseJoinColumns()
 {
     $metadata = new ClassMetadataInfo($this->_namespace . '\\DDC2079Entity');
     $metadata->namespace = $this->_namespace;
     $metadata->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true));
     $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE);
     $metadata->mapManyToMany(array('fieldName' => 'centroCustos', 'targetEntity' => 'DDC2079CentroCusto', 'joinTable' => array('name' => 'unidade_centro_custo', 'joinColumns' => array(array('name' => 'idorcamento', 'referencedColumnName' => 'idorcamento'), array('name' => 'idunidade', 'referencedColumnName' => 'idunidade')), 'inverseJoinColumns' => array(array('name' => 'idcentrocusto', 'referencedColumnName' => 'idcentrocusto'), array('name' => 'idpais', 'referencedColumnName' => 'idpais')))));
     $this->_generator->writeEntityClass($metadata, $this->_tmpDir);
     $filename = $this->_tmpDir . DIRECTORY_SEPARATOR . $this->_namespace . DIRECTORY_SEPARATOR . 'DDC2079Entity.php';
     $this->assertFileExists($filename);
     require_once $filename;
     $property = new \ReflectionProperty($metadata->name, 'centroCustos');
     $docComment = $property->getDocComment();
     //joinColumns
     $this->assertContains('@JoinColumn(name="idorcamento", referencedColumnName="idorcamento"),', $docComment);
     $this->assertContains('@JoinColumn(name="idunidade", referencedColumnName="idunidade")', $docComment);
     //inverseJoinColumns
     $this->assertContains('@JoinColumn(name="idcentrocusto", referencedColumnName="idcentrocusto"),', $docComment);
     $this->assertContains('@JoinColumn(name="idpais", referencedColumnName="idpais")', $docComment);
 }
开发者ID:ruian,项目名称:doctrine2,代码行数:23,代码来源:EntityGeneratorTest.php

示例5: generate

 public function generate($parameters)
 {
     if (!$this->isInitialized) {
         throw new \RuntimeException('Entity generator needs to be initialized first in order to generate');
     }
     $moduleName = $this->moduleName;
     $parentClassName = $this->parentClassName;
     $this->classNames = $parameters->classNames;
     $classNames = $this->classNames;
     $outputList = array();
     $metadatas = array();
     foreach ($classNames as $className) {
         if (in_array($className, $this->driver->getAllClassNames())) {
             $classNameWithNamespace = $this->getNamespacedClassName($className);
             $this->namespacedClassNames[$className] = $classNameWithNamespace;
             $realClassNameWithNamespace = $this->composeFullClassName($classNameWithNamespace);
             $realClassName = $this->getClassNameFromNamespacedClassName($classNameWithNamespace);
             $namespace = $this->getNamespaceFromNamespacedClassName($realClassNameWithNamespace, $realClassName);
             $metadata = new \Doctrine\ORM\Mapping\ClassMetadataInfo($className);
             $this->driver->loadMetadataForClass($className, $metadata);
             $metadata = $this->fixMetadata($metadata);
             $outputList[] = array('outputDirectory' => $this->generatedEntityOutputDirectory, 'entityNamespace' => $this->entityNamespace, 'entityName' => $className, 'className' => $realClassName);
             $metadata->name = $realClassNameWithNamespace;
             $metadata->namespace = $namespace;
             $metadatas[] = $metadata;
             echo $namespace . '\\' . $realClassName . '<br>';
         }
     }
     if (count($metadatas) > 0) {
         $this->initGenerator();
         if ($this->parentClassName != null) {
             if (!file_exists($this->generatedEntityOutputDirectory . '/' . $this->parentClassName . '.php')) {
                 $parentMetadata = new \Doctrine\ORM\Mapping\ClassMetadataInfo($this->parentClassName);
                 $parentMetadata->name = $this->composeFullClassName($this->parentClassName);
                 $this->generator->writeEntityClass($parentMetadata, $this->generatedEntityOutputDirectory);
             }
         }
         $this->generator->generate($metadatas, $this->generatedEntityOutputDirectory);
     }
     return $outputList;
 }
开发者ID:bitweb,项目名称:doctrine-entity-generator-module,代码行数:41,代码来源:EntityGeneratorService.php


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