Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

   1  <?php
   2  
   3  namespace Packback\Lti1p3;
   4  
   5  use Packback\Lti1p3\Interfaces\ILtiRegistration;
   6  use Packback\Lti1p3\Interfaces\ILtiServiceConnector;
   7  use Packback\Lti1p3\Interfaces\IServiceRequest;
   8  
   9  abstract class LtiAbstractService
  10  {
  11      private $serviceConnector;
  12      private $registration;
  13      private $serviceData;
  14  
  15      public function __construct(
  16          ILtiServiceConnector $serviceConnector,
  17          ILtiRegistration $registration,
  18          array $serviceData)
  19      {
  20          $this->serviceConnector = $serviceConnector;
  21          $this->registration = $registration;
  22          $this->serviceData = $serviceData;
  23      }
  24  
  25      public function getServiceData(): array
  26      {
  27          return $this->serviceData;
  28      }
  29  
  30      public function setServiceData(array $serviceData): self
  31      {
  32          $this->serviceData = $serviceData;
  33  
  34          return $this;
  35      }
  36  
  37      abstract public function getScope(): array;
  38  
  39      protected function makeServiceRequest(IServiceRequest $request): array
  40      {
  41          return $this->serviceConnector->makeServiceRequest(
  42              $this->registration,
  43              $this->getScope(),
  44              $request,
  45          );
  46      }
  47  
  48      protected function getAll(IServiceRequest $request, string $key = null): array
  49      {
  50          return $this->serviceConnector->getAll(
  51              $this->registration,
  52              $this->getScope(),
  53              $request,
  54              $key
  55          );
  56      }
  57  }