當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ClassMetadata::mapEmbedded方法代碼示例

本文整理匯總了PHP中Doctrine\ORM\Mapping\ClassMetadata::mapEmbedded方法的典型用法代碼示例。如果您正苦於以下問題:PHP ClassMetadata::mapEmbedded方法的具體用法?PHP ClassMetadata::mapEmbedded怎麽用?PHP ClassMetadata::mapEmbedded使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\ORM\Mapping\ClassMetadata的用法示例。


在下文中一共展示了ClassMetadata::mapEmbedded方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getMetadata

 /**
  * @return ClassMetadata
  */
 public static function getMetadata()
 {
     $metadata = new ClassMetadata(static::class);
     $metadata->setIdentifier(['id']);
     $metadata->mapField(['fieldName' => 'id']);
     $metadata->mapField(['fieldName' => 'a']);
     $metadata->mapField(['fieldName' => 'b']);
     $metadata->mapField(['fieldName' => 'c']);
     $metadata->mapEmbedded(['fieldName' => 'd', 'class' => DummyEmbeddable::class, 'columnPrefix' => 'd']);
     $metadata->mapManyToOne(['fieldName' => 'parent', 'targetEntity' => self::class, 'inversedBy' => 'children']);
     $metadata->mapOneToMany(['fieldName' => 'children', 'targetEntity' => self::class, 'mappedBy' => 'parent']);
     $metadata->wakeupReflection(new RuntimeReflectionService());
     return $metadata;
 }
開發者ID:mihai-stancu,項目名稱:serializer,代碼行數:17,代碼來源:DummyEntity.php

示例2: remapActions

 private function remapActions(ClassMetadata $metadata, ClassMetadataFactory $metadataFactory)
 {
     $fieldName = 'actions';
     unset($metadata->fieldMappings[$fieldName]);
     unset($metadata->embeddedClasses[$fieldName]);
     // Re-map the embeddable
     $mapping = ['fieldName' => $fieldName, 'class' => $this->actionsClass, 'columnPrefix' => null];
     $metadata->mapEmbedded($mapping);
     // Remove the existing inlined fields
     foreach ($metadata->fieldMappings as $name => $fieldMapping) {
         if (isset($fieldMapping['declaredField']) && $fieldMapping['declaredField'] === $fieldName) {
             unset($metadata->fieldMappings[$name]);
             unset($metadata->fieldNames[$fieldMapping['columnName']]);
         }
     }
     // Re-inline the embeddable
     $embeddableMetadata = $metadataFactory->getMetadataFor($this->actionsClass);
     $metadata->inlineEmbeddable($fieldName, $embeddableMetadata);
 }
開發者ID:gbelmm,項目名稱:ACL,代碼行數:19,代碼來源:ACLMetadataLoader.php

示例3: addNestedEmbeddedClasses

 /**
  * Adds nested embedded classes metadata to a parent class.
  *
  * @param ClassMetadata $subClass    Sub embedded class metadata to add nested embedded classes metadata from.
  * @param ClassMetadata $parentClass Parent class to add nested embedded classes metadata to.
  * @param string        $prefix      Embedded classes' prefix to use for nested embedded classes field names.
  */
 private function addNestedEmbeddedClasses(ClassMetadata $subClass, ClassMetadata $parentClass, $prefix)
 {
     foreach ($subClass->embeddedClasses as $property => $embeddableClass) {
         if (isset($embeddableClass['inherited'])) {
             continue;
         }
         $embeddableMetadata = $this->getMetadataFor($embeddableClass['class']);
         $parentClass->mapEmbedded(array('fieldName' => $prefix . '.' . $property, 'class' => $embeddableMetadata->name, 'columnPrefix' => $embeddableClass['columnPrefix'], 'declaredField' => $embeddableClass['declaredField'] ? $prefix . '.' . $embeddableClass['declaredField'] : $prefix, 'originalField' => $embeddableClass['originalField'] ?: $property));
     }
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:17,代碼來源:ClassMetadataFactory.php

示例4: testWakeupReflectionWithEmbeddableAndStaticReflectionService

 public function testWakeupReflectionWithEmbeddableAndStaticReflectionService()
 {
     $classMetadata = new ClassMetadata('Doctrine\\Tests\\ORM\\Mapping\\TestEntity1');
     $classMetadata->mapEmbedded(array('fieldName' => 'test', 'class' => 'Doctrine\\Tests\\ORM\\Mapping\\TestEntity1', 'columnPrefix' => false));
     $field = array('fieldName' => 'test.embeddedProperty', 'type' => 'string', 'originalClass' => 'Doctrine\\Tests\\ORM\\Mapping\\TestEntity1', 'declaredField' => 'test', 'originalField' => 'embeddedProperty');
     $classMetadata->mapField($field);
     $classMetadata->wakeupReflection(new StaticReflectionService());
     $this->assertEquals(array('test' => null, 'test.embeddedProperty' => null), $classMetadata->getReflectionProperties());
 }
開發者ID:selimcr,項目名稱:servigases,代碼行數:9,代碼來源:ClassMetadataTest.php


注:本文中的Doctrine\ORM\Mapping\ClassMetadata::mapEmbedded方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。