public function get_category() {
        global $CFG;
        // If the category is not set, if the current user does not have the rights to change the category, or if the
        // category does not exist, we set the default category to the course to be approved.
        // The system level is used because the capability moodle/site:approvecourse is based on a system level.
        if (empty($this->properties->category) || !has_capability('moodle/course:changecategory', context_system::instance()) ||
                (!$category = core_course_category::get($this->properties->category, IGNORE_MISSING, true))) {
            $category = core_course_category::get($CFG->defaultrequestcategory, IGNORE_MISSING, true);
        }
        if (!$category) {
            $category = core_course_category::get_default();
        }
        return $category;
    }
public function get_category() {
        global $CFG;
        // If the category is not set, if the current user does not have the rights to change the category, or if the
        // category does not exist, we set the default category to the course to be approved.
        // The system level is used because the capability moodle/site:approvecourse is based on a system level.
        if (empty($this->properties->category) || !has_capability('moodle/course:changecategory', context_system::instance()) ||
                (!$category = core_course_category::get($this->properties->category, IGNORE_MISSING, true))) {
            $category = core_course_category::get($CFG->defaultrequestcategory, IGNORE_MISSING, true);
        }
        if (!$category) {
            $category = core_course_category::get_default();
        }
        return $category;
    }
public function get_category ( ) { global $ CFG ; // If the category is not set, if the current user does not have the rights to change the category, or if the // category does not exist, we set the default category to the course to be approved. // The system level is used because the capability moodle/site:approvecourse is based on a system level. if ( empty ( $ this -> properties -> category ) || ! has_capability ( 'moodle/course:changecategory' , context_system :: instance ( ) ) || ( ! $ category = core_course_category :: get ( $ this -> properties -> category , IGNORE_MISSING , true ) ) ) { $ category = core_course_category :: get ( $ CFG -> defaultrequestcategory , IGNORE_MISSING , true ) ; } if ( ! $ category ) { $ category = core_course_category :: get_default ( ) ; } return $ category ; }
Returns the category where this course request should be created

Note that we don't check here that user has a capability to view
hidden categories if he has capabilities 'moodle/site:approvecourse' and
'moodle/course:changecategory'

@return core_course_category
Returns the category where this course request should be created