Автор: Elliot Levin (elliot@aanet.com.au)
Пример #1
0
 /**
  * Adds a property mapping to the entity relation map.
  * 
  * @param IDataPropertyColumnMapping|IEntityPropertyToOneRelationMapping|ICollectionPropertyToManyRelationMapping $PropertyMapping
  * @throws MappingException If the property mapping is not
  */
 private function AddPropertyMapping(IPropertyMapping $PropertyMapping)
 {
     $ProperyIdentifier = $PropertyMapping->GetProperty()->GetIdentifier();
     if ($PropertyMapping instanceof IDataPropertyColumnMapping) {
         $this->DataPropertyColumnMappings[$ProperyIdentifier] = $PropertyMapping;
         $this->MappedReviveColumns = array_merge($this->MappedReviveColumns, $PropertyMapping->GetReviveColumns());
         $this->MappedPersistColumns = array_merge($this->MappedPersistColumns, $PropertyMapping->GetPersistColumns());
         if ($PropertyMapping->IsIdentityPrimaryKeyMapping()) {
             $this->AddIdentityPrimaryKeyMapping($PropertyMapping);
         }
     } else {
         if ($PropertyMapping instanceof IEntityPropertyToOneRelationMapping) {
             $this->EntityPropertyToOneRelationMappings[$ProperyIdentifier] = $PropertyMapping;
         } else {
             if ($PropertyMapping instanceof ICollectionPropertyToManyRelationMapping) {
                 $this->CollectionPropertyToManyRelationMappings[$ProperyIdentifier] = $PropertyMapping;
             } else {
                 throw new MappingException('Supplied property mapping must be of type %s, %s or %s: %s given', IDataPropertyColumnMapping::IDataPropertyColumnMappingType, IEntityPropertyToOneRelationMapping::IEntityPropertyToOneRelationMappingType, ICollectionPropertyToManyRelationMapping::ICollectionPropertyToManyRelationMappingType, get_class($PropertyMapping));
             }
         }
     }
     $this->MappedProperties[$ProperyIdentifier] = $PropertyMapping->GetProperty();
     $this->PropertyMappings[$ProperyIdentifier] = $PropertyMapping;
 }