ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ComponentDecoratorTrait.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use Closure;
27
32{
33 use CheckClosureTrait;
34
35 private ?Closure $component_decorator = null;
36 private ?Closure $triggerer_decorator = null;
37 private ?Closure $symbol_decorator = null;
38
39 private array $topics = [];
40
41 public function withTopics(Topic ...$topics): self
42 {
43 $this->topics = $topics;
44
45 return $this;
46 }
47
48 public function getTopics(): array
49 {
50 return $this->topics;
51 }
52
53 public function addComponentDecorator(Closure $component_decorator): self
54 {
55 $this->checkClosureForSignature($component_decorator, Component::class);
56
57 if ($this->component_decorator instanceof Closure) {
59 $this->component_decorator = static function (Component $c) use (
61 $existing
62 ): Component {
63 $component = $existing($c);
64
65 return $component_decorator($component);
66 };
67 } else {
68 $this->component_decorator = $component_decorator;
69 }
70
71 return $this;
72 }
73
74 public function getComponentDecorator(): ?Closure
75 {
77 }
78
80 {
81 $this->checkClosureForSignature($symbol_decorator, Symbol::class);
82
83 if ($this->symbol_decorator instanceof Closure) {
84 $existing = $this->symbol_decorator;
85 $this->symbol_decorator = static function (Symbol $c) use ($symbol_decorator, $existing): Symbol {
86 $component = $existing($c);
87
88 return $symbol_decorator($component);
89 };
90 } else {
91 $this->symbol_decorator = $symbol_decorator;
92 }
93
94 return $this;
95 }
96
97 public function getSymbolDecorator(): ?Closure
98 {
100 }
101}
This is just a class that marks a string as a help topic.
Definition: Topic.php:27
$c
Definition: deliver.php:25
A component is the most general form of an entity in the UI.
Definition: Component.php:28
This describes a symbol.
Definition: Symbol.php:30
addComponentDecorator(Closure $component_decorator)
addSymbolDecorator(Closure $symbol_decorator)