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


PHP ClassMetadata::getAssociationMapping方法代码示例

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


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

示例1: getAssociationMapping

 /** {@inheritdoc} */
 public function getAssociationMapping($name)
 {
     if (!$this->classMetadata->hasAssociation($name)) {
         throw new MetadataException("Association '{$name}' not found in class '{$this->getClass()}'.");
     }
     return $this->classMetadata->getAssociationMapping($name);
 }
开发者ID:mike227,项目名称:n-forms,代码行数:8,代码来源:ClassMetadata.php

示例2: test_custom_region_gets_set_on_the_meta_data_on_build

 public function test_custom_region_gets_set_on_the_meta_data_on_build()
 {
     $cache = $this->factory('READ_ONLY', 'custom_region');
     $cache->build();
     $mapping = $this->metadata->getAssociationMapping($this->field);
     $this->assertEquals('custom_region', $mapping['cache']['region']);
 }
开发者ID:guiwoda,项目名称:fluent,代码行数:7,代码来源:AssociationCacheTest.php

示例3: testClassMetadataInstanceSerialization

 public function testClassMetadataInstanceSerialization()
 {
     $cm = new ClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsUser');
     // Test initial state
     $this->assertTrue(count($cm->getReflectionProperties()) == 0);
     $this->assertTrue($cm->reflClass instanceof \ReflectionClass);
     $this->assertEquals('Doctrine\\Tests\\Models\\CMS\\CmsUser', $cm->name);
     $this->assertEquals('Doctrine\\Tests\\Models\\CMS\\CmsUser', $cm->rootEntityName);
     $this->assertEquals(array(), $cm->subClasses);
     $this->assertEquals(array(), $cm->parentClasses);
     // Customize state
     $cm->setSubclasses(array("One", "Two", "Three"));
     $cm->setParentClasses(array("UserParent"));
     $cm->setCustomRepositoryClass("UserRepository");
     $cm->setDiscriminatorColumn(array('name' => 'disc', 'type' => 'integer'));
     $cm->mapOneToOne(array('fieldName' => 'phonenumbers', 'targetEntity' => 'Bar', 'mappedBy' => 'foo'));
     $this->assertTrue($cm->getAssociationMapping('phonenumbers') instanceof \Doctrine\ORM\Mapping\OneToOneMapping);
     $this->assertEquals(1, count($cm->associationMappings));
     $serialized = serialize($cm);
     $cm = unserialize($serialized);
     // Check state
     $this->assertTrue(count($cm->getReflectionProperties()) > 0);
     $this->assertTrue($cm->reflClass instanceof \ReflectionClass);
     $this->assertEquals('Doctrine\\Tests\\Models\\CMS\\CmsUser', $cm->name);
     $this->assertEquals('UserParent', $cm->rootEntityName);
     $this->assertEquals(array('One', 'Two', 'Three'), $cm->subClasses);
     $this->assertEquals(array('UserParent'), $cm->parentClasses);
     $this->assertEquals('UserRepository', $cm->getCustomRepositoryClass());
     $this->assertEquals(array('name' => 'disc', 'type' => 'integer'), $cm->discriminatorColumn);
     $this->assertTrue($cm->getAssociationMapping('phonenumbers') instanceof \Doctrine\ORM\Mapping\OneToOneMapping);
     $this->assertEquals(1, count($cm->associationMappings));
     $oneOneMapping = $cm->getAssociationMapping('phonenumbers');
     $this->assertEquals('phonenumbers', $oneOneMapping->getSourceFieldName());
     $this->assertEquals('Doctrine\\Tests\\Models\\CMS\\Bar', $oneOneMapping->getTargetEntityName());
 }
开发者ID:jackbravo,项目名称:doctrine,代码行数:35,代码来源:ClassMetadataTest.php

示例4: getAssociationMapping

 /**
  * @param string $association
  * @return array
  * @throws InvalidAssociationException
  */
 protected function getAssociationMapping($association)
 {
     try {
         return $this->metadata->getAssociationMapping($association);
     } catch (MappingException $e) {
         throw InvalidAssociationException::associationNotExist($this->entity, $association, $e);
     }
 }
开发者ID:librette,项目名称:doctrine,代码行数:13,代码来源:WrappedEntity.php

示例5: isIgnoredRelation

 /**
  * {@inheritdoc}
  */
 public function isIgnoredRelation(ClassMetadata $metadata, $associationName)
 {
     $mapping = $metadata->getAssociationMapping($associationName);
     if (!$mapping['isOwningSide'] || !($mapping['type'] & ClassMetadata::TO_ONE)) {
         return false;
     }
     return $associationName === 'workflowItem' || $associationName === 'workflowStep';
 }
