Author: Elliot Levin (elliot@aanet.com.au)
Esempio n. 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());
 }
Esempio n. 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();
     }
 }
Esempio n. 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;
 }
Esempio n. 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;
 }
Esempio n. 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;
 }
Esempio n. 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);
 }