getServiceLocator()->get(ConsumerService::class); } /** * Get common user uri associated to Lti user id * * @param $id string Identifier of LTI user * @param $key string Oauth LTI consumer key * @return array|null * @throws \common_Exception * @throws \tao_models_classes_oauth_Exception */ public function getUserId($id, $key) { $dataStore = new \tao_models_classes_oauth_DataStore(); try { /** @var \core_kernel_classes_Resource $consumerResource */ $consumerResource = $dataStore->findOauthConsumerResource($key); } catch (\tao_models_classes_oauth_Exception $e) { throw new \common_exception_NotFound($e->getMessage()); } /** @var LtiUserService $service */ $service = $this->getServiceLocator()->get(LtiUserService::SERVICE_ID); $userIdentifier = $service->getUserIdentifier($id, $consumerResource); if (is_null($userIdentifier)) { return null; } return [ 'id' => $userIdentifier ]; } public function createFromArray(array $propertiesValues) { if (array_key_exists(OntologyRdfs::RDFS_LABEL, $propertiesValues)) { $label = $propertiesValues[OntologyRdfs::RDFS_LABEL]; } else { $label = ''; } unset($propertiesValues[OntologyRdfs::RDFS_LABEL]); $propertiesValues['classUri'] = ConsumerService::CLASS_URI; $resource = parent::create($label, $this->getRootClass(), $propertiesValues); return $resource; } }