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


PHP ClassMetadata::mapOneToMany方法代碼示例

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


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

示例1: mapTranslatable

 /**
  * Add mapping data to a translatable entity.
  *
  * @param ClassMetadata $metadata
  */
 private function mapTranslatable(ClassMetadata $metadata)
 {
     // In the case A -> B -> TranslatableInterface, B might not have mapping defined as it
     // is probably defined in A, so in that case, we just return.
     if (!isset($this->configs[$metadata->name])) {
         return;
     }
     $metadata->mapOneToMany(array('fieldName' => 'translations', 'targetEntity' => $this->configs[$metadata->name]['translation']['model'], 'mappedBy' => 'translatable', 'fetch' => ClassMetadataInfo::FETCH_EXTRA_LAZY, 'indexBy' => 'locale', 'cascade' => array('persist', 'merge', 'remove'), 'orphanRemoval' => true));
 }
開發者ID:Onnit,項目名稱:Sylius,代碼行數:14,代碼來源:ORMTranslatableListener.php

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

示例3: mapTranslatable

 /**
  * Add mapping data to a translatable entity.
  *
  * @param ClassMetadata $metadata
  */
 private function mapTranslatable(ClassMetadata $metadata)
 {
     $className = $metadata->name;
     try {
         $resourceMetadata = $this->registry->getByClass($className);
     } catch (\InvalidArgumentException $exception) {
         return;
     }
     if (!$resourceMetadata->hasParameter('translation')) {
         return;
     }
     $translationResourceMetadata = $this->registry->get($resourceMetadata->getAlias() . '_translation');
     $metadata->mapOneToMany(['fieldName' => 'translations', 'targetEntity' => $translationResourceMetadata->getClass('model'), 'mappedBy' => 'translatable', 'fetch' => ClassMetadataInfo::FETCH_EXTRA_LAZY, 'indexBy' => 'locale', 'cascade' => ['persist', 'merge', 'remove'], 'orphanRemoval' => true]);
 }
開發者ID:ahmadrabie,項目名稱:Sylius,代碼行數:19,代碼來源:ORMTranslatableListener.php

示例4: mapTranslatable

 private function mapTranslatable(ClassMetadata $classMetadata)
 {
     if (!$classMetadata->hasAssociation('translations')) {
         $classMetadata->mapOneToMany(['fieldName' => 'translations', 'mappedBy' => 'translatable', 'indexBy' => 'locale', 'cascade' => ['persist', 'merge', 'remove'], 'fetch' => $this->translatableFetchMode, 'targetEntity' => $classMetadata->getReflectionClass()->getMethod('getTranslationEntityClass')->invoke(null), 'orphanRemoval' => true]);
     }
 }
開發者ID:jdachtera,項目名稱:DoctrineBehaviors,代碼行數:6,代碼來源:TranslatableSubscriber.php

示例5: mapTranslatable

 /**
  * Add mapping data to a translatable entity
  *
  * @param ClassMetadata $mapping
  * @return void
  */
 private function mapTranslatable(ClassMetadata $mapping)
 {
     $metadata = $this->getTranslatableMetadata($mapping->name);
     if (!$mapping->hasAssociation($metadata->translations->name)) {
         $targetMetadata = $this->getTranslatableMetadata($metadata->targetEntity);
         $mapping->mapOneToMany(array('fieldName' => $metadata->translations->name, 'targetEntity' => $metadata->targetEntity, 'mappedBy' => $targetMetadata->translatable->name, 'fetch' => ClassMetadataInfo::FETCH_EXTRA_LAZY, 'indexBy' => $targetMetadata->locale->name, 'cascade' => array('persist', 'merge', 'remove'), 'orphanRemoval' => true));
     }
 }
開發者ID:prezent,項目名稱:doctrine-translatable,代碼行數:14,代碼來源:TranslatableListener.php

