Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
renderer_factory Interface Reference

A renderer factory is just responsible for creating an appropriate renderer for any given part of Moodle. More...

Inheritance diagram for renderer_factory:
renderer_factory_base standard_renderer_factory theme_overridden_renderer_factory

Public Member Functions

 get_renderer (moodle_page $page, $component, $subtype=null, $target=null)
 Return the renderer for a particular part of Moodle.
 

Detailed Description

A renderer factory is just responsible for creating an appropriate renderer for any given part of Moodle.

Which renderer factory to use is chose by the current theme, and an instance if created automatically when the theme is set up.

A renderer factory must also have a constructor that takes a theme_config object. (See renderer_factory_base::__construct for an example.)

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Since
Moodle 2.0

Member Function Documentation

◆ get_renderer()

renderer_factory::get_renderer ( moodle_page $page,
$component,
$subtype = null,
$target = null )

Return the renderer for a particular part of Moodle.

The renderer interfaces are defined by classes called {plugin}_renderer where {plugin} is the name of the component. The renderers for core Moodle are defined in lib/renderer.php. For plugins, they will be defined in a file called renderer.php inside the plugin.

Renderers will normally want to subclass the renderer_base class. (However, if you really know what you are doing, you don't have to do that.)

There is no separate interface definition for renderers. The default {plugin}_renderer implementation also serves to define the API for other implementations of the interface, whether or not they subclass it.

A particular plugin can define multiple renderers if it wishes, using the $subtype parameter. For example workshop_renderer, workshop_allocation_manual_renderer etc.

Parameters
moodle_page$pagethe page the renderer is outputting content for.
string$componentname such as 'core', 'mod_forum' or 'qtype_multichoice'.
string$subtypeoptional subtype such as 'news' resulting to 'mod_forum_news'
string$targetone of rendering target constants
Return values
renderer_basean object implementing the requested renderer interface.

Implemented in standard_renderer_factory, and theme_overridden_renderer_factory.


The documentation for this interface was generated from the following file: