ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
State.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26use ILIAS\UI\Implementation\Component\ComponentHelper;
28
32class State implements I\State\State
33{
34 use ComponentHelper;
35
36 public const CMD_CLOSE = 'close';
37 public const CMD_REDIRECT = 'redirect';
38
39 protected array $buttons = [];
40 protected string $cmd = 'show';
41 protected array $params = [];
42 protected string $title = '';
43
44 public function __construct(
45 protected ?I\IsPromptContent $content
46 ) {
47 }
48
49 public function getTitle(): string
50 {
51 return $this->title ? $this->title : $this->content->getPromptTitle();
52 }
53
54 public function withTitle(string $title): self
55 {
56 $clone = clone $this;
57 $clone->title = $title;
58 return $clone;
59 }
60
61 public function withContent(I\IsPromptContent $content): self
62 {
63 $clone = clone $this;
64 $clone->content = $content;
65 return $clone;
66 }
67
71 public function getContent(): ?I\IsPromptContent
72 {
73 return $this->content;
74 }
75
79 public function getButtons(): array
80 {
81 return $this->content->getPromptButtons();
82 }
83
84 public function withCloseModal(bool $flag): self
85 {
86 return $this->withCommand($flag ? self::CMD_CLOSE : '');
87 }
88
89 public function withRedirect(URI $redirect): self
90 {
91 $clone = $this->withCommand(self::CMD_REDIRECT);
92 $clone->params = [
93 self::CMD_REDIRECT => $redirect->__toString()
94 ];
95 return $clone;
96 }
97
98 protected function withCommand(string $cmd)
99 {
100 $clone = clone $this;
101 $clone->cmd = $cmd;
102 return $clone;
103 }
104
105 public function getCommand(): string
106 {
107 return $this->cmd;
108 }
109
110 public function getParameters(): array
111 {
112 return $this->params;
113 }
114}
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
__toString()
Definition: URI.php:337
__construct(protected ?I\IsPromptContent $content)
Definition: State.php:44
withContent(I\IsPromptContent $content)
Definition: State.php:61
A component is the most general form of an entity in the UI.
Definition: Component.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21