original_string: public static function resolve_category($data, &$errors = array()) {
          $catid = null;
  
          if (!empty($data['category'])) {
              $category = core_course_category::get((int) $data['category'], IGNORE_MISSING);
              if (!empty($category) && !empty($category->id)) {
                  $catid = $category->id;
              } else {
                  $errors['couldnotresolvecatgorybyid'] =
                      new lang_string('couldnotresolvecatgorybyid', 'tool_uploadcourse');
              }
          }
  
          if (empty($catid) && !empty($data['category_idnumber'])) {
              $catid = self::resolve_category_by_idnumber($data['category_idnumber']);
              if (empty($catid)) {
                  $errors['couldnotresolvecatgorybyidnumber'] =
                      new lang_string('couldnotresolvecatgorybyidnumber', 'tool_uploadcourse');
              }
          }
          if (empty($catid) && !empty($data['category_path'])) {
              $catid = self::resolve_category_by_path(explode(' / ', $data['category_path']));
              if (empty($catid)) {
                  $errors['couldnotresolvecatgorybypath'] =
                      new lang_string('couldnotresolvecatgorybypath', 'tool_uploadcourse');
              }
          }
  
          return $catid;
      }
code: public static function resolve_category($data, &$errors = array()) {
          $catid = null;
  
          if (!empty($data['category'])) {
              $category = core_course_category::get((int) $data['category'], IGNORE_MISSING);
              if (!empty($category) && !empty($category->id)) {
                  $catid = $category->id;
              } else {
                  $errors['couldnotresolvecatgorybyid'] =
                      new lang_string('couldnotresolvecatgorybyid', 'tool_uploadcourse');
              }
          }
  
          if (empty($catid) && !empty($data['category_idnumber'])) {
              $catid = self::resolve_category_by_idnumber($data['category_idnumber']);
              if (empty($catid)) {
                  $errors['couldnotresolvecatgorybyidnumber'] =
                      new lang_string('couldnotresolvecatgorybyidnumber', 'tool_uploadcourse');
              }
          }
          if (empty($catid) && !empty($data['category_path'])) {
              $catid = self::resolve_category_by_path(explode(' / ', $data['category_path']));
              if (empty($catid)) {
                  $errors['couldnotresolvecatgorybypath'] =
                      new lang_string('couldnotresolvecatgorybypath', 'tool_uploadcourse');
              }
          }
  
          return $catid;
      }
code_tokens: public static function resolve_category ( $ data , & $ errors = array ( ) ) { $ catid = null ; if ( ! empty ( $ data [ 'category' ] ) ) { $ category = core_course_category :: get ( ( int ) $ data [ 'category' ] , IGNORE_MISSING ) ; if ( ! empty ( $ category ) && ! empty ( $ category -> id ) ) { $ catid = $ category -> id ; } else { $ errors [ 'couldnotresolvecatgorybyid' ] = new lang_string ( 'couldnotresolvecatgorybyid' , 'tool_uploadcourse' ) ; } } if ( empty ( $ catid ) && ! empty ( $ data [ 'category_idnumber' ] ) ) { $ catid = self :: resolve_category_by_idnumber ( $ data [ 'category_idnumber' ] ) ; if ( empty ( $ catid ) ) { $ errors [ 'couldnotresolvecatgorybyidnumber' ] = new lang_string ( 'couldnotresolvecatgorybyidnumber' , 'tool_uploadcourse' ) ; } } if ( empty ( $ catid ) && ! empty ( $ data [ 'category_path' ] ) ) { $ catid = self :: resolve_category_by_path ( explode ( ' / ' , $ data [ 'category_path' ] ) ) ; if ( empty ( $ catid ) ) { $ errors [ 'couldnotresolvecatgorybypath' ] = new lang_string ( 'couldnotresolvecatgorybypath' , 'tool_uploadcourse' ) ; } } return $ catid ; }
docstring: Resolve a category based on the data passed.
  
  Key accepted are:
  - category, which is supposed to be a category ID.
  - category_idnumber
  - category_path, array of categories from parent to child.
  
  @param array $data to resolve the category from.
  @param array $errors will be populated with errors found.
  @return int category ID.
docstring_tokens: Resolve a category based on the data passed .