original_string: protected function get_cm($modulename, $instanceid, $courseid) {
          $modinfo = get_fast_modinfo($courseid);
  
          // Hopefully not many, they are indexed by cmid.
          $instances = $modinfo->get_instances_of($modulename);
          foreach ($instances as $cminfo) {
              if ($cminfo->instance == $instanceid) {
                  return $cminfo;
              }
          }
  
          // Nothing found.
          throw new \dml_missing_record_exception($modulename);
      }
code: protected function get_cm($modulename, $instanceid, $courseid) {
          $modinfo = get_fast_modinfo($courseid);
  
          // Hopefully not many, they are indexed by cmid.
          $instances = $modinfo->get_instances_of($modulename);
          foreach ($instances as $cminfo) {
              if ($cminfo->instance == $instanceid) {
                  return $cminfo;
              }
          }
  
          // Nothing found.
          throw new \dml_missing_record_exception($modulename);
      }
code_tokens: protected function get_cm ( $ modulename , $ instanceid , $ courseid ) { $ modinfo = get_fast_modinfo ( $ courseid ) ; // Hopefully not many, they are indexed by cmid. $ instances = $ modinfo -> get_instances_of ( $ modulename ) ; foreach ( $ instances as $ cminfo ) { if ( $ cminfo -> instance == $ instanceid ) { return $ cminfo ; } } // Nothing found. throw new \ dml_missing_record_exception ( $ modulename ) ; }
docstring: Gets the course module for the required instanceid + modulename.
  
  The returned data depends on the logged user, when calling this through
  self::get_document the admin user is used so everything would be returned.
  
  No need more internal caching here, modinfo is already cached.
  
  @throws \dml_missing_record_exception
  @param string $modulename The module name
  @param int $instanceid Module instance id (depends on the module)
  @param int $courseid Helps speeding up things
  @return \cm_info
docstring_tokens: Gets the course module for the required instanceid + modulename .