See Release Notes
Long Term Support Release
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 * Contains the course_content_items_exporter class. 19 * 20 * @package core 21 * @subpackage course 22 * @copyright 2020 Jake Dallimore <jrhdallimore@gmail.com> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 namespace core_course\local\exporters; 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 use core\external\exporter; 30 use core_course\local\entity\content_item; 31 32 /** 33 * The course_content_items_exporter class. 34 * 35 * @copyright 2020 Jake Dallimore <jrhdallimore@gmail.com> 36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 37 */ 38 class course_content_items_exporter extends exporter { 39 40 /** @var content_item[] the array of content items. */ 41 private $contentitems; 42 43 /** 44 * The course_content_items_exporter constructor. 45 * 46 * @param array $contentitems the array of \core_course\local\entity\content_item objects to export. 47 * @param array $related any related objects, see define_related for what's expected. 48 */ 49 public function __construct(array $contentitems, array $related) { 50 $this->contentitems = $contentitems; 51 52 parent::__construct([], $related); 53 } 54 55 /** 56 * Return the properties defining this export. 57 * 58 * @return array the array of properties. 59 */ 60 public static function define_properties() { 61 return [ 62 'content_items' => [ 63 'type' => course_content_item_exporter::read_properties_definition(), 64 'multiple' => true 65 ] 66 ]; 67 } 68 69 /** 70 * Generate and return the data for this export. 71 * 72 * @param \renderer_base $output 73 * @return array the array of course content_items 74 */ 75 protected function get_other_values(\renderer_base $output) { 76 77 $contentitemexport = function(content_item $contentitem) use ($output) { 78 $exporter = new course_content_item_exporter( 79 $contentitem, 80 [ 81 'context' => $this->related['context'], 82 'favouriteitems' => $this->related['favouriteitems'], 83 'recommended' => $this->related['recommended'] 84 ] 85 ); 86 return $exporter->export($output); 87 }; 88 89 $exportedcontentitems = array_map($contentitemexport, $this->contentitems); 90 91 return [ 92 'content_items' => $exportedcontentitems 93 ]; 94 } 95 96 /** 97 * Define the list of related objects, used by this exporter. 98 * 99 * @return array the list of related objects. 100 */ 101 protected static function define_related() { 102 return [ 103 'context' => '\context', 104 'favouriteitems' => '\stdClass[]?', 105 'recommended' => '\stdClass[]?' 106 ]; 107 } 108 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body