ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilLTITool.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 use ceLTIc\LTI\Tool;
24 use ceLTIc\LTI\User;
25 
31 class ilLTITool extends Tool
32 {
36  protected ?\ilLogger $logger = null;
37 
42  public function __construct(ilLTIDataConnector $dataConnector)
43  {
44  global $DIC;
45  $this->logger = ilLoggerFactory::getLogger('ltis');
46  // $this->initialize();
47  if (empty($dataConnector)) {
48  $dataConnector = ilLTIDataConnector::getDataConnector();
49  }
50  $this->dataConnector = $dataConnector;
51  // parent::__construct($dataConnector);
52  $this->setParameterConstraint('resource_link_id', true, 50, array('basic-lti-launch-request'));
53  $this->setParameterConstraint('user_id', true, 64, array('basic-lti-launch-request'));
54  $this->setParameterConstraint('roles', true, null, array('basic-lti-launch-request'));
55  $this->setParameterConstraint('lis_person_contact_email_primary', true, 80, array('basic-lti-launch-request'));
56  }
57 
61  protected function onLaunch(): void
62  {
63  // save/update current user
64  if ($this->userResult instanceof User) {
65  $this->logger->debug("onLaunch - user");
66  $this->userResult->save();
67  }
68 
69  if ($this->context instanceof Context) {
70  $this->logger->debug("onLaunch - context");
71  $this->context->save();
72  }
73 
74  if ($this->resourceLink instanceof ResourceLink) {
75  $this->logger->debug("onLaunch - resource");
76  $this->resourceLink->save();
77  }
78  }
79 }
static getLogger(string $a_component_id)
Get component logger.
LTI provider for LTI launch.
__construct(ilLTIDataConnector $dataConnector)
ilLTITool constructor.
onLaunch()
Process a valid launch request.
static getDataConnector(mixed $db=null, string $dbTableNamePrefix='', string $type='')
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
ilLogger $logger
Component logger with individual log levels by component id.