Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 402] [Versions 311 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  }