ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilLTIConsumerResourceBase Class Reference
+ Inheritance diagram for ilLTIConsumerResourceBase:
+ Collaboration diagram for ilLTIConsumerResourceBase:

Public Member Functions

 __construct (ilLTIConsumerServiceBase $service)
 Class constructor. More...
 
 getTemplate ()
 Get the resource template. More...
 
 getFormats ()
 Get the resource media types. More...
 
 getMethods ()
 Get the resource methods. More...
 
 getService ()
 Get the resource's service. More...
 
 checkTool (array $scopes=array())
 Check to make sure the request is valid. More...
 

Data Fields

const HTTP_POST = 'POST'
 HTTP Post method. More...
 
const HTTP_GET = 'GET'
 HTTP Get method. More...
 
const HTTP_PUT = 'PUT'
 HTTP Put method. More...
 
const HTTP_DELETE = 'DELETE'
 HTTP Delete method. More...
 

Protected Member Functions

 parseTemplate ()
 Parse the template for variables. More...
 

Protected Attributes

string $type
 Type for this resource. More...
 
string $id
 ID for this resource. More...
 
string $template
 Template for this resource. More...
 
array $variables
 Custom parameter substitution variables associated with this resource. More...
 
array $formats
 Media types supported by this resource. More...
 
array $methods
 HTTP actions supported by this resource. More...
 
array $params
 Template variables parsed from the resource template. More...
 

Private Attributes

ilLTIConsumerServiceBase $service
 Service associated with this resource. More...
 

Detailed Description

Definition at line 30 of file class.ilLTIConsumerResourceBase.php.

Constructor & Destructor Documentation

◆ __construct()

ilLTIConsumerResourceBase::__construct ( ilLTIConsumerServiceBase  $service)

Class constructor.

Service instance

Reimplemented in ilLTIConsumerGradeServiceLineItem, ilLTIConsumerGradeServiceLineItems, ilLTIConsumerGradeServiceResults, and ilLTIConsumerGradeServiceScores.

Definition at line 74 of file class.ilLTIConsumerResourceBase.php.

75 {
76 $this->service = $service;
77 $this->type = 'RestService';
78 $this->id = '';
79 $this->template = '';
80 $this->variables = array();
81 $this->formats = array();
82 $this->methods = array();
83 $this->params = array();
84 }
ilLTIConsumerServiceBase $service
Service associated with this resource.

References $service.

Member Function Documentation

◆ checkTool()

ilLTIConsumerResourceBase::checkTool ( array  $scopes = array())

Check to make sure the request is valid.

Definition at line 147 of file class.ilLTIConsumerResourceBase.php.

147 : ?object
148 {
149 $token = $this->getService()->checkTool();
150 $permittedScopes = $this->getService()->getPermittedScopes();
151 if (empty($scopes) || empty(array_intersect($permittedScopes, $scopes))) {
152 $token = null;
153 }
154 return $token;
155 }
getService()
Get the resource's service.
$scopes
Definition: ltitoken.php:96
$token
Definition: xapitoken.php:70

References $scopes, $token, and getService().

Referenced by ilLTIConsumerGradeServiceScores\execute().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFormats()

ilLTIConsumerResourceBase::getFormats ( )

Get the resource media types.

Definition at line 97 of file class.ilLTIConsumerResourceBase.php.

97 : array
98 {
99 return $this->formats;
100 }
array $formats
Media types supported by this resource.

References $formats.

◆ getMethods()

ilLTIConsumerResourceBase::getMethods ( )

Get the resource methods.

Definition at line 105 of file class.ilLTIConsumerResourceBase.php.

105 : array
106 {
107 return $this->methods;
108 }
array $methods
HTTP actions supported by this resource.

References $methods.

◆ getService()

ilLTIConsumerResourceBase::getService ( )

Get the resource's service.

Definition at line 113 of file class.ilLTIConsumerResourceBase.php.

References $service.

Referenced by checkTool().

+ Here is the caller graph for this function:

◆ getTemplate()

ilLTIConsumerResourceBase::getTemplate ( )

Get the resource template.

