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


PHP ClassMetadata::isAssociationInverseSide方法代码示例

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


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

示例1: getAssociationString

 private function getAssociationString(ClassMetadata $class1, $association)
 {
     $targetClassName = $class1->getAssociationTargetClass($association);
     $class2 = $this->getClassByName($targetClassName);
     $isInverse = $class1->isAssociationInverseSide($association);
     $class1Count = $class1->isCollectionValuedAssociation($association) ? 2 : 1;
     if (null === $class2) {
         return $this->getClassString($class1) . ($isInverse ? '<' : '<>') . '-' . $association . ' ' . ($class1Count > 1 ? '*' : ($class1Count ? '1' : '')) . ($isInverse ? '<>' : '>') . '[' . str_replace('\\', '.', $targetClassName) . ']';
     }
     $class1SideName = $association;
     $class2SideName = '';
     $class2Count = 0;
     $bidirectional = false;
     if ($isInverse) {
         $class2SideName = (string) $class1->getAssociationMappedByTargetField($association);
         if ($class2SideName) {
             $class2Count = $class2->isCollectionValuedAssociation($class2SideName) ? 2 : 1;
             $bidirectional = true;
         }
     } else {
         foreach ($class2->getAssociationNames() as $class2Side) {
             if ($class2->isAssociationInverseSide($class2Side) && $class2->getAssociationMappedByTargetField($class2Side) === $association) {
                 $class2SideName = $class2Side;
                 $class2Count = $class2->isCollectionValuedAssociation($class2SideName) ? 2 : 1;
                 $bidirectional = true;
                 break;
             }
         }
     }
     $this->visitAssociation($targetClassName, $class2SideName);
     return $this->getClassString($class1) . ($bidirectional ? $isInverse ? '<' : '<>' : '') . ($class2SideName ? $class2SideName . ' ' : '') . ($class2Count > 1 ? '*' : ($class2Count ? '1' : '')) . '-' . $class1SideName . ' ' . ($class1Count > 1 ? '*' : ($class1Count ? '1' : '')) . ($bidirectional && $isInverse ? '<>' : '>') . $this->getClassString($class2);
 }
开发者ID:antoinealej,项目名称:TibetWebsite,代码行数:32,代码来源:MetadataGrapher.php

示例2: completeOwningSide

 /**
  * If this is an inverse side association, completes the owning side.
  *
  * @param string        $field
  * @param ClassMetadata $targetClass
  * @param object        $targetObject
  *
  * @return void
  */
 private function completeOwningSide($field, $targetClass, $targetObject)
 {
     // add this object on the owning side as well, for obvious infinite recursion
     // reasons this is only done when called on the inverse side.
     if ($this->cm->isAssociationInverseSide($field)) {
         $mappedByField = $this->cm->getAssociationMappedByTargetField($field);
         $targetMetadata = self::$objectManager->getClassMetadata($targetClass);
         $setter = ($targetMetadata->isCollectionValuedAssociation($mappedByField) ? "add" : "set") . $mappedByField;
         $targetObject->{$setter}($this);
     }
 }
开发者ID:alvarobfdev,项目名称:applog,代码行数:20,代码来源:PersistentObject.php

示例3: getAssocsConfig

 /**
  * @param ClassMetadata $metadata
  * @param array         $assocNames
  *
  * @return array
  */
 private function getAssocsConfig(ClassMetadata $metadata, $assocNames)
 {
     $assocsConfigs = [];
     foreach ($assocNames as $assocName) {
         if (!$metadata->isAssociationInverseSide($assocName)) {
             continue;
         }
         $class = $metadata->getAssociationTargetClass($assocName);
         if ($metadata->isSingleValuedAssociation($assocName)) {
             $nullable = $metadata instanceof ClassMetadataInfo && isset($metadata->discriminatorColumn['nullable']) && $metadata->discriminatorColumn['nullable'];
             $assocsConfigs[$assocName] = ['field_type' => 'A2lix\\AutoFormBundle\\Form\\Type\\AutoFormType', 'data_class' => $class, 'required' => !$nullable];
             continue;
         }
         $assocsConfigs[$assocName] = ['field_type' => 'Symfony\\Component\\Form\\Extension\\Core\\Type\\CollectionType', 'entry_type' => 'A2lix\\AutoFormBundle\\Form\\Type\\AutoFormType', 'entry_options' => ['data_class' => $class], 'allow_add' => true, 'by_reference' => false];
     }
     return $assocsConfigs;
 }
开发者ID:a2lix,项目名称:AutoFormBundle,代码行数:23,代码来源:DoctrineInfo.php

示例4: processAssociationNames

 /**
  * @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata
  * @param                                                    $model
  *
  * @return array
  */
 protected function processAssociationNames(ClassMetadata $metadata, $model)
 {
     $data = array();
     foreach ($metadata->getAssociationNames() as $assocName) {
         $propertyValue = $this->readProperty($model, $assocName);
         if (null === $propertyValue || $metadata->isAssociationInverseSide($assocName)) {
             continue;
         }
         if ($metadata->isSingleValuedAssociation($assocName)) {
             $assocValue = $this->namingStrategy->modelName($propertyValue, $this->getManager()->getClassMetadata(get_class($propertyValue)));
             $assocValue = $this->navigator->accept($this->getVisitor(), $assocValue, 'reference');
             $data[$assocName] = $assocValue;
         } else {
             $data[$assocName] = array();
             foreach ($propertyValue as $value) {
                 $assocValue = $this->namingStrategy->modelName($value, $this->getManager()->getClassMetadata(get_class($value)));
                 $assocValue = $this->navigator->accept($this->getVisitor(), $assocValue, 'reference');
                 $data[$assocName][] = $assocValue;
             }
         }
     }
     return $data;
 }
开发者ID:xijia37,项目名称:fixture-dumper,代码行数:29,代码来源:AbstractGenerator.php


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