ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ComponentDecoratorTrait.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\GlobalScreen\Scope;
22 
23 use Closure;
29 
34 {
35  use CheckClosureTrait;
36 
37  private ?Closure $component_decorator = null;
38  private ?Closure $triggerer_decorator = null;
39  private ?Closure $symbol_decorator = null;
40 
41  private array $topics = [];
42 
43  public function withTopics(Topic ...$topics): self
44  {
45  $this->topics = $topics;
46 
47  return $this;
48  }
49 
50  public function getTopics(): array
51  {
52  return $this->topics;
53  }
54 
55  public function addComponentDecorator(Closure $component_decorator): self
56  {
57  $this->checkClosureForSignature($component_decorator, Component::class);
58 
59  if ($this->component_decorator instanceof Closure) {
60  $existing = $this->component_decorator;
61  $this->component_decorator = static function (Component $c) use (
62  $component_decorator,
63  $existing
64  ): Component {
65  $component = $existing($c);
66 
67  return $component_decorator($component);
68  };
69  } else {
70  $this->component_decorator = $component_decorator;
71  }
72 
73  return $this;
74  }
75 
76  public function getComponentDecorator(): ?Closure
77  {
79  }
80 
81  public function addSymbolDecorator(Closure $symbol_decorator): isDecorateable
82  {
83  $this->checkClosureForSignature($symbol_decorator, Symbol::class);
84 
85  if ($this->symbol_decorator instanceof Closure) {
86  $existing = $this->symbol_decorator;
87  $this->symbol_decorator = static function (Symbol $c) use ($symbol_decorator, $existing): Symbol {
88  $component = $existing($c);
89 
90  return $symbol_decorator($component);
91  };
92  } else {
93  $this->symbol_decorator = $symbol_decorator;
94  }
95 
96  return $this;
97  }
98 
99  public function getSymbolDecorator(): ?Closure
100  {
102  }
103 }
This describes a symbol.
Definition: Symbol.php:29
This is just a class that marks a string as a help topic.
Definition: Topic.php:26
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$c
Definition: deliver.php:9
addSymbolDecorator(Closure $symbol_decorator)
addComponentDecorator(Closure $component_decorator)