/** * @param int $resourceId * @return BookableResource */ public function LoadById($resourceId) { if (!$this->_cache->Exists($resourceId)) { $resource = $this->LoadResource(new GetResourceByIdCommand($resourceId)); $this->_cache->Add($resourceId, $resource); } return $this->_cache->Get($resourceId); }
public function LoadById($groupId) { if ($this->_cache->Exists($groupId)) { return $this->_cache->Get($groupId); } $group = null; $db = ServiceLocator::GetDatabase(); $reader = $db->Query(new GetGroupByIdCommand($groupId)); if ($row = $reader->GetRow()) { $group = new Group($row[ColumnNames::GROUP_ID], $row[ColumnNames::GROUP_NAME]); $group->WithGroupAdmin($row[ColumnNames::GROUP_ADMIN_GROUP_ID]); } $reader->Free(); $reader = $db->Query(new GetAllGroupUsersCommand($groupId, AccountStatus::ACTIVE)); while ($row = $reader->GetRow()) { $group->WithUser($row[ColumnNames::USER_ID]); } $reader->Free(); $reader = $db->Query(new GetAllGroupPermissionsCommand($groupId)); while ($row = $reader->GetRow()) { $group->WithPermission($row[ColumnNames::RESOURCE_ID]); } $reader->Free(); $reader = $db->Query(new GetAllGroupRolesCommand($groupId)); while ($row = $reader->GetRow()) { $group->WithRole($row[ColumnNames::ROLE_ID]); } $reader->Free(); $this->_cache->Add($groupId, $group); return $group; }
/** * @param int|CustomAttributeCategory $category * @return array|CustomAttribute[] */ public function GetByCategory($category) { if (!$this->cache->Exists($category)) { $reader = ServiceLocator::GetDatabase()->Query(new GetAttributesByCategoryCommand($category)); $attributes = array(); while ($row = $reader->GetRow()) { $attributes[] = CustomAttribute::FromRow($row); } $this->cache->Add($category, $attributes); } return $this->cache->Get($category); }
/** * @param int $userId * @return User */ public function LoadById($userId) { if (!$this->_cache->Exists($userId)) { $command = new GetUserByIdCommand($userId); return $this->Load($command); } else { return $this->_cache->Get($userId); } }
public function LoadById($scheduleId) { if (!$this->_cache->Exists($scheduleId)) { $schedule = null; $reader = ServiceLocator::GetDatabase()->Query(new GetScheduleByIdCommand($scheduleId)); if ($row = $reader->GetRow()) { $schedule = Schedule::FromRow($row); } $reader->Free(); return $schedule; } return $this->_cache->Get($scheduleId); }