Changeset 4792 for trunk/lib/Doctrine

Show
Ignore:
Timestamp:
08/22/08 10:37:03 (5 months ago)
Author:
romanb
Message:

added mapping check to onetomany. corrected test models.

Location:
trunk/lib/Doctrine
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/Doctrine/Association/OneToMany.php

    r4789 r4792  
    6969     
    7070    /** 
     71     * Validates and completed the mapping. 
     72     * 
     73     * @param array $mapping The mapping to validate and complete. 
     74     * @return array The validated and completed mapping. 
     75     * @override 
     76     */ 
     77    protected function _validateAndCompleteMapping(array $mapping) 
     78    { 
     79        $mapping = parent::_validateAndCompleteMapping($mapping); 
     80        // one-side MUST be inverse (must have mappedBy) 
     81        if ( ! isset($mapping['mappedBy'])) { 
     82            throw Doctrine_MappingException::oneToManyRequiresMappedBy($mapping['fieldName']); 
     83        } 
     84         
     85        return $mapping; 
     86    } 
     87     
     88    /** 
    7189     * Whether orphaned elements (removed from the collection) should be deleted. 
    7290     * 
  • trunk/lib/Doctrine/MappingException.php

    r4776 r4792  
    4848        return new self("No mapping found for field '$fieldName'."); 
    4949    } 
     50     
     51    public static function oneToManyRequiresMappedBy($fieldName) 
     52    { 
     53        return new self("OneToMany mapping on field '$fieldName' requires the 'mappedBy' attribute."); 
     54    } 
    5055} 
    5156