-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArticleDialogBox.php
More file actions
48 lines (38 loc) · 1.41 KB
/
ArticleDialogBox.php
File metadata and controls
48 lines (38 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace Imaarov\Patterns\Behavioral\Mediator;
use Imaarov\Patterns\Behavioral\Mediator\Button;
class ArticleDialogBox extends DialogBox {
private ListBox $articlesListBox;
private TextBox $titleTextBox;
private Button $saveButton;
public function simulateUserInteraction()
{
$this->articlesListBox->setSelection("Article 1");
$this->titleTextBox->setcontent("");
$this->titleTextBox->setcontent("Article 2");
echo "\nText Box " . $this->titleTextBox->getcontent();
echo "\n Button " . $this->saveButton->getIsEnable();
}
public function __construct()
{
$this->articlesListBox = new ListBox($this);
$this->titleTextBox = new TextBox($this);
$this->saveButton = new Button($this);
}
public function change(UIControl $uIControl)
{
if($uIControl == $this->articlesListBox)
$this->articleSelection();
else if($uIControl == $this->titleTextBox)
$this->titleChange();
}
private function titleChange() : void {
$content = $this->titleTextBox->getcontent();
$isEmpty = ($content == null || empty($content));
$this->saveButton->setIsEnable($isEmpty);
}
private function articleSelection() : void {
$this->titleTextBox->setcontent($this->articlesListBox->getSelection());
$this->saveButton->setIsEnable(true);
}
}