19 declare(strict_types=1);
41 return $this->
renderToast($component, $default_renderer);
47 throw new LogicException(
"Cannot render: " . get_class($component));
52 $tpl = $this->
getTemplate(
"tpl.toast.html",
true,
true);
54 $title = $component->getTitle();
55 if ($title instanceof
Shy || $title instanceof
Link) {
56 $title = $default_renderer->render($title);
58 $title = htmlentities($title);
60 $tpl->setVariable(
"TITLE", $title);
62 $tpl->setVariable(
"VANISH_ASYNC", $component->getAction());
64 $desc = htmlentities($component->getDescription());
65 if (trim($desc) !=
"") {
66 $tpl->setCurrentBlock(
"desc");
67 $tpl->setVariable(
"DESC", $desc);
68 $tpl->parseCurrentBlock();
71 $actions = $component->getLinks();
72 if (!empty($actions)) {
73 foreach ($actions as $action) {
74 $tpl->setCurrentBlock(
"action");
75 $tpl->setVariable(
"ACTION", $default_renderer->render($action));
76 $tpl->parseCurrentBlock();
80 $tpl->setVariable(
"ICON", $default_renderer->render($component->getIcon()));
81 $tpl->setVariable(
"CLOSE", $default_renderer->render($this->getUIFactory()->button()->close()));
83 $component = $component->withAdditionalOnLoadCode(fn(
$id) =>
"il.UI.toast.showToast($id);");
85 $tpl->setCurrentBlock(
"id");
87 $tpl->parseCurrentBlock();
94 $tpl = $this->
getTemplate(
"tpl.container.html",
true,
true);
95 $tpl->setVariable(
"TOASTS", $default_renderer->render($component->getToasts()));
101 parent::registerResources($registry);
102 $registry->
register(
'./src/UI/templates/js/Toast/toast.js');
111 Component\Toast\Toast::class,
112 Component\Toast\Container::class
Registry for resources required by rendered output like Javascript or CSS.
registerResources(ResourceRegistry $registry)
Announce resources this renderer requires.
checkComponent(Component $component)
Check if a given component fits this renderer and throw if that is not the case. ...
renderToast(Component\Toast\Toast $component, RendererInterface $default_renderer)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
renderContainer(Component\Toast\Container $component, RendererInterface $default_renderer)
getComponentInterfaceName()
getTemplate(string $name, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get template of component this renderer is made for.
register(string $name)
Add a dependency.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
render(Component\Component $component, RendererInterface $default_renderer)
Base class for all component renderers.
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.