ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
FSLoader.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
29 
41 class FSLoader implements Loader
42 {
43  use LoaderHelper;
44 
45  public function __construct(
46  private RendererFactory $default_renderer_factory,
47  private RendererFactory $glyph_renderer_factory,
48  private RendererFactory $field_renderer_factory,
49  private RendererFactory $message_box_renderer_factory,
50  private RendererFactory $form_renderer_factory,
51  ) {
52  }
53 
57  public function getRendererFor(Component $component, array $contexts): ComponentRenderer
58  {
59  $context_names = $this->getContextNames($contexts);
60  $factory = $this->getRendererFactoryFor($component);
61  return $factory->getRendererInContext($component, $context_names);
62  }
63 
67  public function getRendererFactoryFor(Component $component): RendererFactory
68  {
69  if ($component instanceof Glyph) {
70  return $this->glyph_renderer_factory;
71  }
72  if ($component instanceof FormInput) {
73  return $this->field_renderer_factory;
74  }
75  if ($component instanceof MessageBox) {
76  return $this->message_box_renderer_factory;
77  }
78  if ($component instanceof Form) {
79  return $this->form_renderer_factory;
80  }
81 
82  return $this->default_renderer_factory;
83  }
84 }
Loads renderers for components from the file system.
Definition: FSLoader.php:41
An entity that renders components to a string output.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This implements commonalities between all forms.
Definition: Form.php:33
__construct(private RendererFactory $default_renderer_factory, private RendererFactory $glyph_renderer_factory, private RendererFactory $field_renderer_factory, private RendererFactory $message_box_renderer_factory, private RendererFactory $form_renderer_factory,)
Definition: FSLoader.php:45
This is the interface that components should use if they want to load specific renderers.
getRendererFactoryFor(Component $component)
Definition: FSLoader.php:67
Loads renderers for components.
Definition: Loader.php:29
getRendererFor(Component $component, array $contexts)
Definition: FSLoader.php:57