72 $registry->
register(
'./src/UI/templates/js/Core/ui.js');
101 final public function txt($id)
103 return $this->lng->txt($id);
110 final public function toJS($key)
112 $this->lng->toJS($key);
122 return $this->lng->getLangKey();
149 return $this->tpl_factory->getTemplate($path, $purge_unfilled_vars, $purge_unused_blocks);
161 return "src/UI/templates/default/$component/$name";
195 return $this->js_binding->createId();
207 if ($binder ===
null) {
211 $id = $this->js_binding->createId();
212 $on_load_code = $binder($id);
213 if (!is_string($on_load_code)) {
214 throw new \LogicException(
215 "Expected JavaScript binder to return string" .
216 " (used component: " . get_class($component) .
")"
219 $this->js_binding->addOnLoadCode($on_load_code);
232 if (count($triggered_signals) == 0) {
237 foreach ($triggered_signals as $triggered_signal) {
238 $signal = $triggered_signal->getSignal();
239 $event = $triggered_signal->getEvent();
240 $options = json_encode($signal->getOptions());
243 if ($event ==
'load' || $event ==
'ready') {
245 "$(document).trigger('{$signal}',
247 'id' : '{$signal}', 'event' : '{$event}',
248 'triggerer' : $('#{$id}'),
249 'options' : JSON.parse('{$options}')
254 "$('#{$id}').on('{$event}', function(event) {
255 $(this).trigger('{$signal}',
257 'id' : '{$signal}', 'event' : '{$event}',
258 'triggerer' : $(this),
259 'options' : JSON.parse('{$options}')
281 if (!is_array($interfaces)) {
282 throw new \LogicException(
283 "Expected array, found '" . (
string) (
null) .
"' when rendering."
287 foreach ($interfaces as $interface) {
288 if ($component instanceof $interface) {
292 $ifs = implode(
", ", $interfaces);
293 throw new \LogicException(
294 "Expected $ifs, found '" . get_class($component) .
"' when rendering."
310 $class = get_class($this);
311 if (isset(self::$component_storage[$class])) {
312 return self::$component_storage[$class];
316 $re =
"%ILIAS\\\\UI\\\\Implementation\\\\Component\\\\(\\w+)\\\\(\\w+)%";
317 preg_match($re, $class, $matches);
318 if (preg_match($re, $class, $matches) !== 1) {
319 throw new \LogicException(
"The Renderer needs to be located in ILIAS\\UI\\Implementation\\Component\\*.");
321 self::$component_storage[$class] = $matches[1];
323 return self::$component_storage[$class];
An exception for terminatinating execution or to throw for unit testing.
Base class for all component renderers.
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
getTemplatePath($name)
Get the path to the template of this component.
createId()
Get a fresh unique id.
__construct(Factory $ui_factory, TemplateFactory $tpl_factory, \ilLanguage $lng, JavaScriptBinding $js_binding, \ILIAS\Refinery\Factory $refinery)
Component renderers must only depend on a UI-Factory and a Template Factory.
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.
getLangKey()
Get current language key.
static $component_storage
addTriggererOnLoadCode(Triggerer $triggerer)
Add onload-code for triggerer.
toJS($key)
Add language var to client side (il.Language)
getUIFactory()
Get a UI factory.
getComponentInterfaceName()
Get the name of the component-interface this renderer is supposed to render.
bindOnloadCode(JavaScriptBindable $component)
Bind the JavaScript onload-code.
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.
withAdditionalOnLoadCode(\Closure $binder)
Add some onload-code to the component instead of replacing the existing one.
getOnLoadCode()
Get the currently bound on load code.
getTriggeredSignals()
Get all triggered signals of this component.
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.
register($name)
Add a dependency.
Interface for a factory that provides templates.
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
Class ChatMainBarProvider \MainMenu\Provider.