Автор: Elliot Levin (elliot@aanet.com.au)
Пример #1
0
 public function __construct(Object\IEntityMap $EntityMap, FunctionToASTConverter $FunctionToASTConverter)
 {
     $this->EntityMap = $EntityMap;
     $this->EntityType = $EntityMap->GetEntityType();
     $this->FunctionToASTConverter = $FunctionToASTConverter;
     $this->Criterion = new Criterion($EntityMap->GetEntityType());
 }
Пример #2
0
 public final function SetEntityMap(IEntityMap $EntityMap = null)
 {
     $this->EntityMap = $EntityMap;
     if ($EntityMap !== null) {
         $this->Accessor->SetEntityType($EntityMap->GetEntityType());
         $this->Identifier = $this->Accessor->GetIdentifier();
     }
 }
Пример #3
0
 /**
  * {@inheritDoc}
  */
 public final function MapPrimaryKeysToIdentities(array $PrimaryKeys)
 {
     $Identities = array_map(function () {
         return $this->EntityMap->Identity();
     }, $PrimaryKeys);
     foreach ($this->IdentityPropertyPrimaryKeyMappings as $Mapping) {
         $Mapping->Revive($PrimaryKeys, $Identities);
     }
     return $Identities;
 }
Пример #4
0
 /**
  * Loads an entity from an identity instance.
  * 
  * @param Object\Identity $Identity The identity of the entity
  * @return object|null
  */
 protected function LoadByIdentity(Object\Identity $Identity)
 {
     $CachedEntity = $this->IdentityMap->GetFromCache($Identity);
     if ($CachedEntity instanceof $this->EntityType) {
         return $CachedEntity;
     }
     $Entity = $this->DomainDatabaseMap->Load(new Base\Object\Request($this->EntityType, $this->EntityMap->GetProperties(), true, new Base\Object\Criteria\MatchesCriterion($Identity)));
     if ($Entity instanceof $this->EntityType) {
         $this->IdentityMap->CacheEntity($Entity, $Identity);
     }
     return $Entity;
 }
Пример #5
0
 /**
  * Adds an entity map to the domain.
  * 
  * @param EntityMap $EntityMap The entity map to add.
  * @return void
  */
 protected final function AddEntityMap(IEntityMap $EntityMap)
 {
     $EntityMap->InititalizeProperties($this);
     $this->EntityMaps[$EntityMap->GetEntityType()] = $EntityMap;
 }
Пример #6
0
 public final function CacheEntity($Entity, Object\Identity $Identity = null)
 {
     $Identity = $Identity ?: $this->EntityMap->Identity($Entity);
     $IdentityHash = $Identity->Hash();
     $this->Cache->Save($IdentityHash, $Entity);
 }