| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\DiscussionTools; |
| 4 |
|
| 5 |
use JsonSerializable; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
class OverflowMenuItem implements JsonSerializable { |
| 11 |
|
| 12 |
private string $icon; |
| 13 |
private string $label; |
| 14 |
private array $data; |
| 15 |
private string $id; |
| 16 |
private int $weight; |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
public function __construct( |
| 27 |
string $id, |
| 28 |
string $icon, |
| 29 |
string $label, |
| 30 |
int $weight = 0, |
| 31 |
array $data = [] |
| 32 |
) { |
| 33 |
$this->id = $id; |
| 34 |
$this->icon = $icon; |
| 35 |
$this->label = $label; |
| 36 |
$this->weight = $weight; |
| 37 |
$this->data = $data; |
| 38 |
} |
| 39 |
|
| 40 |
public function jsonSerialize(): array { |
| 41 |
$data = $this->data; |
| 42 |
|
| 43 |
$data['id'] = $this->id; |
| 44 |
return [ |
| 45 |
'id' => $this->id, |
| 46 |
'data' => $data, |
| 47 |
'icon' => $this->icon, |
| 48 |
'label' => $this->label, |
| 49 |
]; |
| 50 |
} |
| 51 |
|
| 52 |
public function getId(): string { |
| 53 |
return $this->id; |
| 54 |
} |
| 55 |
|
| 56 |
public function getWeight(): int { |
| 57 |
return $this->weight; |
| 58 |
} |
| 59 |
} |