ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
DecoratorApplierTrait.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
29
33trait DecoratorApplierTrait
34{
35 private function applyTopics(HasHelpTopics $component, isDecorateable $item): Component
36 {
37 return $component->withHelpTopics(...$item->getTopics());
38 }
39
40 public function applyComponentDecorator(Component $component, isGlobalScreenItem $item): Component
41 {
42 if (!$item instanceof isDecorateable) {
43 return $component;
44 }
45
46 if (!$component instanceof JavaScriptBindable) {
47 return $component;
48 }
49
50 $c = $item->getComponentDecorator();
51 if ($c !== null) {
52 return $c($component);
53 }
54
55 return $component;
56 }
57
58 public function applySymbolDecorator(Symbol $symbol, isGlobalScreenItem $item): Symbol
59 {
60 $c = $item->getSymbolDecorator();
61 if ($c !== null) {
62 return $c($symbol);
63 }
64
65 return $symbol;
66 }
67}
$c
Definition: deliver.php:25
A component is the most general form of an entity in the UI.
Definition: Component.php:28
withHelpTopics(Topic ... $topics)
Let this component have the given topics.
Interface to be extended by components that have the possibility to bind to Javascript.
This describes a symbol.
Definition: Symbol.php:30
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.