示例6: mapTranslatable

 /**
  * @param ClassMetadata $classMetadata
  */
 private function mapTranslatable(ClassMetadata $classMetadata)
 {
     if (!$classMetadata->hasAssociation('translations')) {
         $classMetadata->mapOneToMany(array('fieldName' => 'translations', 'mappedBy' => 'translatable', 'indexBy' => 'locale', 'cascade' => array('all'), 'fetch' => $this->translatableFetchMode, 'targetEntity' => $this->getClassName($classMetadata), 'orphanRemoval' => true));
     }
 }
開發者ID:jewome62,項目名稱:DoctrineIntl,代碼行數:9,代碼來源:TranslatableSubscriber.php

示例7: setPostVoteAssociation

 /**
  * Adds post vote association mapping to User class
  * 
  * @param ClassMetadata $classMetadata
  */
 protected function setPostVoteAssociation(ClassMetadata $classMetadata)
 {
     $classMetadata->mapOneToMany(array('targetEntity' => 'Valantir\\ForumBundle\\Entity\\PostVote', 'fieldName' => 'postsVotes', 'mappedBy' => 'user'));
 }
開發者ID:Valantir007,項目名稱:ForumBundle,代碼行數:9,代碼來源:MappingListener.php

示例8: updateTranslatableMetadata

 protected function updateTranslatableMetadata(ClassMetadata $metadata)
 {
     if (!$metadata->hasAssociation('translations')) {
         $metadata->mapOneToMany(['fieldName' => 'translations', 'mappedBy' => 'translatable', 'indexBy' => 'locale', 'cascade' => ['persist', 'merge', 'remove'], 'fetch' => $this->translatableFetchMode, 'targetEntity' => $metadata->name . 'Translation', 'orphanRemoval' => true]);
     }
 }
開發者ID:nkt,項目名稱:translate-bundle,代碼行數:6,代碼來源:SchemaEventSubscriber.php

示例9: mapUserAccessible

 private function mapUserAccessible(ClassMetadata $classMetadata)
 {
     if (!$classMetadata->hasAssociation('userAccesses')) {
         $classMetadata->mapOneToMany(['fieldName' => 'userAccesses', 'mappedBy' => 'userAccessible', 'cascade' => ['persist', 'merge', 'remove'], 'targetEntity' => $classMetadata->name . 'UserAccess', 'orphanRemoval' => true]);
     }
 }
開發者ID:Myps,項目名稱:security,代碼行數:6,代碼來源:UserAccessibleListener.php

示例10: mapTranslatable

 private function mapTranslatable(ClassMetadata $classMetadata)
 {
     if (!$classMetadata->hasAssociation('translations')) {
         $classMetadata->mapOneToMany(['fieldName' => 'translations', 'mappedBy' => 'translatable', 'cascade' => ['persist', 'merge', 'remove'], 'targetEntity' => $classMetadata->name . 'Translation']);
     }
 }
開發者ID:nvdnkpr,項目名稱:DoctrineBehaviors,代碼行數:6,代碼來源:TranslatableListener.php

示例11: setServerMetaData

 private function setServerMetaData(ClassMetadata $metadata)
 {
     $metadata->mapOneToMany(['targetEntity' => ServerModule::class, 'fieldName' => 'modules', 'mappedBy' => 'server']);
 }
開發者ID:lfgamers,項目名稱:discord-base-bot,代碼行數:4,代碼來源:ORMMappingSubscriber.php

示例12: mapTranslatable

 /**
  * Map Translatable
  *
  * @param ClassMetadata $classMetadata
  */
 protected function mapTranslatable(ClassMetadata $classMetadata)
 {
     if (!$classMetadata->hasAssociation('translations')) {
         $classMetadata->mapOneToMany(['fieldName' => 'translations', 'mappedBy' => 'translatable', 'indexBy' => 'locale', 'cascade' => ['persist', 'merge', 'remove'], 'targetEntity' => $classMetadata->name . 'Translation', 'orphanRemoval' => true]);
     }
 }
開發者ID:smart85,項目名稱:UnifikDoctrineBehaviorsBundle,代碼行數:11,代碼來源:TranslatableListener.php

