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 401 and 402] [Versions 401 and 403]

   1  <?php
   2  
   3  namespace IMSGlobal\LTI\ToolProvider\MediaType;
   4  
   5  /**
   6   * Class to represent an LTI Message
   7   *
   8   * @author  Stephen P Vickers <svickers@imsglobal.org>
   9   * @copyright  IMS Global Learning Consortium Inc
  10   * @date  2016
  11   * @version  3.0.0
  12   * @license  GNU Lesser General Public License, version 3 (<http://www.gnu.org/licenses/lgpl.html>)
  13   */
  14  class Message
  15  {
  16  
  17  /**
  18   * Class constructor.
  19   *
  20   * @param Message $message               Message object
  21   * @param array   $capabilitiesOffered   Capabilities offered
  22   */
  23      function __construct($message, $capabilitiesOffered)
  24      {
  25  
  26          $this->message_type = $message->type;
  27          $this->path = $message->path;
  28          $this->enabled_capability = array();
  29          foreach ($message->capabilities as $capability) {
  30              if (in_array($capability, $capabilitiesOffered)) {
  31                  $this->enabled_capability[] = $capability;
  32              }
  33          }
  34          $this->parameter = array();
  35          foreach ($message->constants as $name => $value) {
  36              $parameter = new \stdClass;
  37              $parameter->name = $name;
  38              $parameter->fixed = $value;
  39              $this->parameter[] = $parameter;
  40          }
  41          foreach ($message->variables as $name => $value) {
  42              if (in_array($value, $capabilitiesOffered)) {
  43                  $parameter = new \stdClass;
  44                  $parameter->name = $name;
  45                  $parameter->variable = $value;
  46                  $this->parameter[] = $parameter;
  47              }
  48          }
  49  
  50      }
  51  
  52  }