Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 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  declare(strict_types=1);
  18  
  19  namespace core_reportbuilder\external;
  20  
  21  use renderer_base;
  22  use core\external\exporter;
  23  
  24  /**
  25   * Custom report menu cards exporter class
  26   *
  27   * @package     core_reportbuilder
  28   * @copyright   2021 David Matamoros <davidmc@moodle.com>
  29   * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  30   */
  31  class custom_report_menu_cards_exporter extends exporter {
  32  
  33      /**
  34       * Return a list of objects that are related to the exporter
  35       *
  36       * @return array
  37       */
  38      protected static function define_related(): array {
  39          return [
  40              'menucards' => 'array[]',
  41          ];
  42      }
  43  
  44      /**
  45       * Return the list of additional properties for read structure and export
  46       *
  47       * @return array[]
  48       */
  49      protected static function define_other_properties(): array {
  50          return [
  51              'menucards' => [
  52                  'type' => [
  53                      'name' => [
  54                          'type' => PARAM_TEXT,
  55                          'optional' => true,
  56                      ],
  57                      'key' => [
  58                          'type' => PARAM_TEXT,
  59                          'optional' => true,
  60                      ],
  61                      'items' => [
  62                          'type' => [
  63                              'name' => [
  64                                  'type' => PARAM_TEXT,
  65                              ],
  66                              'identifier' => [
  67                                  'type' => PARAM_TEXT,
  68                              ],
  69                              'title' => [
  70                                  'type' => PARAM_TEXT,
  71                              ],
  72                              'action' => [
  73                                  'type' => PARAM_TEXT,
  74                              ],
  75                              'disabled' => [
  76                                  'type' => PARAM_BOOL,
  77                                  'optional' => true,
  78                                  'default' => false,
  79                              ],
  80                          ],
  81                          'optional' => true,
  82                          'multiple' => true,
  83                      ],
  84                  ],
  85                  'optional' => true,
  86                  'multiple' => true,
  87              ],
  88          ];
  89      }
  90  
  91      /**
  92       * Get the additional values to inject while exporting
  93       *
  94       * @param renderer_base $output
  95       * @return array
  96       */
  97      protected function get_other_values(renderer_base $output): array {
  98          return [
  99              'menucards' => $this->related['menucards']
 100          ];
 101      }
 102  }