17
17
/**
18
18
* Thumblinks Action block renderable.
19
19
*
20
- * @package block_thumblinks_action
20
+ * @package block_featured_courses
21
21
* @copyright 2020 - CALL Learning - Laurent David <laurent@call-learning>
22
22
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
23
*/
24
24
25
25
namespace block_featured_courses \output ;
26
- global $ CFG ;
27
-
28
26
defined ('MOODLE_INTERNAL ' ) || die ();
29
27
30
28
use context_course ;
35
33
use renderer_base ;
36
34
use templatable ;
37
35
36
+ /**
37
+ * Class mini_course_summary_exporter
38
+ *
39
+ * @package block_featured_courses
40
+ * @copyright 2020 - CALL Learning - Laurent David <laurent@call-learning>
41
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
42
+ */
38
43
class mini_course_summary_exporter extends course_summary_exporter {
39
44
40
45
/**
@@ -67,16 +72,29 @@ public static function define_other_properties() {
67
72
*
68
73
* @param mixed $data - Either an stdClass or an array of values.
69
74
* @param array $related - An optional list of pre-loaded objects related to this object.
75
+ * @throws \coding_exception
70
76
*/
71
77
public function __construct ($ data , $ related = array ()) {
72
78
\core \external \exporter::__construct ($ data , $ related );
73
79
}
74
80
81
+ /**
82
+ * Define related data
83
+ *
84
+ * @return string[]
85
+ */
75
86
protected static function define_related () {
76
87
// We cache the context so it does not need to be retrieved from the course.
77
88
return array ('context ' => '\\context ' );
78
89
}
79
90
91
+ /**
92
+ * Get additional values related to the course
93
+ *
94
+ * @param renderer_base $output
95
+ * @return array
96
+ * @throws \moodle_exception
97
+ */
80
98
protected function get_other_values (renderer_base $ output ) {
81
99
global $ CFG ;
82
100
$ courseimage = self ::get_course_image ($ this ->data );
@@ -103,7 +121,7 @@ protected function get_other_values(renderer_base $output) {
103
121
/**
104
122
* Class containing data for featured_courses block.
105
123
*
106
- * @package block_mcms
124
+ * @package block_featured_courses
107
125
* @copyright 2020 - CALL Learning - Laurent David <laurent@call-learning>
108
126
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
109
127
*/
@@ -118,7 +136,7 @@ class featured_courses implements renderable, templatable {
118
136
* featured_courses constructor.
119
137
* Retrieve matchin courses
120
138
*
121
- * @param $coursesid
139
+ * @param int $coursesid
122
140
* @throws \coding_exception
123
141
* @throws \dml_exception
124
142
*/
@@ -128,6 +146,13 @@ public function __construct($coursesid) {
128
146
$ this ->courses = $ DB ->get_records_select ('course ' , 'id ' . $ sql , $ params );
129
147
}
130
148
149
+ /**
150
+ * Export featured course data
151
+ *
152
+ * @param renderer_base $renderer
153
+ * @return array
154
+ * @throws \coding_exception
155
+ */
131
156
public function export_for_template (renderer_base $ renderer ) {
132
157
$ formattedcourses = array_map (function ($ course ) use ($ renderer ) {
133
158
context_helper::preload_from_record ($ course );
0 commit comments