public function __construct(Object\IEntityMap $EntityMap, FunctionToASTConverter $FunctionToASTConverter) { $this->EntityMap = $EntityMap; $this->EntityType = $EntityMap->GetEntityType(); $this->FunctionToASTConverter = $FunctionToASTConverter; $this->Criterion = new Criterion($EntityMap->GetEntityType()); }
public final function SetEntityMap(IEntityMap $EntityMap = null) { $this->EntityMap = $EntityMap; if ($EntityMap !== null) { $this->Accessor->SetEntityType($EntityMap->GetEntityType()); $this->Identifier = $this->Accessor->GetIdentifier(); } }
/** * {@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; }
/** * 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; }
/** * 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; }
public final function CacheEntity($Entity, Object\Identity $Identity = null) { $Identity = $Identity ?: $this->EntityMap->Identity($Entity); $IdentityHash = $Identity->Hash(); $this->Cache->Save($IdentityHash, $Entity); }