コード例 #1
0
 /**
  * @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);
 }
コード例 #2
0
 /**
  * @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);
 }
コード例 #3
0
ファイル: GroupRepository.php プロジェクト: hugutux/booked
 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;
 }
コード例 #4
0
ファイル: UserRepository.php プロジェクト: ksdtech/booked
 /**
  * @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);
     }
 }
コード例 #5
0
ファイル: ScheduleRepository.php プロジェクト: Trideon/gigolo
 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);
 }