19 declare(strict_types=1);
39 return $this->
renderToast($component, $default_renderer);
50 $tpl = $this->
getTemplate(
"tpl.toast.html",
true,
true);
52 $title = $component->getTitle();
53 if ($title instanceof
Shy || $title instanceof
Link) {
54 $title = $default_renderer->render($title);
56 $title = htmlentities($title);
58 $tpl->setVariable(
"TITLE", $title);
60 $tpl->setVariable(
"VANISH_ASYNC", $component->getAction());
62 $desc = htmlentities($component->getDescription());
63 if (trim($desc) !=
"") {
64 $tpl->setCurrentBlock(
"desc");
65 $tpl->setVariable(
"DESC", $desc);
66 $tpl->parseCurrentBlock();
69 $actions = $component->getLinks();
70 if (!empty($actions)) {
71 foreach ($actions as $action) {
72 $tpl->setCurrentBlock(
"action");
73 $tpl->setVariable(
"ACTION", $default_renderer->render($action));
74 $tpl->parseCurrentBlock();
78 $tpl->setVariable(
"ICON", $default_renderer->render($component->getIcon()));
79 $tpl->setVariable(
"CLOSE", $default_renderer->render($this->getUIFactory()->button()->close()));
81 $component = $component->withAdditionalOnLoadCode(fn(
$id) =>
"il.UI.toast.showToast($id);");
83 $tpl->setCurrentBlock(
"id");
85 $tpl->parseCurrentBlock();
92 $tpl = $this->
getTemplate(
"tpl.container.html",
true,
true);
93 $tpl->setVariable(
"TOASTS", $default_renderer->render($component->getToasts()));
99 parent::registerResources($registry);
100 $registry->
register(
'assets/js/toast.js');
Registry for resources required by rendered output like Javascript or CSS.
registerResources(ResourceRegistry $registry)
Announce resources this renderer requires.
renderToast(Component\Toast\Toast $component, RendererInterface $default_renderer)
renderContainer(Component\Toast\Container $component, RendererInterface $default_renderer)
getTemplate(string $name, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get template of component this renderer is made for.
cannotHandleComponent(Component $component)
This method MUST be called by derived component renderers, if.
register(string $name)
Add a dependency.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
render(Component\Component $component, RendererInterface $default_renderer)
Base class for all component renderers.
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.