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


PHP ClassMetadata::isSingleValuedAssociation方法代码示例

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


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

示例1: isIgnoredRelation

 /**
  * {@inheritdoc}
  */
 protected function isIgnoredRelation(ClassMetadata $metadata, $associationName)
 {
     // skip workflow and collection relations
     if ($this->isWorkflowField($associationName) || !$metadata->isSingleValuedAssociation($associationName)) {
         return true;
     }
     return parent::isIgnoredRelation($metadata, $associationName);
 }
开发者ID:xamin123,项目名称:platform,代码行数:11,代码来源:FieldProvider.php

示例2: findParentMapping

 /**
  * Find the parent object's property which holds the collection entries
  *
  * @param object        $parent   The parent entity.
  * @param ClassMetadata $metaData Metadata of the object that is being created.
  *
  * @return string|boolean The name of the parent mapping field or false if none is found.
  */
 protected function findParentMapping($parent, ClassMetadata $metaData)
 {
     $parentClass = ClassUtils::getClass($parent);
     foreach ($metaData->associationMappings as $mapping) {
         if ($mapping['targetEntity'] == $parentClass && $metaData->isSingleValuedAssociation($mapping['fieldName'])) {
             return $mapping['fieldName'];
         }
     }
     return false;
 }
开发者ID:waifei,项目名称:createphp,代码行数:18,代码来源:DoctrineOrmMapper.php

示例3: isIgnoredRelation

 /**
  * {@inheritdoc}
  */
 public function isIgnoredRelation(ClassMetadata $metadata, $associationName)
 {
     if ($metadata->isSingleValuedAssociation($associationName)) {
         $targetClassName = $metadata->getAssociationTargetClass($associationName);
         $groups = $this->groupingConfigProvider->getConfig($targetClassName)->get('groups');
         if (!empty($groups) && in_array(GroupingScope::GROUP_DICTIONARY, $groups)) {
             return true;
         }
     }
     return false;
 }
开发者ID:xamin123,项目名称:platform,代码行数:14,代码来源:DictionaryExclusionProvider.php

示例4: getAssociationValue

 /** {@inheritdoc} */
 public function getAssociationValue($object, $fieldName)
 {
     if (!$this->hasAssociation($fieldName)) {
         throw new MetadataException("Association '{$fieldName}' not found in class '{$this->getClass()}'.");
     }
     if ($this->classMetadata->isSingleValuedAssociation($fieldName)) {
         $value = $this->classMetadata->getFieldValue($object, $fieldName);
     } else {
         $value = $this->getCollection($object, $fieldName);
     }
     return $value;
 }
开发者ID:mike227,项目名称:n-forms,代码行数:13,代码来源:BaseClassMetadata.php

示例5: getRelation

 /**
  * @param ClassMetadata $meta
  * @param object $entity
  * @param string $field
  * @return bool|object
  */
 private function getRelation(ClassMetadata $meta, $entity, $field)
 {
     if (!$meta->hasAssociation($field) || !$meta->isSingleValuedAssociation($field)) {
         return FALSE;
     }
     // todo: allow access using property or method
     $relation = $meta->getFieldValue($entity, $field);
     if ($relation instanceof Collection) {
         return FALSE;
     }
     if ($relation === NULL) {
         $class = $meta->getAssociationTargetClass($field);
         $relationMeta = $this->mapper->getEntityManager()->getClassMetadata($class);
         $relation = $relationMeta->newInstance();
         $meta->setFieldValue($entity, $field, $relation);
     }
     return $relation;
 }
开发者ID:kuba1999,项目名称:DoctrineForms,代码行数:24,代码来源:ToOne.php

