Ok, from a developers point of view there is an error in the documentation of the favicon method in the core_renderer class.
Note: All code referenced from Moodle version 3.5.2+ (Build: 20180914).
So, given the stack trace in the OP, line 102 is:
$icon = helper::get_icon($tool)->out();
this calls the static method 'get_icon' in the class helper to get a 'moodle_url' object and then call the 'out' method on it. The 'get_icon' method in /enrol/lti/classes/helper.php is:
/**
* Returns the icon of the tool.
*
* @param \stdClass $tool The lti tool
* @return \moodle_url A url to the icon of the tool
* @since Moodle 3.2
*/
public static function get_icon($tool) {
global $OUTPUT;
return $OUTPUT->favicon();
}
Thus this is the 'favicon' method in the 'core_renderer' class which is in /lib/outputrenderers.php:
/**
* Returns the URL for the favicon.
*
* @since Moodle 2.5.1 2.6
* @return string The favicon URL
*/
public function favicon() {
return $this->image_url('favicon', 'theme');
}
this states that the return is a 'string', however the 'image_url' method of the same class is:
/**
* Return the moodle_url for an image.
*
* The exact image location and extension is determined
* automatically by searching for gif|png|jpg|jpeg, please
* note there can not be diferent images with the different
* extension. The imagename is for historical reasons
* a relative path name, it may be changed later for core
* images. It is recommended to not use subdirectories
* in plugin and theme pix directories.
*
* There are three types of images:
* 1/ theme images - stored in theme/mytheme/pix/,
* use component 'theme'
* 2/ core images - stored in /pix/,
* overridden via theme/mytheme/pix_core/
* 3/ plugin images - stored in mod/mymodule/pix,
* overridden via theme/mytheme/pix_plugins/mod/mymodule/,
* example: image_url('comment', 'mod_glossary')
*
* @param string $imagename the pathname of the image
* @param string $component full plugin name (aka component) or 'theme'
* @return moodle_url
*/
public function image_url($imagename, $component = 'moodle') {
return $this->page->theme->image_url($imagename, $component);
}
which states it is a 'moodle_url' class, the 'image_url' method that is called on the 'theme_config' class in /lib/outputlib.php is:
/**
* Return the direct URL for an image from the pix folder.
*
* Use this function sparingly and never for icons. For icons use pix_icon or the pix helper in a mustache template.
*
* @param string $imagename the name of the icon.
* @param string $component specification of one plugin like in get_string()
* @return moodle_url
*/
public function image_url($imagename, $component) {
global $CFG;
$params = array('theme'=>$this->name);
$svg = $this->use_svg_icons();
if (empty($component) or $component === 'moodle' or $component === 'core') {
$params['component'] = 'core';
} else {
$params['component'] = $component;
}
$rev = theme_get_revision();
if ($rev != -1) {
$params['rev'] = $rev;
}
$params['image'] = $imagename;
$url = new moodle_url("/theme/image.php");
if (!empty($CFG->slasharguments) and $rev > 0) {
$path = '/'.$params['theme'].'/'.$params['component'].'/'.$params['rev'].'/'.$params['image'];
if (!$svg) {
// We add a simple /_s to the start of the path.
// The underscore is used to ensure that it isn't a valid theme name.
$path = '/_s'.$path;
}
$url->set_slashargument($path, 'noparam', true);
} else {
if (!$svg) {
// We add an SVG param so that we know not to serve SVG images.
// We do this because all modern browsers support SVG and this param will one day be removed.
$params['svg'] = '0';
}
$url->params($params);
}
return $url;
}
which also states it is a 'moodle_url' class (instantiated object of) being returned.
So from a purely Essential theme point of view, I / Julian / David has been misinformed when reading the core code and written:
/**
* Returns the url of the custom favicon.
*/
public function favicon() {
$favicon = \theme_essential\toolbox::get_setting('favicon', 'format_file_url');
if (empty($favicon)) {
return $this->page->theme->image_url('favicon', 'theme');
} else {
return $favicon;
}
}
in the overridden core_renderer method 'favicon'. And thus I suspect many other developers have too. I'll now work on a fix.
Therefore the 'favicon' method in the 'core_renderer' class is incorrectly documented and hence the error message 'Exception - Call to a member function out() on string' because a string does not have a method called 'out' but a 'moodle_url' object does.
Is there an MDL for this trivial bug?
Also if you're using any of my other themes and have the same issue, then let me know.
Gareth