original_string: protected function validate_field(field_controller $field) : field_controller {
          if (!array_key_exists($field->get('categoryid'), $this->get_categories_with_fields())) {
              throw new \moodle_exception('fieldnotfound', 'core_customfield');
          }
          $category = $this->get_categories_with_fields()[$field->get('categoryid')];
          if (!array_key_exists($field->get('id'), $category->get_fields())) {
              throw new \moodle_exception('fieldnotfound', 'core_customfield');
          }
          return $category->get_fields()[$field->get('id')];
      }
code: protected function validate_field(field_controller $field) : field_controller {
          if (!array_key_exists($field->get('categoryid'), $this->get_categories_with_fields())) {
              throw new \moodle_exception('fieldnotfound', 'core_customfield');
          }
          $category = $this->get_categories_with_fields()[$field->get('categoryid')];
          if (!array_key_exists($field->get('id'), $category->get_fields())) {
              throw new \moodle_exception('fieldnotfound', 'core_customfield');
          }
          return $category->get_fields()[$field->get('id')];
      }
code_tokens: protected function validate_field ( field_controller $ field ) : field_controller { if ( ! array_key_exists ( $ field -> get ( 'categoryid' ) , $ this -> get_categories_with_fields ( ) ) ) { throw new \ moodle_exception ( 'fieldnotfound' , 'core_customfield' ) ; } $ category = $ this -> get_categories_with_fields ( ) [ $ field -> get ( 'categoryid' ) ] ; if ( ! array_key_exists ( $ field -> get ( 'id' ) , $ category -> get_fields ( ) ) ) { throw new \ moodle_exception ( 'fieldnotfound' , 'core_customfield' ) ; } return $ category -> get_fields ( ) [ $ field -> get ( 'id' ) ] ; }
docstring: Validate that the given field belongs to this handler
  
  @param field_controller $field
  @return field_controller
  @throws \moodle_exception
docstring_tokens: Validate that the given field belongs to this handler