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 field data.
  19   *
  20   * @package    mod_data
  21   * @copyright  2017 Juan Leyva <juan@moodle.com>
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  namespace mod_data\external;
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  use core\external\exporter;
  28  
  29  /**
  30   * Class for exporting field data.
  31   *
  32   * @copyright  2017 Juan Leyva <juan@moodle.com>
  33   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  34   */
  35  class field_exporter extends exporter {
  36  
  37      protected static function define_properties() {
  38  
  39          $properties = array(
  40              'id' => array(
  41                  'type' => PARAM_INT,
  42                  'description' => 'Field id.',
  43              ),
  44              'dataid' => array(
  45                  'type' => PARAM_INT,
  46                  'description' => 'The field type of the content.',
  47                  'default' => 0,
  48              ),
  49              'type' => array(
  50                  'type' => PARAM_PLUGIN,
  51                  'description' => 'The field type.',
  52              ),
  53              'name' => array(
  54                  'type' => PARAM_TEXT,
  55                  'description' => 'The field name.',
  56              ),
  57              'description' => array(
  58                  'type' => PARAM_RAW,
  59                  'description' => 'The field description.',
  60              ),
  61              'required' => array(
  62                  'type' => PARAM_BOOL,
  63                  'description' => 'Whether is a field required or not.',
  64                  'default' => 0,
  65              ),
  66          );
  67          // Field possible parameters.
  68          for ($i = 1; $i <= 10; $i++) {
  69              $properties["param$i"] = array(
  70                  'type' => PARAM_RAW,
  71                  'description' => 'Field parameters',
  72                  'null' => NULL_ALLOWED,
  73              );
  74          }
  75  
  76          return $properties;
  77      }
  78  
  79      protected static function define_related() {
  80          // Context is required for text formatting.
  81          return array(
  82              'context' => 'context',
  83          );
  84      }
  85  }