Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402]

   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  #[\AllowDynamicProperties]
  15  class Message
  16  {
  17  
  18  /**
  19   * Class constructor.
  20   *
  21   * @param Message $message               Message object
  22   * @param array   $capabilitiesOffered   Capabilities offered
  23   */
  24      function __construct($message, $capabilitiesOffered)
  25      {
  26  
  27          $this->message_type = $message->type;
  28          $this->path = $message->path;
  29          $this->enabled_capability = array();
  30          foreach ($message->capabilities as $capability) {
  31              if (in_array($capability, $capabilitiesOffered)) {
  32                  $this->enabled_capability[] = $capability;
  33              }
  34          }
  35          $this->parameter = array();
  36          foreach ($message->constants as $name => $value) {
  37              $parameter = new \stdClass;
  38              $parameter->name = $name;
  39              $parameter->fixed = $value;
  40              $this->parameter[] = $parameter;
  41          }
  42          foreach ($message->variables as $name => $value) {
  43              if (in_array($value, $capabilitiesOffered)) {
  44                  $parameter = new \stdClass;
  45                  $parameter->name = $name;
  46                  $parameter->variable = $value;
  47                  $this->parameter[] = $parameter;
  48              }
  49          }
  50  
  51      }
  52  
  53  }