|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace CultuurNet\UDB3\Event\Events; |
|
4
|
|
|
|
|
5
|
|
|
use CultuurNet\UDB3\Calendar; |
|
6
|
|
|
use CultuurNet\UDB3\Event\EventType; |
|
7
|
|
|
use CultuurNet\UDB3\Event\ValueObjects\LocationId; |
|
8
|
|
|
use CultuurNet\UDB3\Offer\Events\AbstractEvent; |
|
9
|
|
|
use CultuurNet\UDB3\Theme; |
|
10
|
|
|
use CultuurNet\UDB3\Title; |
|
11
|
|
|
|
|
12
|
|
|
final class MajorInfoUpdated extends AbstractEvent |
|
13
|
|
|
{ |
|
14
|
|
|
use BackwardsCompatibleEventTrait; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @var Title |
|
18
|
|
|
*/ |
|
19
|
|
|
private $title; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @var EventType |
|
23
|
|
|
*/ |
|
24
|
|
|
private $eventType; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @var Theme|null |
|
28
|
|
|
*/ |
|
29
|
|
|
private $theme; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var LocationId |
|
33
|
|
|
*/ |
|
34
|
|
|
private $location; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var Calendar |
|
38
|
|
|
*/ |
|
39
|
|
|
private $calendar; |
|
40
|
|
|
|
|
41
|
|
|
public function __construct( |
|
42
|
|
|
string $eventId, |
|
43
|
|
|
Title $title, |
|
44
|
|
|
EventType $eventType, |
|
45
|
|
|
LocationId $location, |
|
46
|
|
|
Calendar $calendar, |
|
47
|
|
|
Theme $theme = null |
|
48
|
|
|
) { |
|
49
|
|
|
parent::__construct($eventId); |
|
50
|
|
|
|
|
51
|
|
|
$this->title = $title; |
|
52
|
|
|
$this->eventType = $eventType; |
|
53
|
|
|
$this->location = $location; |
|
54
|
|
|
$this->calendar = $calendar; |
|
55
|
|
|
$this->theme = $theme; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function getTitle(): Title |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->title; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function getEventType(): EventType |
|
64
|
|
|
{ |
|
65
|
|
|
return $this->eventType; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function getTheme(): ?Theme |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->theme; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function getCalendar(): Calendar |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->calendar; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function getLocation(): LocationId |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->location; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
public function serialize(): array |
|
84
|
|
|
{ |
|
85
|
|
|
$theme = null; |
|
86
|
|
|
if ($this->getTheme() !== null) { |
|
87
|
|
|
$theme = $this->getTheme()->serialize(); |
|
88
|
|
|
} |
|
89
|
|
|
return parent::serialize() + array( |
|
90
|
|
|
'title' => (string)$this->getTitle(), |
|
91
|
|
|
'event_type' => $this->getEventType()->serialize(), |
|
92
|
|
|
'theme' => $theme, |
|
93
|
|
|
'location' => $this->getLocation()->toNative(), |
|
94
|
|
|
'calendar' => $this->getCalendar()->serialize(), |
|
95
|
|
|
); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
public static function deserialize(array $data): MajorInfoUpdated |
|
99
|
|
|
{ |
|
100
|
|
|
return new self( |
|
101
|
|
|
$data['item_id'], |
|
102
|
|
|
new Title($data['title']), |
|
103
|
|
|
EventType::deserialize($data['event_type']), |
|
104
|
|
|
new LocationId($data['location']), |
|
105
|
|
|
Calendar::deserialize($data['calendar']), |
|
106
|
|
|
empty($data['theme']) ? null : Theme::deserialize($data['theme']) |
|
107
|
|
|
); |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|