开发者ID:ramunasd,项目名称:platform,代码行数:11,代码来源:WorkflowExclusionProvider.php

示例6: getForeignPropertyMeta

 /**
  * Gibt das Property für eine Objekt-Fremd-Beziehung zurück
  *
  * dies ist z.B. bei der ManyToOne Seite möglich
  * @return Psc\CMS\EntityPropertyMeta
  */
 public function getForeignPropertyMeta(EntityMeta $foreignEntity)
 {
     throw new \Psc\Code\NotImplementedException();
     $foreignField = \Psc\Inflector::create()->propertyName($foreignEntity->getGClass()->getClassName());
     //var_dump($foreignEntity->getClassMetadata()->associationMappings);
     //var_dump($this->classMetadata->associationMappings);
     //var_dump($this->classMetadata->getFieldForColumn($foreignField));
     $mapping = $this->classMetadata->getAssociationMapping();
     //var_dump($mapping);
     return $this->getPropertyMeta($mapping);
 }
开发者ID:pscheit,项目名称:psc-cms,代码行数:17,代码来源:EntityMeta.php

示例7: isIgnoredRelation

 /**
  * {@inheritdoc}
  */
 public function isIgnoredRelation(ClassMetadata $metadata, $associationName)
 {
     if ($metadata->name !== 'Oro\\Bundle\\AttachmentBundle\\Entity\\Attachment') {
         return false;
     }
     $mapping = $metadata->getAssociationMapping($associationName);
     if (!$mapping['isOwningSide'] || !($mapping['type'] & ClassMetadata::MANY_TO_ONE)) {
         return false;
     }
     return $associationName === ExtendHelper::buildAssociationName($mapping['targetEntity']);
 }
开发者ID:Maksold,项目名称:platform,代码行数:14,代码来源:AttachmentExclusionProvider.php

示例8: getAssociationMapping

 public static function getAssociationMapping(ClassMetadata $classMetadata, $name, $type = NULL)
 {
     if (!$classMetadata->hasAssociation($name)) {
         return NULL;
     }
     $mapping = $classMetadata->getAssociationMapping($name);
     $type = $type ? (array) $type : NULL;
     if ($type === NULL || in_array($mapping['type'], $type, TRUE)) {
         return $mapping;
     }
     return NULL;
 }
开发者ID:librette,项目名称:doctrine-forms,代码行数:12,代码来源:MetadataHelpers.php

示例9: isIgnoredRelation

 /**
  * {@inheritdoc}
  */
 public function isIgnoredRelation(ClassMetadata $metadata, $associationName)
 {
     if ($metadata->name !== 'Oro\\Bundle\\TrackingBundle\\Entity\\TrackingVisit') {
         return false;
     }
     $mapping = $metadata->getAssociationMapping($associationName);
     if (!$mapping['isOwningSide'] || !($mapping['type'] & ClassMetadata::MANY_TO_ONE)) {
         return false;
     }
     $identifierEventAssociationName = ExtendHelper::buildAssociationName($mapping['targetEntity'], IdentifierEventExtension::ASSOCIATION_KIND);
     return $associationName === $identifierEventAssociationName;
 }
开发者ID:Maksold,项目名称:platform,代码行数:15,代码来源:IdentifierEventExclusionProvider.php

示例10: isIgnoredRelation

 /**
  * {@inheritdoc}
  */
 public function isIgnoredRelation(ClassMetadata $metadata, $associationName)
 {
     if (!$this->configManager->hasConfig($metadata->name, $associationName)) {
         return false;
     }
     $groups = $this->configManager->getEntityConfig('grouping', $metadata->name)->get('groups');
     if (empty($groups) || !in_array(ActivityScope::GROUP_ACTIVITY, $groups, true)) {
         return false;
     }
     $mapping = $metadata->getAssociationMapping($associationName);
     if (!$mapping['isOwningSide'] || !($mapping['type'] & ClassMetadata::MANY_TO_MANY)) {
         return false;
     }
     $activityAssociationName = ExtendHelper::buildAssociationName($mapping['targetEntity'], ActivityScope::ASSOCIATION_KIND);
     return $associationName === $activityAssociationName;
 }
开发者ID:Maksold,项目名称:platform,代码行数:19,代码来源:ActivityExclusionProvider.php

