/**
* Loads all entities that are specified from the given request instance.
*
* @param Object\IRequest $ObjectRequest The request to load
* @return array|object|null Depending on the supplied request, either all the entities are
* returned as an array or the first is returned or null if none are found.
*/
public final function Load(Object\IRequest $ObjectRequest)
{
$EntityType = $ObjectRequest->GetEntityType();
$this->VerifyEntityTypeIsMapped($EntityType);
$RelationalRequest = $this->MapRequest($ObjectRequest);
$ResultRows = $this->Database->Load($RelationalRequest);
$RevivalDataArray = $this->MapRowsToRevivalData($EntityType, $ResultRows);
$RevivedEntities = $this->Domain->ReviveEntities($EntityType, $RevivalDataArray);
if ($ObjectRequest->IsSingleEntity()) {
return count($RevivedEntities) > 0 ? reset($RevivedEntities) : null;
} else {
return $RevivedEntities;
}
}