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  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * The mod_lti unknown service api called event.
  19   *
  20   * @package    mod_lti
  21   * @copyright  2013 Adrian Greeve <adrian@moodle.com>
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  namespace mod_lti\event;
  26  defined('MOODLE_INTERNAL') || die();
  27  
  28  /**
  29   * The mod_lti unknown service api called event class.
  30   *
  31   * Event for when something happens with an unknown lti service API call.
  32   *
  33   * @package    mod_lti
  34   * @since      Moodle 2.6
  35   * @copyright  2013 Adrian Greeve <adrian@moodle.com>
  36   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  37   */
  38  class unknown_service_api_called extends \core\event\base {
  39  
  40      /** @var \stdClass Data to be used by event observers. */
  41      protected $eventdata;
  42  
  43      /**
  44       * Sets custom data used by event observers.
  45       *
  46       * @param \stdClass $data
  47       */
  48      public function set_message_data(\stdClass $data) {
  49          $this->eventdata = $data;
  50      }
  51  
  52      /**
  53       * Returns custom data for event observers.
  54       *
  55       * @return \stdClass
  56       */
  57      public function get_message_data() {
  58          if ($this->is_restored()) {
  59              throw new \coding_exception('Function get_message_data() can not be used on restored events.');
  60          }
  61          return $this->eventdata;
  62      }
  63  
  64      /**
  65       * Init method.
  66       */
  67      protected function init() {
  68          $this->data['crud'] = 'r';
  69          $this->data['edulevel'] = self::LEVEL_OTHER;
  70          $this->context = \context_system::instance();
  71      }
  72  
  73      /**
  74       * Returns localised description of what happened.
  75       *
  76       * @return string
  77       */
  78      public function get_description() {
  79          return 'An unknown call to a service api was made.';
  80      }
  81  
  82      /**
  83       * Returns localised general event name.
  84       *
  85       * @return string
  86       */
  87      public static function get_name() {
  88          return get_string('ltiunknownserviceapicall', 'mod_lti');
  89      }
  90  
  91      /**
  92       * Does this event replace a legacy event?
  93       *
  94       * @return null|string legacy event name
  95       */
  96      public static function get_legacy_eventname() {
  97          return 'lti_unknown_service_api_call';
  98      }
  99  
 100      /**
 101       * Legacy event data if get_legacy_eventname() is not empty.
 102       *
 103       * @return mixed
 104       */
 105      protected function get_legacy_eventdata() {
 106          return $this->eventdata;
 107      }
 108  
 109  }