ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
Legacy.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 
23 use ILIAS\UI\Component as C;
29 
34 class Legacy implements C\Legacy\Legacy
35 {
36  use ComponentHelper;
38 
39  private string $content;
41  private array $signal_list;
42 
43  public function __construct(string $content, SignalGeneratorInterface $signal_generator)
44  {
45  $this->checkStringArg("content", $content);
46 
47  $this->content = $content;
48  $this->signal_generator = $signal_generator;
49  $this->signal_list = array();
50  }
51 
55  public function getContent(): string
56  {
57  return $this->content;
58  }
59 
63  public function withCustomSignal(string $signal_name, string $js_code): C\Legacy\Legacy
64  {
65  $clone = clone $this;
66  $clone->registerSignalAndCustomCode($signal_name, $js_code);
67  return $clone;
68  }
69 
73  public function getCustomSignal(string $signal_name): Signal
74  {
75  if (!key_exists($signal_name, $this->signal_list)) {
76  throw new InvalidArgumentException("Signal with name $signal_name is not registered");
77  }
78 
79  return $this->signal_list[$signal_name]['signal'];
80  }
81 
94  public function getAllCustomSignals(): array
95  {
96  return $this->signal_list;
97  }
98 
102  private function registerSignalAndCustomCode(string $signal_name, string $js_code): void
103  {
104  $this->signal_list[$signal_name] = array(
105  'signal' => $this->signal_generator->create(),
106  'js_code' => $js_code
107  );
108  }
109 }
__construct(string $content, SignalGeneratorInterface $signal_generator)
Definition: Legacy.php:43
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.
registerSignalAndCustomCode(string $signal_name, string $js_code)
Registers new signal with its JavaScript code in the signal list.
Definition: Legacy.php:102
getAllCustomSignals()
Get a list of all registered signals and their custom JavaScript code.
Definition: Legacy.php:94
SignalGeneratorInterface $signal_generator
Definition: Legacy.php:40
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21
withCustomSignal(string $signal_name, string $js_code)
Definition: Legacy.php:63