Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.
   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   * Class for exporting path_node data.
  19   *
  20   * @package    tool_lp
  21   * @copyright  2016 Issam Taboubi <issam.taboubi@umontreal.ca>
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  namespace tool_lp\external;
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  use context_system;
  28  
  29  /**
  30   * Class for exporting path_node data.
  31   *
  32   * @copyright  2016 Issam Taboubi <issam.taboubi@umontreal.ca>
  33   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  34   */
  35  class path_node_exporter extends \core\external\exporter {
  36  
  37      /**
  38       * Constructor - saves the persistent object, and the related objects.
  39       *
  40       * @param mixed $data The data.
  41       * @param array $related Array of relateds.
  42       */
  43      public function __construct($data, $related = array()) {
  44          if (!isset($related['context'])) {
  45              // Previous code was automatically using the system context which was not always correct.
  46              // We let developers know that they must fix their code without breaking anything,
  47              // and fallback on the previous behaviour. This should be removed at a later stage: Moodle 3.5.
  48              debugging('Missing related context in path_node_exporter.', DEBUG_DEVELOPER);
  49              $related['context'] = context_system::instance();
  50          }
  51          parent::__construct($data, $related);
  52      }
  53  
  54      /**
  55       * Return the list of properties.
  56       *
  57       * @return array
  58       */
  59      protected static function define_related() {
  60          return [
  61              'context' => 'context'
  62          ];
  63      }
  64  
  65      /**
  66       * Return the list of properties.
  67       *
  68       * @return array
  69       */
  70      protected static function define_properties() {
  71          return [
  72              'id' => [
  73                  'type' => PARAM_INT,
  74                  'null' => NULL_ALLOWED
  75              ],
  76              'name' => [
  77                  'type' => PARAM_TEXT
  78              ],
  79              'first' => [
  80                  'type' => PARAM_BOOL
  81              ],
  82              'last' => [
  83                  'type' => PARAM_BOOL
  84              ],
  85              'position' => [
  86                  'type' => PARAM_INT
  87              ]
  88          ];
  89      }
  90  }