ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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

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

References $service.

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.

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.

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

Referenced by ilLTIConsumerGradeServiceScores\execute().

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  }
$scopes
Definition: ltitoken.php:99
$token
Definition: xapitoken.php:70
getService()
Get the resource's service.
+ 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.

References $formats.

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

◆ getMethods()

ilLTIConsumerResourceBase::getMethods ( )

Get the resource methods.

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

References $methods.

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

◆ getService()

ilLTIConsumerResourceBase::getService ( )

Get the resource's service.

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

References $service.

Referenced by checkTool().

114  {
115  return $this->service;
116  }
ilLTIConsumerServiceBase $service
Service associated with this resource.
+ Here is the caller graph for this function:

◆ getTemplate()

ilLTIConsumerResourceBase::getTemplate ( )

Get the resource template.

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

References $template.

Referenced by parseTemplate().

89  : string
90  {
91  return $this->template;
92  }
string $template
Template for this resource.
+ 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.

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

Referenced by ilLTIConsumerGradeServiceScores\execute().

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.
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64
string $template
Template for this resource.
$path
Definition: ltiservices.php:32
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
getTemplate()
Get the resource template.
$i
Definition: metadata.php:41
+ 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

ilLTIConsumerServiceBase ilLTIConsumerResourceBase::$service
private

Service associated with this resource.

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

Referenced by __construct(), and getService().

◆ $template

string ilLTIConsumerResourceBase::$template
protected

Template for this resource.

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

Referenced by getTemplate().

◆ $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.

◆ HTTP_GET

const ilLTIConsumerResourceBase::HTTP_GET = 'GET'

HTTP Get method.

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

◆ HTTP_POST

const ilLTIConsumerResourceBase::HTTP_POST = 'POST'

HTTP Post method.

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

◆ HTTP_PUT

const ilLTIConsumerResourceBase::HTTP_PUT = 'PUT'

HTTP Put method.

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


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