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 * Course Group exporter. 19 * 20 * @package mod_forum 21 * @copyright 2019 Andrew Nicols <andrew@nicols.co.uk> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace mod_forum\local\exporters; 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 use core\external\exporter; 30 use renderer_base; 31 use stdClass; 32 33 require_once($CFG->dirroot . '/mod/forum/lib.php'); 34 35 /** 36 * Group exporter. 37 * 38 * @copyright 2019 Andrew Nicols <andrew@nicols.co.uk> 39 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 40 */ 41 class group extends exporter { 42 /** @var stdClass $group Group */ 43 private $group; 44 45 /** 46 * Constructor. 47 * 48 * @param stdClass $group The group to export 49 * @param array $related The related data for the export. 50 */ 51 public function __construct(stdClass $group, array $related = []) { 52 $this->group = $group; 53 return parent::__construct([], $related); 54 } 55 56 /** 57 * Return the list of additional properties. 58 * 59 * @return array 60 */ 61 protected static function define_other_properties() { 62 return [ 63 'id' => [ 64 'type' => PARAM_INT, 65 'optional' => true, 66 'default' => null, 67 'null' => NULL_ALLOWED 68 ], 69 'urls' => [ 70 'type' => [ 71 'image' => [ 72 'description' => 'The URL for the group image', 73 'type' => PARAM_URL, 74 'optional' => true, 75 'default' => null, 76 'null' => NULL_ALLOWED 77 ] 78 ], 79 ], 80 ]; 81 } 82 83 /** 84 * Get the additional values to inject while exporting. 85 * 86 * @param renderer_base $output The renderer. 87 * @return array Keys are the property names, values are their values. 88 */ 89 protected function get_other_values(renderer_base $output) { 90 return [ 91 'id' => $group->id, 92 'urls' => [ 93 'image' => $imageurl ? $imageurl->out(false) : null 94 ] 95 ]; 96 } 97 98 /** 99 * Returns a list of objects that are related. 100 * 101 * @return array 102 */ 103 protected static function define_related() { 104 return [ 105 'urlmanager' => 'mod_forum\local\managers\url', 106 'context' => 'context' 107 ]; 108 } 109 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body