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 403]

   1  <?php
   2  
   3  namespace Packback\Lti1p3;
   4  
   5  class LtiDeepLinkResource
   6  {
   7      private $type = 'ltiResourceLink';
   8      private $title;
   9      private $text;
  10      private $url;
  11      private $line_item;
  12      private $icon;
  13      private $thumbnail;
  14      private $custom_params = [];
  15      private $target = 'iframe';
  16  
  17      public static function new(): LtiDeepLinkResource
  18      {
  19          return new LtiDeepLinkResource();
  20      }
  21  
  22      public function getType(): string
  23      {
  24          return $this->type;
  25      }
  26  
  27      public function setType(string $value): LtiDeepLinkResource
  28      {
  29          $this->type = $value;
  30  
  31          return $this;
  32      }
  33  
  34      public function getTitle(): ?string
  35      {
  36          return $this->title;
  37      }
  38  
  39      public function setTitle(?string $value): LtiDeepLinkResource
  40      {
  41          $this->title = $value;
  42  
  43          return $this;
  44      }
  45  
  46      public function getText(): ?string
  47      {
  48          return $this->text;
  49      }
  50  
  51      public function setText(?string $value): LtiDeepLinkResource
  52      {
  53          $this->text = $value;
  54  
  55          return $this;
  56      }
  57  
  58      public function getUrl(): ?string
  59      {
  60          return $this->url;
  61      }
  62  
  63      public function setUrl(?string $value): LtiDeepLinkResource
  64      {
  65          $this->url = $value;
  66  
  67          return $this;
  68      }
  69  
  70      public function getLineItem(): ?LtiLineitem
  71      {
  72          return $this->line_item;
  73      }
  74  
  75      public function setLineItem(?LtiLineitem $value): LtiDeepLinkResource
  76      {
  77          $this->line_item = $value;
  78  
  79          return $this;
  80      }
  81  
  82      public function setIcon(?LtiDeepLinkResourceIcon $icon): LtiDeepLinkResource
  83      {
  84          $this->icon = $icon;
  85  
  86          return $this;
  87      }
  88  
  89      public function getIcon(): ?LtiDeepLinkResourceIcon
  90      {
  91          return $this->icon;
  92      }
  93  
  94      public function setThumbnail(?LtiDeepLinkResourceIcon $thumbnail): LtiDeepLinkResource
  95      {
  96          $this->thumbnail = $thumbnail;
  97  
  98          return $this;
  99      }
 100  
 101      public function getThumbnail(): ?LtiDeepLinkResourceIcon
 102      {
 103          return $this->thumbnail;
 104      }
 105  
 106      public function getCustomParams(): array
 107      {
 108          return $this->custom_params;
 109      }
 110  
 111      public function setCustomParams(array $value): LtiDeepLinkResource
 112      {
 113          $this->custom_params = $value;
 114  
 115          return $this;
 116      }
 117  
 118      public function getTarget(): string
 119      {
 120          return $this->target;
 121      }
 122  
 123      public function setTarget(string $value): LtiDeepLinkResource
 124      {
 125          $this->target = $value;
 126  
 127          return $this;
 128      }
 129  
 130      public function toArray(): array
 131      {
 132          $resource = [
 133              'type' => $this->type,
 134              'title' => $this->title,
 135              'text' => $this->text,
 136              'url' => $this->url,
 137              'presentation' => [
 138                  'documentTarget' => $this->target,
 139              ],
 140          ];
 141          if (!empty($this->custom_params)) {
 142              $resource['custom'] = $this->custom_params;
 143          }
 144          if (isset($this->icon)) {
 145              $resource['icon'] = $this->icon->toArray();
 146          }
 147          if (isset($this->thumbnail)) {
 148              $resource['thumbnail'] = $this->thumbnail->toArray();
 149          }
 150          if ($this->line_item !== null) {
 151              $resource['lineItem'] = [
 152                  'scoreMaximum' => $this->line_item->getScoreMaximum(),
 153                  'label' => $this->line_item->getLabel(),
 154              ];
 155          }
 156  
 157          return $resource;
 158      }
 159  }