23
23
*/
24
24
25
25
namespace block_featured_courses ;
26
- defined ('MOODLE_INTERNAL ' ) || die ();
27
- global $ CFG ;
28
26
29
27
use core_course \external \course_summary_exporter ;
28
+ use core_course_category ;
29
+ use moodle_exception ;
30
30
use moodle_url ;
31
31
use renderer_base ;
32
32
@@ -45,7 +45,7 @@ class mini_course_summary_exporter extends course_summary_exporter {
45
45
*
46
46
* @return array|array[]
47
47
*/
48
- public static function define_other_properties () {
48
+ public static function define_other_properties (): array {
49
49
return array (
50
50
'fullnamedisplay ' => array (
51
51
'type ' => PARAM_TEXT ,
@@ -65,22 +65,12 @@ public static function define_other_properties() {
65
65
);
66
66
}
67
67
68
- /**
69
- * Constructor - saves the persistent object, and the related objects.
70
- *
71
- * @param mixed $data - Either an stdClass or an array of values.
72
- * @param array $related - An optional list of pre-loaded objects related to this object.
73
- */
74
- public function __construct ($ data , $ related = array ()) {
75
- \core \external \exporter::__construct ($ data , $ related );
76
- }
77
-
78
68
/**
79
69
* Define related variables
80
70
*
81
71
* @return string[]
82
72
*/
83
- protected static function define_related () {
73
+ protected static function define_related (): array {
84
74
// We cache the context so it does not need to be retrieved from the course.
85
75
return array ('context ' => '\\context ' );
86
76
}
@@ -90,15 +80,15 @@ protected static function define_related() {
90
80
*
91
81
* @param renderer_base $output
92
82
* @return array
93
- * @throws \ moodle_exception
83
+ * @throws moodle_exception
94
84
*/
95
- protected function get_other_values (renderer_base $ output ) {
85
+ protected function get_other_values (renderer_base $ output ): array {
96
86
global $ CFG ;
97
87
$ courseimage = self ::get_course_image ($ this ->data );
98
88
if (!$ courseimage ) {
99
89
$ courseimage = $ output ->get_generated_image_for_id ($ this ->data ->id );
100
90
}
101
- $ coursecategory = \ core_course_category::get ($ this ->data ->category , MUST_EXIST , true );
91
+ $ coursecategory = core_course_category::get ($ this ->data ->category , MUST_EXIST , true );
102
92
$ urlparam = array ('id ' => $ this ->data ->id );
103
93
$ courseurl = new moodle_url ('/course/view.php ' , $ urlparam );
104
94
if (!empty ($ CFG ->enablesyllabus ) && class_exists ('\\local_syllabus \\locallib\utils ' )) {
@@ -108,9 +98,9 @@ protected function get_other_values(renderer_base $output) {
108
98
'fullnamedisplay ' => get_course_display_name_for_list ($ this ->data ),
109
99
'viewurl ' => $ courseurl ->out (false ),
110
100
'courseimage ' => $ courseimage ,
111
- 'showshortname ' => $ CFG ->courselistshortnames ? true : false ,
101
+ 'showshortname ' => ( bool ) ( $ CFG ->courselistshortnames ?? false ) ,
112
102
'coursecategory ' => $ coursecategory ->name
113
103
);
114
104
}
115
105
116
- }
106
+ }
0 commit comments