示例11: extendLoadMetadataForClass

 /**
  * Merge DoctrineClassMetadata and DataAuditClassMetadata
  * @param  DoctrineClassMetadata $doctrineClassMetadata
  * @return null|ClassMetadata
  * @throws \InvalidArgumentException
  */
 public function extendLoadMetadataForClass(DoctrineClassMetadata $doctrineClassMetadata)
 {
     if ($doctrineClassMetadata->isMappedSuperclass || !($classMetadata = $this->loadMetadataForClass($doctrineClassMetadata->getReflectionClass()))) {
         return null;
     }
     /** @var $property PropertyMetadata */
     foreach ($classMetadata->propertyMetadata as $name => $property) {
         if ($doctrineClassMetadata->isInheritedField($name) || isset($doctrineClassMetadata->associationMappings[$property->name]['inherited'])) {
             unset($classMetadata->propertyMetadata[$name]);
             continue;
         }
         if ($doctrineClassMetadata->isCollectionValuedAssociation($name)) {
             $property->isCollection = true;
             $targetMapping = $doctrineClassMetadata->getAssociationMapping($name);
             if (!method_exists($targetMapping['targetEntity'], $property->method)) {
                 throw new \InvalidArgumentException(sprintf("Method %s in Class %s is not defined. Class must implement " . "a method '__toString' or configure getMethod with Versioned annotation", $property->method, $targetMapping['targetEntity']));
             }
         }
     }
     return $classMetadata;
 }
开发者ID:Maksold,项目名称:platform,代码行数:27,代码来源:AnnotationDriver.php

示例12: getAssociationMetadata

 private function getAssociationMetadata(ClassMetadata $meta, $associationName)
 {
     if (!$meta->hasAssociation($associationName)) {
         return FALSE;
     }
     $association = $meta->getAssociationMapping($associationName);
     if (!$association & ClassMetadata::TO_ONE) {
         return FALSE;
     }
     return $association;
 }
开发者ID:librette,项目名称:doctrine-forms,代码行数:11,代码来源:ToOneHandler.php

示例13: createAssociationField

 /**
  * @param FormBuilder $form
  * @param ClassMetadata $metaData
  * @param string $fieldName
  */
 public function createAssociationField($form, $metaData, $fieldName)
 {
     $formField = new SelectField(array());
     $formField->setLabel($this->translateName($fieldName));
     $formField->setName($fieldName);
     $mapping = $metaData->getAssociationMapping($fieldName);
     $required = false;
     $targetEntityName = $metaData->getAssociationTargetClass($fieldName);
     $targetEntity = $this->doctrineService->getRepository($targetEntityName);
     if ($metaData->isCollectionValuedAssociation($fieldName)) {
         $formField->setMultiple(true);
         $formField->setRequired(false);
     } else {
         foreach ($mapping['joinColumns'] as $joinColumn) {
             if (!$joinColumn['nullable']) {
                 $required = true;
                 break;
             }
         }
         $formField->setRequired($required);
     }
     $collection = static::entityToCollection($targetEntity->findAll(), !$formField->isMultiple());
     $formField->setCollection($collection);
     $form->addField($formField);
 }
开发者ID:itephp,项目名称:doctrine-bridge,代码行数:30,代码来源:DoctrineDesigner.php

示例14: addDoctrineAssociations

 /**
  * @param EntityMetadata $entityMetadata
  * @param ClassMetadata $classMetadata
  */
 protected function addDoctrineAssociations(EntityMetadata $entityMetadata, ClassMetadata $classMetadata)
 {
     $associations = array_diff($classMetadata->getAssociationNames(), $this->getDeletedFields($classMetadata->name));
     foreach ($associations as $fieldName) {
         $fieldMetadata = $this->metadataFactory->createFieldMetadata(['field_name' => $fieldName], $classMetadata->getAssociationMapping($fieldName));
         $entityMetadata->addFieldMetadata($fieldMetadata);
     }
 }
开发者ID:startupz,项目名称:platform-1,代码行数:12,代码来源:MetadataBuilder.php

示例15: getFromClause

 private function getFromClause(ClassMetadata $metadataActivity, ClassMetadata $metadataPerson)
 {
     $associationMapping = $metadataActivity->getAssociationMapping('person');
     return $metadataActivity->getTableName() . ' JOIN ' . $metadataPerson->getTableName() . ' ON ' . $metadataPerson->getTableName() . '.' . $associationMapping['joinColumns'][0]['referencedColumnName'] . ' = ' . $associationMapping['joinColumns'][0]['name'];
 }
开发者ID:Chill-project,项目名称:Activity,代码行数:5,代码来源:TimelineActivityProvider.php


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