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


PHP EntityGenerator::generateEntityClass方法代码示例

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


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

示例1: exportClassMetadata

 /**
  * {@inheritdoc}
  */
 public function exportClassMetadata(ClassMetadataInfo $metadata)
 {
     if (!$this->_entityGenerator) {
         throw new \RuntimeException('For the AnnotationExporter you must set an EntityGenerator instance with the setEntityGenerator() method.');
     }
     $this->_entityGenerator->setGenerateAnnotations(true);
     $this->_entityGenerator->setGenerateStubMethods(false);
     $this->_entityGenerator->setRegenerateEntityIfExists(false);
     $this->_entityGenerator->setUpdateEntityIfExists(false);
     return $this->_entityGenerator->generateEntityClass($metadata);
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:14,代码来源:AnnotationExporter.php

示例2: generateEntityClass

 public function generateEntityClass(ClassMetadataInfo $metadata)
 {
     static::swap();
     $result = parent::generateEntityClass($metadata);
     static::swap();
     return $result;
 }
开发者ID:farafiri,项目名称:class-generator-for-php,代码行数:7,代码来源:InterfaceGenerator.php

示例3: generate

 public function generate($jsonSchema)
 {
     $schema = json_decode($jsonSchema, true);
     if (!isset($schema['type']) && $schema['type'] !== 'object') {
         throw new \RuntimeException("Unable to process the schema");
     }
     if (!isset($schema['title'])) {
         throw new \RuntimeException("title property must be defined");
     }
     // TODO investigate implementation via ClassMetadataBuilder
     $className = $schema['title'];
     $medatadata = new ClassMetadata($this->getNamespace() . '\\' . $className);
     if (isset($schema['properties'])) {
         foreach ($schema['properties'] as $name => $definition) {
             $type = $definition['type'];
             $nullable = isset($schema['required']) ? !in_array($name, $schema['required']) : true;
             $medatadata->mapField(['fieldName' => $name, 'type' => $type, 'nullable' => $nullable, 'options' => []]);
         }
     }
     $filename = sprintf("%s/%s/%s.php", $this->getPath(), join('/', explode('\\', $this->getNamespace())), $className);
     mkdir(dirname($filename), 0777, true);
     $generator = new EntityGenerator();
     $generator->setGenerateAnnotations(true);
     file_put_contents($filename, $generator->generateEntityClass($medatadata));
 }
开发者ID:jeremygiberson,项目名称:js2doctrine,代码行数:25,代码来源:ModelGenerator.php

示例4: generateClass

 /**
  * @return bool
  * @throws \Exception
  */
 public function generateClass()
 {
     $metadata = $this->getMetaData();
     $this->setClassName($metadata->name);
     // setting the namespace
     $metadata->name = $this->getNamespace() . '\\' . $metadata->name;
     //generate the basic class-code
     if (!($this->generatedCode = $this->entityGenerator->generateEntityClass($metadata))) {
         throw new \Exception('Entity class could not be created');
     }
     // TableAnnotation-Update if a Database is given
     if (isset($this->database)) {
         $this->updateTableAnnotation();
     }
     $this->generateUseStatements();
     $this->generateMethods();
     $this->writeFile();
     return true;
 }
开发者ID:kerion,项目名称:zedogenerator,代码行数:23,代码来源:ZeDoMoGenerator.php

示例5: generateEntityClass

 /**
  * {@inheritdoc}
  */
 public function generateEntityClass(ClassMetadataInfo $metadata)
 {
     $code = parent::generateEntityClass($metadata);
     $class = new \ReflectionClass('Doctrine\\ORM\\Tools\\EntityGenerator');
     $spacesProperty = $class->getProperty('spaces');
     $spacesProperty->setAccessible(true);
     $prefixCodeWithSpacesMethod = $class->getMethod('prefixCodeWithSpaces');
     $prefixCodeWithSpacesMethod->setAccessible(true);
     $code = str_replace(array('<constants>'), array($prefixCodeWithSpacesMethod->invoke($this, $this->generateConstant($metadata))), $code);
     return str_replace('<spaces>', $spacesProperty->getValue($this), $code);
 }
开发者ID:bit3,项目名称:contao-doctrine-orm,代码行数:14,代码来源:EntityGenerator.php


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