propagate(LtiRestApiService::singleton()); } /** * @param null $uri * @return mixed|void * @throws \common_exception_NoImplementation */ public function get($uri = null) { throw new \common_exception_NoImplementation(); } /** * End point to get common user uri by lti user id * @throws \common_exception_NotImplemented */ public function getUserId() { try { $parameters = $this->getParameters(); if (!isset($parameters[self::LTI_USER_ID])) { throw new \common_exception_MissingParameter(self::LTI_USER_ID, __FUNCTION__); } if (!isset($parameters[self::LTI_CONSUMER_KEY])) { throw new \common_exception_MissingParameter(self::LTI_CONSUMER_KEY, __FUNCTION__); } $id = $parameters[self::LTI_USER_ID]; $key = $parameters[self::LTI_CONSUMER_KEY]; $data = $this->getCrudService->getUserId($id, $key); if (!$data) { \common_Logger::i('Id ' . $id . ' is not found.'); throw new \common_exception_NotFound('No data found for the given id.'); } $this->returnSuccess($data); } catch (\Exception $e) { \common_Logger::w($e->getMessage()); $this->returnFailure($e); } } /** * Optionally a specific rest controller may declare * aliases for parameters used for the rest communication */ protected function getParametersAliases() { return [ 'user_id' => self::LTI_USER_ID, 'oauth_consumer_key' => self::LTI_CONSUMER_KEY, 'label' => OntologyRdfs::RDFS_LABEL, 'oauth-key' => DataStore::PROPERTY_OAUTH_KEY, 'oauth-secret' => DataStore::PROPERTY_OAUTH_SECRET, 'oauth-callback-url' => DataStore::PROPERTY_OAUTH_CALLBACK, ]; } /** * Return array of required parameters sorted by http method * @return array */ protected function getParametersRequirements() { return []; } }