示例13: mapTranslatable

 /**
  * Add mapping data to a translatable entity
  *
  * @param ClassMetadata $mapping
  * @return void
  */
 private function mapTranslatable(ClassMetadata $mapping)
 {
     $metadata = $this->getTranslatableMetadata($mapping->name);
     if (!$mapping->hasAssociation($metadata->translations->name)) {
         $targetMetadata = $this->getTranslatableMetadata($metadata->targetEntity);
         $mapping->mapOneToMany(array('fieldName' => $metadata->translations->name, 'targetEntity' => $metadata->targetEntity, 'mappedBy' => $targetMetadata->translatable->name, 'fetch' => ClassMetadataInfo::FETCH_LAZY, 'indexBy' => $targetMetadata->locale->name, 'cascade' => array('persist', 'merge', 'remove'), 'orphanRemoval' => true));
         $cacheMap = array('usage' => constant('Doctrine\\ORM\\Mapping\\ClassMetadata::CACHE_USAGE_' . 'NONSTRICT_READ_WRITE'));
         $mapping->enableAssociationCache($metadata->translations->name, $cacheMap);
     }
 }
開發者ID:beyzakokcan,項目名稱:ojs,代碼行數:16,代碼來源:TranslatableCacheListener.php

示例14: loadMetadataForClass

 /**
  * Loads the metadata for the specified class into the provided container.
  */
 public function loadMetadataForClass($className, ClassMetadata $metadata)
 {
     $annotClass = new \Addendum\ReflectionAnnotatedClass($className);
     // Evaluate DoctrineEntity annotation
     if (($entityAnnot = $annotClass->getAnnotation('DoctrineEntity')) === false) {
         throw DoctrineException::updateMe("{$className} is no entity.");
     }
     $metadata->setCustomRepositoryClass($entityAnnot->repositoryClass);
     // Evaluate DoctrineTable annotation
     if ($tableAnnot = $annotClass->getAnnotation('DoctrineTable')) {
         $metadata->setPrimaryTable(array('name' => $tableAnnot->name, 'schema' => $tableAnnot->schema, 'catalog' => $tableAnnot->catalog));
     }
     // Evaluate DoctrineInheritanceType annotation
     if ($inheritanceTypeAnnot = $annotClass->getAnnotation('DoctrineInheritanceType')) {
         $metadata->setInheritanceType($inheritanceTypeAnnot->value);
     }
     // Evaluate DoctrineDiscriminatorColumn annotation
     if ($discrColumnAnnot = $annotClass->getAnnotation('DoctrineDiscriminatorColumn')) {
         $metadata->setDiscriminatorColumn(array('name' => $discrColumnAnnot->name, 'type' => $discrColumnAnnot->type, 'length' => $discrColumnAnnot->length));
     }
     // Evaluate DoctrineDiscriminatorMap annotation
     if ($discrValueAnnot = $annotClass->getAnnotation('DoctrineDiscriminatorValue')) {
         $metadata->setDiscriminatorValue($discrValueAnnot->value);
     }
     // Evaluate DoctrineSubClasses annotation
     if ($subClassesAnnot = $annotClass->getAnnotation('DoctrineSubClasses')) {
         $metadata->setSubclasses($subClassesAnnot->value);
     }
     // Evaluate DoctrineChangeTrackingPolicy annotation
     if ($changeTrackingAnnot = $annotClass->getAnnotation('DoctrineChangeTrackingPolicy')) {
         $metadata->setChangeTrackingPolicy($changeTrackingAnnot->value);
     }
     // Evaluate annotations on properties/fields
     foreach ($annotClass->getProperties() as $property) {
         if ($metadata->hasField($property->getName())) {
             continue;
         }
         $mapping = array();
         $mapping['fieldName'] = $property->getName();
         // Check for DoctrineJoinColummn/DoctrineJoinColumns annotations
         $joinColumns = array();
         if ($joinColumnAnnot = $property->getAnnotation('DoctrineJoinColumn')) {
             $joinColumns[] = array('name' => $joinColumnAnnot->name, 'referencedColumnName' => $joinColumnAnnot->referencedColumnName, 'unique' => $joinColumnAnnot->unique, 'nullable' => $joinColumnAnnot->nullable, 'onDelete' => $joinColumnAnnot->onDelete, 'onUpdate' => $joinColumnAnnot->onUpdate);
         } else {
             if ($joinColumnsAnnot = $property->getAnnotation('DoctrineJoinColumns')) {
                 $joinColumns = $joinColumnsAnnot->value;
             }
         }
         // Field can only be annotated with one of: DoctrineColumn,
         // DoctrineOneToOne, DoctrineOneToMany, DoctrineManyToOne, DoctrineManyToMany
         if ($columnAnnot = $property->getAnnotation('DoctrineColumn')) {
             if ($columnAnnot->type == null) {
                 throw DoctrineException::updateMe("Missing type on property " . $property->getName());
             }
             $mapping['type'] = $columnAnnot->type;
             $mapping['length'] = $columnAnnot->length;
             $mapping['nullable'] = $columnAnnot->nullable;
             if ($idAnnot = $property->getAnnotation('DoctrineId')) {
                 $mapping['id'] = true;
             }
             if ($generatedValueAnnot = $property->getAnnotation('DoctrineGeneratedValue')) {
                 $metadata->setIdGeneratorType($generatedValueAnnot->strategy);
             }
             $metadata->mapField($mapping);
             // Check for SequenceGenerator/TableGenerator definition
             if ($seqGeneratorAnnot = $property->getAnnotation('DoctrineSequenceGenerator')) {
                 $metadata->setSequenceGeneratorDefinition(array('sequenceName' => $seqGeneratorAnnot->sequenceName, 'allocationSize' => $seqGeneratorAnnot->allocationSize, 'initialValue' => $seqGeneratorAnnot->initialValue));
             } else {
                 if ($tblGeneratorAnnot = $property->getAnnotation('DoctrineTableGenerator')) {
                     throw new DoctrineException("DoctrineTableGenerator not yet implemented.");
                 }
             }
         } else {
             if ($oneToOneAnnot = $property->getAnnotation('DoctrineOneToOne')) {
                 $mapping['targetEntity'] = $oneToOneAnnot->targetEntity;
                 $mapping['joinColumns'] = $joinColumns;
                 $mapping['mappedBy'] = $oneToOneAnnot->mappedBy;
                 $mapping['cascade'] = $oneToOneAnnot->cascade;
                 $metadata->mapOneToOne($mapping);
             } else {
                 if ($oneToManyAnnot = $property->getAnnotation('DoctrineOneToMany')) {
                     $mapping['mappedBy'] = $oneToManyAnnot->mappedBy;
                     $mapping['targetEntity'] = $oneToManyAnnot->targetEntity;
                     $mapping['cascade'] = $oneToManyAnnot->cascade;
                     $metadata->mapOneToMany($mapping);
                 } else {
                     if ($manyToOneAnnot = $property->getAnnotation('DoctrineManyToOne')) {
                         $mapping['joinColumns'] = $joinColumns;
                         $mapping['cascade'] = $manyToOneAnnot->cascade;
                         $mapping['targetEntity'] = $manyToOneAnnot->targetEntity;
                         $metadata->mapManyToOne($mapping);
                     } else {
                         if ($manyToManyAnnot = $property->getAnnotation('DoctrineManyToMany')) {
                             $joinTable = array();
                             if ($joinTableAnnot = $property->getAnnotation('DoctrineJoinTable')) {
                                 $joinTable = array('name' => $joinTableAnnot->name, 'schema' => $joinTableAnnot->schema, 'catalog' => $joinTableAnnot->catalog, 'joinColumns' => $joinTableAnnot->joinColumns, 'inverseJoinColumns' => $joinTableAnnot->inverseJoinColumns);
                             }
//.........這裏部分代碼省略.........
開發者ID:jackbravo,項目名稱:doctrine,代碼行數:101,代碼來源:AnnotationDriver.php


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