Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
serializeobject.php
1<?php
2
3
4namespace Bitrix\Calendar;
5
6
7trait SerializeObject
8{
9 public function __serialize(): array
10 {
11 return (array)unserialize($this->serialize(), ['allowed_classes' => false]);
12 }
13
17 public function serialize(): string
18 {
19 return serialize(get_object_vars($this));
20 }
21
22 public function __unserialize($data): void
23 {
24 $this->unserialize($data);
25 }
26
30 public function unserialize($serializedData): void
31 {
32 $data = $serializedData;
33
34 if (is_string($data))
35 {
36 $data = unserialize($data, ['allowed_classes' => false]);
37 }
38
39 foreach ($data as $key => $value)
40 {
41 $this->$key = $value;
42 }
43 }
44}