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


PHP MappingException::illegalInverseIdentifierAssocation方法代碼示例

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


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

示例1: _validateAndCompleteOneToOneMapping

 /**
  * Validates & completes a one-to-one association mapping.
  *
  * @param array $mapping  The mapping to validate & complete.
  * @throws RuntimeException
  * @throws MappingException
  * @return array The validated & completed mapping.@override
  */
 protected function _validateAndCompleteOneToOneMapping(array $mapping)
 {
     $mapping = $this->_validateAndCompleteAssociationMapping($mapping);
     if (isset($mapping['joinColumns']) && $mapping['joinColumns']) {
         $mapping['isOwningSide'] = true;
     }
     if ($mapping['isOwningSide']) {
         if (!isset($mapping['joinColumns']) || !$mapping['joinColumns']) {
             // Apply default join column
             $mapping['joinColumns'] = array(array('name' => $this->namingStrategy->joinColumnName($mapping['fieldName']), 'referencedColumnName' => $this->namingStrategy->referenceColumnName()));
         }
         $uniqueContraintColumns = array();
         foreach ($mapping['joinColumns'] as &$joinColumn) {
             if ($mapping['type'] === self::ONE_TO_ONE && !$this->isInheritanceTypeSingleTable()) {
                 if (count($mapping['joinColumns']) == 1) {
                     if (!isset($mapping['id']) || !$mapping['id']) {
                         $joinColumn['unique'] = true;
                     }
                 } else {
                     $uniqueContraintColumns[] = $joinColumn['name'];
                 }
             }
             if (empty($joinColumn['name'])) {
                 $joinColumn['name'] = $this->namingStrategy->joinColumnName($mapping['fieldName']);
             }
             if (empty($joinColumn['referencedColumnName'])) {
                 $joinColumn['referencedColumnName'] = $this->namingStrategy->referenceColumnName();
             }
             if ($joinColumn['name'][0] === '`') {
                 $joinColumn['name'] = trim($joinColumn['name'], '`');
                 $joinColumn['quoted'] = true;
             }
             if ($joinColumn['referencedColumnName'][0] === '`') {
                 $joinColumn['referencedColumnName'] = trim($joinColumn['referencedColumnName'], '`');
                 $joinColumn['quoted'] = true;
             }
             $mapping['sourceToTargetKeyColumns'][$joinColumn['name']] = $joinColumn['referencedColumnName'];
             $mapping['joinColumnFieldNames'][$joinColumn['name']] = isset($joinColumn['fieldName']) ? $joinColumn['fieldName'] : $joinColumn['name'];
         }
         if ($uniqueContraintColumns) {
             if (!$this->table) {
                 throw new RuntimeException("ClassMetadataInfo::setTable() has to be called before defining a one to one relationship.");
             }
             $this->table['uniqueConstraints'][$mapping['fieldName'] . "_uniq"] = array('columns' => $uniqueContraintColumns);
         }
         $mapping['targetToSourceKeyColumns'] = array_flip($mapping['sourceToTargetKeyColumns']);
     }
     $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) ? (bool) $mapping['orphanRemoval'] : false;
     $mapping['isCascadeRemove'] = $mapping['orphanRemoval'] ? true : $mapping['isCascadeRemove'];
     if ($mapping['orphanRemoval']) {
         unset($mapping['unique']);
     }
     if (isset($mapping['id']) && $mapping['id'] === true && !$mapping['isOwningSide']) {
         throw MappingException::illegalInverseIdentifierAssocation($this->name, $mapping['fieldName']);
     }
     return $mapping;
 }
開發者ID:alexanderwsp-git,項目名稱:columbus,代碼行數:65,代碼來源:ClassMetadataInfo.php

示例2: _validateAndCompleteOneToOneMapping

 /**
  * Validates & completes a one-to-one association mapping.
  *
  * @param array $mapping  The mapping to validate & complete.
  * @return array The validated & completed mapping.
  * @override
  */
 protected function _validateAndCompleteOneToOneMapping(array $mapping)
 {
     $mapping = $this->_validateAndCompleteAssociationMapping($mapping);
     if (isset($mapping['joinColumns']) && $mapping['joinColumns']) {
         $mapping['isOwningSide'] = true;
     }
     if ($mapping['isOwningSide']) {
         if (!isset($mapping['joinColumns']) || !$mapping['joinColumns']) {
             // Apply default join column
             $mapping['joinColumns'] = array(array('name' => $mapping['fieldName'] . '_id', 'referencedColumnName' => 'id'));
         }
         $uniqueContraintColumns = array();
         foreach ($mapping['joinColumns'] as $key => &$joinColumn) {
             if ($mapping['type'] === self::ONE_TO_ONE) {
                 if (count($mapping['joinColumns']) == 1) {
                     $joinColumn['unique'] = true;
                 } else {
                     $uniqueContraintColumns[] = $joinColumn['name'];
                 }
             }
             if (empty($joinColumn['name'])) {
                 $joinColumn['name'] = $mapping['fieldName'] . '_id';
             }
             if (empty($joinColumn['referencedColumnName'])) {
                 $joinColumn['referencedColumnName'] = 'id';
             }
             $mapping['sourceToTargetKeyColumns'][$joinColumn['name']] = $joinColumn['referencedColumnName'];
             $mapping['joinColumnFieldNames'][$joinColumn['name']] = isset($joinColumn['fieldName']) ? $joinColumn['fieldName'] : $joinColumn['name'];
         }
         if ($uniqueContraintColumns) {
             if (!$this->table) {
                 throw new \RuntimeException("ClassMetadataInfo::setTable() has to be called before defining a one to one relationship.");
             }
             $this->table['uniqueConstraints'][$mapping['fieldName'] . "_uniq"] = array('columns' => $uniqueContraintColumns);
         }
         $mapping['targetToSourceKeyColumns'] = array_flip($mapping['sourceToTargetKeyColumns']);
     }
     //TODO: if orphanRemoval, cascade=remove is implicit!
     $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) ? (bool) $mapping['orphanRemoval'] : false;
     if (isset($mapping['id']) && $mapping['id'] === true && !$mapping['isOwningSide']) {
         throw MappingException::illegalInverseIdentifierAssocation($this->name, $mapping['fieldName']);
     }
     return $mapping;
 }
開發者ID:MarS2806,項目名稱:Zend-Framework--Doctrine-ORM--PHPUnit--Ant--Jenkins-CI--TDD-,代碼行數:51,代碼來源:ClassMetadataInfo.php


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