Definition at line 89 of file class.ilLTIConsumerResourceBase.php.

89 : string
90 {
91 return $this->template;
92 }
string $template
Template for this resource.

References $template.

Referenced by parseTemplate().

+ Here is the caller graph for this function:

◆ parseTemplate()

ilLTIConsumerResourceBase::parseTemplate ( )
protected

Parse the template for variables.

Definition at line 121 of file class.ilLTIConsumerResourceBase.php.

121 : array
122 {
123 if (empty($this->params)) {
124 $this->params = array();
125 if (!empty($_SERVER['PATH_INFO'])) {
126 $path = explode('/', $this->service->getResourcePath());
127 $template = preg_replace('/\‍([0-9a-zA-Z_\-,\/]+\‍)/', '', $this->getTemplate());
128 $parts = explode('/', $template);
129 for ($i = 0; $i < count($parts); $i++) {
130 //if ((substr($parts[$i], 0, 1) == '{') && (substr($parts[$i], -1) == '}')) {
131 if ((str_starts_with($parts[$i], '{')) && (str_ends_with($parts[$i], '}'))) {
132 $value = '';
133 if ($i < count($path)) {
134 $value = $path[$i];
135 }
136 $this->params[substr($parts[$i], 1, -1)] = $value;
137 }
138 }
139 }
140 }
141 return $this->params;
142 }
array $params
Template variables parsed from the resource template.
getTemplate()
Get the resource template.
$path
Definition: ltiservices.php:30
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26

References $_SERVER, $params, $parts, $path, $template, and getTemplate().

Referenced by ilLTIConsumerGradeServiceScores\execute().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $formats

array ilLTIConsumerResourceBase::$formats
protected

Media types supported by this resource.

Definition at line 60 of file class.ilLTIConsumerResourceBase.php.

Referenced by getFormats().

◆ $id

string ilLTIConsumerResourceBase::$id
protected

ID for this resource.

Definition at line 51 of file class.ilLTIConsumerResourceBase.php.

◆ $methods

array ilLTIConsumerResourceBase::$methods
protected

HTTP actions supported by this resource.

Definition at line 63 of file class.ilLTIConsumerResourceBase.php.

Referenced by getMethods().

◆ $params

array ilLTIConsumerResourceBase::$params
protected

Template variables parsed from the resource template.

Definition at line 66 of file class.ilLTIConsumerResourceBase.php.

Referenced by ilLTIConsumerGradeServiceScores\execute(), and parseTemplate().

◆ $service

◆ $template

string ilLTIConsumerResourceBase::$template
protected

Template for this resource.

Definition at line 54 of file class.ilLTIConsumerResourceBase.php.

Referenced by getTemplate(), and parseTemplate().

◆ $type

string ilLTIConsumerResourceBase::$type
protected

Type for this resource.

Definition at line 48 of file class.ilLTIConsumerResourceBase.php.

◆ $variables

array ilLTIConsumerResourceBase::$variables
protected

Custom parameter substitution variables associated with this resource.

Definition at line 57 of file class.ilLTIConsumerResourceBase.php.

◆ HTTP_DELETE

const ilLTIConsumerResourceBase::HTTP_DELETE = 'DELETE'

HTTP Delete method.

Definition at line 42 of file class.ilLTIConsumerResourceBase.php.

Referenced by ilLTIConsumerGradeServiceLineItem\__construct().

◆ HTTP_GET

const ilLTIConsumerResourceBase::HTTP_GET = 'GET'

◆ HTTP_POST

const ilLTIConsumerResourceBase::HTTP_POST = 'POST'

HTTP Post method.

Definition at line 33 of file class.ilLTIConsumerResourceBase.php.

Referenced by ilLTIConsumerGradeServiceLineItems\__construct().

◆ HTTP_PUT

const ilLTIConsumerResourceBase::HTTP_PUT = 'PUT'

HTTP Put method.

Definition at line 39 of file class.ilLTIConsumerResourceBase.php.

Referenced by ilLTIConsumerGradeServiceLineItem\__construct().


The documentation for this class was generated from the following file: