當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。