Skip to content

Commit

Permalink
Merge branch 'MDL-75285-master' of https://github.com/marinaglancy/mo…
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Aug 3, 2022
2 parents 4b233aa + 24072f6 commit 41f3f47
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions course/classes/local/entities/course_category.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ protected function get_all_columns(): array {
->add_joins($this->get_joins())
->set_type(column::TYPE_TEXT)
->add_fields("{$tablealias}.name, {$tablealias}.id")
->add_callback(static function(string $name, stdClass $category): string {
return core_course_category::get($category->id, MUST_EXIST, true)->get_formatted_name();
->add_callback(static function(?string $name, stdClass $category): string {
return empty($category->id) ? '' :
core_course_category::get($category->id, MUST_EXIST, true)->get_formatted_name();
})
->set_is_sortable(true);

Expand All @@ -116,7 +117,10 @@ protected function get_all_columns(): array {
->set_type(column::TYPE_TEXT)
->add_fields("{$tablealias}.name, {$tablealias}.id")
->add_fields(context_helper::get_preload_record_columns_sql($tablealiascontext))
->add_callback(static function(string $name, stdClass $category): string {
->add_callback(static function(?string $name, stdClass $category): string {
if (empty($category->id)) {
return '';
}
context_helper::preload_from_record($category);
$context = context_coursecat::instance($category->id);
$url = new moodle_url('/course/management.php', ['categoryid' => $category->id]);
Expand All @@ -134,8 +138,9 @@ protected function get_all_columns(): array {
->add_joins($this->get_joins())
->set_type(column::TYPE_TEXT)
->add_fields("{$tablealias}.name, {$tablealias}.id")
->add_callback(static function(string $name, stdClass $category): string {
return core_course_category::get($category->id, MUST_EXIST, true)->get_nested_name(false);
->add_callback(static function(?string $name, stdClass $category): string {
return empty($category->id) ? '' :
core_course_category::get($category->id, MUST_EXIST, true)->get_nested_name(false);
})
->set_disabled_aggregation(['groupconcat', 'groupconcatdistinct'])
->set_is_sortable(true);
Expand Down

0 comments on commit 41f3f47

Please sign in to comment.