ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
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 29 of file class.ilLTIConsumerResourceBase.php.

Constructor & Destructor Documentation

◆ __construct()

ilLTIConsumerResourceBase::__construct ( ilLTIConsumerServiceBase  $service)

Class constructor.

Service instance

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

References $service.

74  {
75  $this->service = $service;
76  $this->type = 'RestService';
77  $this->id = '';
78  $this->template = '';
79  $this->variables = array();
80  $this->formats = array();
81  $this->methods = array();
82  $this->params = array();
83  }
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 146 of file class.ilLTIConsumerResourceBase.php.

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

Referenced by ilLTIConsumerGradeServiceScores\execute().

146  : ?object
147  {
148  $token = $this->getService()->checkTool();
149  $permittedScopes = $this->getService()->getPermittedScopes();
150  if (empty($scopes) || empty(array_intersect($permittedScopes, $scopes))) {
151  $token = null;
152  }
153  return $token;
154  }
$scopes
Definition: ltitoken.php:96
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$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 96 of file class.ilLTIConsumerResourceBase.php.

References $formats.

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

◆ getMethods()

ilLTIConsumerResourceBase::getMethods ( )

Get the resource methods.

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

References $methods.

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

◆ getService()

ilLTIConsumerResourceBase::getService ( )

Get the resource's service.

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

References $service.

Referenced by checkTool().

113  {
114  return $this->service;
115  }
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 88 of file class.ilLTIConsumerResourceBase.php.

References $template.

Referenced by parseTemplate().

88  : string
89  {
90  return $this->template;
91  }
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 120 of file class.ilLTIConsumerResourceBase.php.

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

Referenced by ilLTIConsumerGradeServiceScores\execute().

120  : array
121  {
122  if (empty($this->params)) {
123  $this->params = array();
124  if (!empty($_SERVER['PATH_INFO'])) {
125  $path = explode('/', $this->service->getResourcePath());
126  $template = preg_replace('/\([0-9a-zA-Z_\-,\/]+\)/', '', $this->getTemplate());
127  $parts = explode('/', $template);
128  for ($i = 0; $i < count($parts); $i++) {
129  //if ((substr($parts[$i], 0, 1) == '{') && (substr($parts[$i], -1) == '}')) {
130  if ((str_starts_with($parts[$i], '{')) && (str_ends_with($parts[$i], '}'))) {
131  $value = '';
132  if ($i < count($path)) {
133  $value = $path[$i];
134  }
135  $this->params[substr($parts[$i], 1, -1)] = $value;
136  }
137  }
138  }
139  }
140  return $this->params;
141  }
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:61
string $template
Template for this resource.
$path
Definition: ltiservices.php:29
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
getTemplate()
Get the resource template.
+ 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 59 of file class.ilLTIConsumerResourceBase.php.

Referenced by getFormats().

◆ $id

string ilLTIConsumerResourceBase::$id
protected

ID for this resource.

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

◆ $methods

array ilLTIConsumerResourceBase::$methods
protected

HTTP actions supported by this resource.

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

Referenced by getMethods().

◆ $params

array ilLTIConsumerResourceBase::$params
protected

Template variables parsed from the resource template.

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

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

◆ $service

ilLTIConsumerServiceBase ilLTIConsumerResourceBase::$service
private

Service associated with this resource.

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

Referenced by __construct(), and getService().

◆ $template

string ilLTIConsumerResourceBase::$template
protected

Template for this resource.

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

Referenced by getTemplate().

◆ $type

string ilLTIConsumerResourceBase::$type
protected

Type for this resource.

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

◆ $variables

array ilLTIConsumerResourceBase::$variables
protected

Custom parameter substitution variables associated with this resource.

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

◆ HTTP_DELETE

const ilLTIConsumerResourceBase::HTTP_DELETE = 'DELETE'

HTTP Delete method.

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

◆ HTTP_GET

const ilLTIConsumerResourceBase::HTTP_GET = 'GET'

HTTP Get method.

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

◆ HTTP_POST

const ilLTIConsumerResourceBase::HTTP_POST = 'POST'

HTTP Post method.

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

◆ HTTP_PUT

const ilLTIConsumerResourceBase::HTTP_PUT = 'PUT'

HTTP Put method.

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


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