original_string: protected function ensure_category_loaded() {
          if (is_array($this->_categories)) {
              return; // Already done.
          }
          if (is_null($this->_course)) {
              throw new coding_exception('Attempt to get the course category for this page before the course was set.');
          }
          if ($this->_course->category == 0) {
              $this->_categories = array();
          } else {
              $this->load_category($this->_course->category);
          }
      }
code: protected function ensure_category_loaded() {
          if (is_array($this->_categories)) {
              return; // Already done.
          }
          if (is_null($this->_course)) {
              throw new coding_exception('Attempt to get the course category for this page before the course was set.');
          }
          if ($this->_course->category == 0) {
              $this->_categories = array();
          } else {
              $this->load_category($this->_course->category);
          }
      }
code_tokens: protected function ensure_category_loaded ( ) { if ( is_array ( $ this -> _categories ) ) { return ; // Already done. } if ( is_null ( $ this -> _course ) ) { throw new coding_exception ( 'Attempt to get the course category for this page before the course was set.' ) ; } if ( $ this -> _course -> category == 0 ) { $ this -> _categories = array ( ) ; } else { $ this -> load_category ( $ this -> _course -> category ) ; } }
docstring: This function ensures that the category of the current course has been
  loaded, and if not, the function loads it now.
  
  @return void
  @throws coding_exception
docstring_tokens: This function ensures that the category of the current course has been loaded and if not the function loads it now .