/** * @param $command SqlCommand * @return User */ private function Load($command) { $reader = ServiceLocator::GetDatabase()->Query($command); if ($row = $reader->GetRow()) { $userId = $row[ColumnNames::USER_ID]; $emailPreferences = $this->LoadEmailPreferences($userId); $permissions = $this->LoadPermissions($userId); $groups = $this->LoadGroups($userId); $user = User::FromRow($row); $user->WithEmailPreferences($emailPreferences); $user->WithPermissions($permissions); $user->WithGroups($groups); $this->LoadAttributes($userId, $user); if ($user->IsGroupAdmin()) { $ownedGroups = $this->LoadOwnedGroups($userId); $user->WithOwnedGroups($ownedGroups); } $preferences = $this->LoadPreferences($userId); $user->WithPreferences($preferences); $user->WithDefaultSchedule($row[ColumnNames::DEFAULT_SCHEDULE_ID]); $this->_cache->Add($userId, $user); return $user; } else { return User::Null(); } }