ILIAS  release_7 Revision v7.30-3-g800a261c036
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
13
18class Legacy implements C\Legacy\Legacy
19{
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}
An exception for terminatinating execution or to throw for unit testing.
__construct($content, SignalGeneratorInterface $signal_generator)
Legacy constructor.
Definition: Legacy.php:43
withCustomSignal(string $signal_name, string $js_code)
Definition: Legacy.php:63
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
This exception indicates that an UI component was accepted by the JF but is not backed by a real impl...
A component is the most general form of an entity in the UI.
Definition: Component.php:14
checkStringArg($which, $value)
Throw an InvalidArgumentException if $value is no string.
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
trait ComponentHelper
Provides common functionality for component implementations.
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.