72 final public function txt($id) {
73 return $this->lng->txt($id);
88 final protected function getTemplate($name, $purge_unfilled_vars, $purge_unused_blocks) {
90 $path =
"src/UI/templates/default/$component/$name";
91 return $this->tpl_factory->getTemplate(
$path, $purge_unfilled_vars, $purge_unused_blocks);
105 if ($binder ===
null) {
108 $id = $this->js_binding->createId();
109 $on_load_code = $binder($id);
110 if (!is_string($on_load_code)) {
111 throw new \LogicException(
112 "Expected JavaScript binder to return string".
113 " (used component: ".get_class($component).
")");
115 $this->js_binding->addOnLoadCode($on_load_code);
130 if(!is_array($interfaces)){
131 throw new \LogicException(
132 "Expected array, found '".(
string)(
null).
"' when rendering.");
135 foreach ($interfaces as $interface) {
136 if ($component instanceof $interface) {
140 $ifs = implode(
", ", $interfaces);
141 throw new \LogicException(
142 "Expected $ifs, found '".get_class($component).
"' when rendering.");
156 $class = get_class($this);
159 $re =
"%ILIAS\\\\UI\\\\Implementation\\\\Component\\\\(\\w+)\\\\(\\w+)%";
160 if (preg_match($re, $class, $matches) !== 1) {
161 throw new \LogicException(
162 "The Renderer needs to be located in ILIAS\\UI\\Implementation\\Component\\*.");
An exception for terminatinating execution or to throw for unit testing.
Base class for all component renderers.
__construct(Factory $ui_factory, TemplateFactory $tpl_factory, \ilLanguage $lng, JavaScriptBinding $js_binding)
Component renderers must only depend on a UI-Factory and a Template Factory.
txt($id)
Get a text from the language file.
getTemplate($name, $purge_unfilled_vars, $purge_unused_blocks)
Get template of component this renderer is made for.
registerResources(ResourceRegistry $registry)
Announce resources this renderer requires.null
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.
checkComponent(Component $component)
Check if a given component fits this renderer and throw \LogicError if that is not the case.
getUIFactory()
Get a UI factory.
getComponentInterfaceName()
Get the name of the component-interface this renderer is supposed to render.
A component is the most general form of an entity in the UI.
Interface to be extended by components that have the possibility to bind to Javascript.
getOnLoadCode()
Get the currently bound on load code.
This is how the factory for UI elements looks.
An entity that renders components to a string output.
Provides methods to interface with javascript.
Registry for resources required by rendered output like Javascript or CSS.
Interface for a factory that provides templates.
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.