-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathElement.php
More file actions
65 lines (55 loc) · 1.47 KB
/
Copy pathElement.php
File metadata and controls
65 lines (55 loc) · 1.47 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace Tgallice\FBMessenger\Model\Attachment\Template\Generic;
use Tgallice\FBMessenger\Model\Button;
use Tgallice\FBMessenger\Model\Attachment\Template\AbstractElement;
use Tgallice\FBMessenger\Model\DefaultAction;
class Element extends AbstractElement
{
/**
* @var null|DefaultAction
*/
private $defaultAction;
/**
* @var null|Button[]
*/
private $buttons;
/**
* @param string $title
*/
public function __construct($title, $subtitle = null, $imageUrl = null, ?array $buttons = null, ?DefaultAction $defaultAction = null)
{
parent::__construct($title, $subtitle, $imageUrl);
if (count($buttons) > 3) {
throw new \InvalidArgumentException('A generic element can not have more than 3 buttons.');
}
$this->buttons = $buttons;
$this->defaultAction = $defaultAction;
}
/**
* @return null|Button[]
*/
public function getButtons()
{
return $this->buttons;
}
/**
* @return null|DefaultAction
*/
public function getDefaultAction()
{
return $this->defaultAction;
}
/**
* @return array
*/
public function jsonSerialize()
{
return [
'title' => $this->getTitle(),
'image_url' => $this->getImageUrl(),
'subtitle' => $this->getSubtitle(),
'buttons' => $this->buttons,
'default_action' => $this->defaultAction,
];
}
}