ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ILIAS\UI\Implementation\DefaultRenderer Class Reference

Renderer that dispatches rendering of UI components to a Renderer found in the same namespace as the component to be renderered. More...

+ Inheritance diagram for ILIAS\UI\Implementation\DefaultRenderer:
+ Collaboration diagram for ILIAS\UI\Implementation\DefaultRenderer:

Public Member Functions

 __construct (RootFactory $ui_factory, TemplateFactory $tpl_factory, ResourceRegistry $resource_registry, \ilLanguage $lng, JavaScriptBinding $js_binding)
 
 render (Component $component)
 
 getRendererFor ($class)
 Get a renderer for a certain Component class. More...
 
 instantiateRendererFor ($class)
 Instantiate a renderer for a certain Component class. More...
 
 getRendererNameFor ($class)
 Get the class name for the renderer of Component class. More...
 
- Public Member Functions inherited from ILIAS\UI\Renderer
 render (Component\Component $component)
 Render given component. More...
 

Private Attributes

 $ui_factory
 
 $cache = array()
 
 $tpl_factory
 
 $resource_registry
 
 $lng
 
 $js_binding
 

Detailed Description

Renderer that dispatches rendering of UI components to a Renderer found in the same namespace as the component to be renderered.

Definition at line 19 of file DefaultRenderer.php.

Constructor & Destructor Documentation

◆ __construct()

Member Function Documentation

◆ getRendererFor()

ILIAS\UI\Implementation\DefaultRenderer::getRendererFor (   $class)

Get a renderer for a certain Component class.

Either initializes a new renderer or uses a cached one initialized before.

Parameters
string$class
Exceptions

Definition at line 76 of file DefaultRenderer.php.

References ILIAS\UI\Implementation\DefaultRenderer\instantiateRendererFor().

Referenced by ILIAS\UI\Implementation\DefaultRenderer\render().

76  {
77  if (array_key_exists($class, $this->cache)) {
78  return $this->cache[$class];
79  }
80  $renderer = $this->instantiateRendererFor($class);
81  $renderer->registerResources($this->resource_registry);
82  $this->cache[$class] = $renderer;
83  return $renderer;
84  }
instantiateRendererFor($class)
Instantiate a renderer for a certain Component class.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRendererNameFor()

ILIAS\UI\Implementation\DefaultRenderer::getRendererNameFor (   $class)

Get the class name for the renderer of Component class.

Parameters
string$class
Returns
string

Definition at line 109 of file DefaultRenderer.php.

Referenced by ILIAS\UI\Implementation\DefaultRenderer\instantiateRendererFor().

109  {
110  $parts = explode("\\", $class);
111  $parts[count($parts)-1] = "Renderer";
112  return implode("\\", $parts);
113  }
+ Here is the caller graph for this function:

◆ instantiateRendererFor()

ILIAS\UI\Implementation\DefaultRenderer::instantiateRendererFor (   $class)

Instantiate a renderer for a certain Component class.

This will always create a fresh renderer for the component.

Parameters
string$class
Exceptions

Definition at line 95 of file DefaultRenderer.php.

References ILIAS\UI\Implementation\DefaultRenderer\getRendererNameFor().

Referenced by ILIAS\UI\Implementation\DefaultRenderer\getRendererFor().

95  {
96  $renderer_class = $this->getRendererNameFor($class);
97  if (!class_exists($renderer_class)) {
98  throw new \LogicException("No rendered for '".$class."' found.");
99  }
100  return new $renderer_class($this->ui_factory, $this->tpl_factory, $this->lng, $this->js_binding);
101  }
getRendererNameFor($class)
Get the class name for the renderer of Component class.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

ILIAS\UI\Implementation\DefaultRenderer::render ( Component  $component)

Definition at line 61 of file DefaultRenderer.php.

References ILIAS\UI\Implementation\DefaultRenderer\getRendererFor().

61  {
62  $renderer = $this->getRendererFor(get_class($component));
63  return $renderer->render($component, $this);
64  }
getRendererFor($class)
Get a renderer for a certain Component class.
+ Here is the call graph for this function:

Field Documentation

◆ $cache

ILIAS\UI\Implementation\DefaultRenderer::$cache = array()
private

Definition at line 28 of file DefaultRenderer.php.

◆ $js_binding

ILIAS\UI\Implementation\DefaultRenderer::$js_binding
private

◆ $lng

ILIAS\UI\Implementation\DefaultRenderer::$lng
private

◆ $resource_registry

ILIAS\UI\Implementation\DefaultRenderer::$resource_registry
private

◆ $tpl_factory

ILIAS\UI\Implementation\DefaultRenderer::$tpl_factory
private

◆ $ui_factory

ILIAS\UI\Implementation\DefaultRenderer::$ui_factory
private

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