示例6: convertMetadata

 /**
  * @param ClassMetadata $metadata
  * @return JavaScript\Metadata
  */
 private function convertMetadata(ClassMetadata $metadata)
 {
     $meta = new JavaScript\Metadata();
     $meta->originalName = $metadata->getName();
     $meta->namespace = str_replace('\\', '_', $metadata->getReflectionClass()->getNamespaceName());
     $meta->functionName = $metadata->getReflectionClass()->getShortName();
     $parent = $metadata->getReflectionClass()->getParentClass();
     $meta->superFunctionName = $parent ? $parent->getShortName() : 'DBEntity';
     // Convert fields.
     foreach ($metadata->getFieldNames() as $fieldName) {
         $field = new JavaScript\Field();
         $field->name = $fieldName;
         $field->methodName = ucfirst($fieldName);
         $field->type = $this->convertDoctrineType($metadata->getTypeOfField($fieldName));
         $field->isIdentifier = $metadata->isIdentifier($fieldName);
         $meta->fields[] = $field;
     }
     // Convert associations.
     foreach ($metadata->getAssociationNames() as $assocName) {
         $assoc = new JavaScript\Association();
         $assoc->name = $assocName;
         $assoc->methodName = ucfirst($assocName);
         $assoc->isCollection = $metadata->isCollectionValuedAssociation($assocName);
         $assoc->isSingle = $metadata->isSingleValuedAssociation($assocName);
         $assoc->singleName = Inflector::singularize($assoc->methodName);
         $assoc->invertedField = $metadata->getAssociationMappedByTargetField($assocName);
         $targetClass = new \ReflectionClass($metadata->getAssociationTargetClass($assocName));
         $assoc->singleType = $targetClass->getShortName();
         $assoc->type = $assoc->singleType . ($assoc->isCollection ? '[]' : '');
         $meta->associations[] = $assoc;
     }
     return $meta;
 }
开发者ID:CornyPhoenix,项目名称:JsEntitiesBundle,代码行数:37,代码来源:JsEntityConverter.php

示例7: mapValue

 /**
  * @param ClassMetadata $objectMeta
  * @param string        $field
  * @param mixed         $value
  */
 protected function mapValue($om, ClassMetadata $objectMeta, $field, &$value)
 {
     if (!$objectMeta->isSingleValuedAssociation($field)) {
         return;
     }
     $mapping = $objectMeta->getAssociationMapping($field);
     $value = $value ? $om->getReference($mapping['targetEntity'], $value) : null;
 }
开发者ID:RobertjanSchipper,项目名称:Cms,代码行数:13,代码来源:LoggableListener.php

示例8: decodeAssociation

 /**
  * @param ClassMetadata $metaData
  * @param object $entity
  * @param string $key
  * @param mixed $value
  */
 private function decodeAssociation($metaData, $entity, $key, $value)
 {
     if ($metaData->isSingleValuedAssociation($key)) {
         $this->decodeAssociationSingle($metaData, $entity, $key, $value);
     } else {
         //multiple
         $this->decodeAssociationMulti($metaData, $entity, $key, $value);
     }
 }
开发者ID:itephp,项目名称:doctrine-bridge,代码行数:15,代码来源:DoctrineTransformer.php

示例9: buildSelectForUpdateQuery

 /**
  * @param EntityRepository $repository
  * @param ORMMetadata $class
  * @return \Doctrine\ORM\QueryBuilder
  */
 protected function buildSelectForUpdateQuery(EntityRepository $repository, ORMMetadata $class)
 {
     $qb = $repository->createQueryBuilder('e', 'e.id');
     $i = 0;
     foreach ($class->getAssociationMappings() as $assocMapping) {
         if (!$class->isSingleValuedAssociation($assocMapping['fieldName'])) {
             continue;
         }
         $targetClass = $this->entityManager->getClassMetadata($assocMapping['targetEntity']);
         $alias = substr($assocMapping['fieldName'], 0, 1) . $i++;
         $qb->leftJoin('e.' . $assocMapping['fieldName'], $alias)->addSelect($alias);
         // todo: deeper!
     }
     return $qb;
 }
开发者ID:rohlikcz,项目名称:DoctrineSearch,代码行数:20,代码来源:DefaultEntityRiver.php

示例10: getCollection

 /**
  * @param ClassMetadata $meta
  * @param object $entity
  * @param string $field
  * @return Collection
  */
 private function getCollection(ClassMetadata $meta, $entity, $field)
 {
     if (!$meta->hasAssociation($field) || $meta->isSingleValuedAssociation($field)) {
         return FALSE;
     }
     $collection = $meta->getFieldValue($entity, $field);
     if ($collection === NULL) {
         $collection = new ArrayCollection();
         $meta->setFieldValue($entity, $field, $collection);
     }
     return $collection;
 }
开发者ID:kuba1999,项目名称:DoctrineForms,代码行数:18,代码来源:ToMany.php

示例11: mapValue

 /**
  * Maps ids of associations to references
  *
  * @param ClassMetadata $class
  * @param string        $field
  * @param mixed         $value
  */
 protected function mapValue(ClassMetadata $class, $field, &$value)
 {
     if (!$class->isSingleValuedAssociation($field)) {
         return;
     }
     $mapping = $class->getAssociationMapping($field);
     $value = $value ? $this->em->getReference($mapping['targetEntity'], $value) : null;
 }
开发者ID:opifer,项目名称:revisions,代码行数:15,代码来源:RevisionListener.php


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