1 | <?php |
||
8 | class DtoEvent implements \JsonSerializable |
||
9 | { |
||
10 | /** |
||
11 | * @var User |
||
12 | * @var Assert\NotBlank |
||
13 | */ |
||
14 | private $user; |
||
15 | |||
16 | private $summary; |
||
17 | |||
18 | private $description; |
||
19 | |||
20 | private $location; |
||
21 | |||
22 | /** |
||
23 | * @var Assert\NotBlank |
||
24 | */ |
||
25 | private $start; |
||
26 | |||
27 | /** |
||
28 | * @var Assert\NotBlank |
||
29 | */ |
||
30 | private $end; |
||
31 | |||
32 | private $googleEventId; |
||
33 | |||
34 | public function __construct(\Google_Service_Calendar_Event $event = null) |
||
35 | { |
||
36 | if ($event && $event instanceof \Google_Service_Calendar_Event) { |
||
37 | $this->summary = $event->getSummary(); |
||
38 | $this->description = $event->getDescription(); |
||
39 | $this->summary = $event->getSummary(); |
||
40 | $this->location = $event->getLocation(); |
||
41 | $this->start = $event->getStart(); |
||
42 | $this->end = $event->getEnd(); |
||
43 | $this->googleEventId = $event->getId(); |
||
44 | } |
||
45 | } |
||
46 | |||
47 | public function jsonSerialize() |
||
48 | { |
||
49 | $description = json_decode($this->description, true); |
||
50 | |||
51 | return [ |
||
52 | 'user' => (int) $description['user'], |
||
53 | 'title' => $this->summary, |
||
54 | 'description' => $description['description'], |
||
55 | 'location' => $this->location, |
||
56 | 'start' => $this->start->dateTime, |
||
57 | 'end' => $this->end->dateTime, |
||
58 | 'id' => $this->googleEventId, |
||
59 | ]; |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @return mixed |
||
64 | */ |
||
65 | public function getSummary() |
||
69 | |||
70 | /** |
||
71 | * @param mixed $summary |
||
72 | */ |
||
73 | public function setSummary($summary) |
||
77 | |||
78 | /** |
||
79 | * @return mixed |
||
80 | */ |
||
81 | public function getDescription() |
||
85 | |||
86 | /** |
||
87 | * @param mixed $description |
||
88 | */ |
||
89 | public function setDescription($description) |
||
93 | |||
94 | /** |
||
95 | * @return mixed |
||
96 | */ |
||
97 | public function getLocation() |
||
101 | |||
102 | /** |
||
103 | * @param mixed $location |
||
104 | */ |
||
105 | public function setLocation($location) |
||
109 | |||
110 | /** |
||
111 | * @return mixed |
||
112 | */ |
||
113 | public function getStart() |
||
117 | |||
118 | /** |
||
119 | * @param mixed $start |
||
120 | */ |
||
121 | public function setStart($start) |
||
125 | |||
126 | /** |
||
127 | * @return mixed |
||
128 | */ |
||
129 | public function getEnd() |
||
133 | |||
134 | /** |
||
135 | * @param mixed $end |
||
136 | */ |
||
137 | public function setEnd($end) |
||
141 | |||
142 | /** |
||
143 | * @return User |
||
144 | */ |
||
145 | public function getUser() |
||
149 | |||
150 | /** |
||
151 | * @param User $user |
||
152 | * |
||
153 | * @return $this |
||
154 | */ |
||
155 | public function setUser($user) |
||
161 | |||
162 | /** |
||
163 | * @return mixed |
||
164 | */ |
||
165 | public function getGoogleEventId() |
||
169 | |||
170 | /** |
||
171 | * @param mixed $googleEventId |
||
172 | * |
||
173 | * @return $this |
||
174 | */ |
||
175 | public function setGoogleEventId($googleEventId) |
||
181 | } |
||
182 |