ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
Legacy.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2016 Timon Amstutz <timon.amstutz@ilub.unibe.ch> Extended GPL, see docs/LICENSE */
4 
6 
7 use ILIAS\UI\Component as C;
13 
18 class Legacy implements C\Legacy\Legacy
19 {
20  use ComponentHelper;
22 
26  private $content;
27 
32 
36  private $signal_list;
37 
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()
56  {
57  return $this->content;
58  }
59 
63  public function withCustomSignal(string $signal_name, string $js_code) : \ILIAS\UI\Component\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 
95  public function getAllCustomSignals() : array
96  {
97  return $this->signal_list;
98  }
99 
106  private function registerSignalAndCustomCode(string $signal_name, string $js_code)
107  {
108  $this->signal_list[$signal_name] = array(
109  'signal' => $this->signal_generator->create(),
110  'js_code' => $js_code
111  );
112  }
113 }
Class Factory.
__construct($content, SignalGeneratorInterface $signal_generator)
Legacy constructor.
Definition: Legacy.php:43
Class ChatMainBarProvider .
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
trait ComponentHelper
Provides common functionality for component implementations.
checkStringArg($which, $value)
Throw an InvalidArgumentException if $value is no string.
registerSignalAndCustomCode(string $signal_name, string $js_code)
Registers new signal with its JavaScript code in the signal list.
Definition: Legacy.php:106
getAllCustomSignals()
Get a list of all registered signals and their custom JavaScript code.
Definition: Legacy.php:95
withCustomSignal(string $signal_name, string $js_code)
Definition: Legacy.php:63