/**
  * Validates and completes the mapping.
  *
  * @param array $mapping The mapping to validate and complete.
  * @throws MappingException
  * @throws InvalidArgumentException
  * @return array The validated and completed mapping.@override
  */
 protected function _validateAndCompleteOneToManyMapping(array $mapping)
 {
     $mapping = $this->_validateAndCompleteAssociationMapping($mapping);
     // OneToMany-side MUST be inverse (must have mappedBy)
     if (!isset($mapping['mappedBy'])) {
         throw MappingException::oneToManyRequiresMappedBy($mapping['fieldName']);
     }
     $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) ? (bool) $mapping['orphanRemoval'] : false;
     $mapping['isCascadeRemove'] = $mapping['orphanRemoval'] ? true : $mapping['isCascadeRemove'];
     if (isset($mapping['orderBy'])) {
         if (!is_array($mapping['orderBy'])) {
             throw new InvalidArgumentException("'orderBy' is expected to be an array, not " . gettype($mapping['orderBy']));
         }
     }
     return $mapping;
 }
 /**
  * Validates & completes a one-to-many association mapping.
  *
  * @param array $mapping The mapping to validate and complete.
  *
  * @return array The validated and completed mapping.
  *
  * @throws MappingException
  * @throws InvalidArgumentException
  */
 protected function _validateAndCompleteOneToManyMapping(array $mapping)
 {
     $mapping = $this->_validateAndCompleteAssociationMapping($mapping);
     // OneToMany-side MUST be inverse (must have mappedBy)
     if (!isset($mapping['mappedBy'])) {
         throw MappingException::oneToManyRequiresMappedBy($mapping['fieldName']);
     }
     $mapping['orphanRemoval'] = isset($mapping['orphanRemoval']) && $mapping['orphanRemoval'];
     $mapping['isCascadeRemove'] = $mapping['orphanRemoval'] || $mapping['isCascadeRemove'];
     $this->assertMappingOrderBy($mapping);
     return $mapping;
 }