1 | <?php |
||
16 | trait Storable |
||
17 | { |
||
18 | /** |
||
19 | * @var \JsonSerializable |
||
20 | */ |
||
21 | protected $object; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $filename; |
||
27 | |||
28 | /** |
||
29 | * @var int|null |
||
30 | */ |
||
31 | protected $file_modification_time = null; |
||
32 | |||
33 | /** |
||
34 | * @param string $filename |
||
35 | */ |
||
36 | public function setFilename($filename) |
||
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | public function regen() |
||
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | public function delete() |
||
62 | |||
63 | /** |
||
64 | * @return string |
||
65 | */ |
||
66 | protected function getFilename() |
||
70 | |||
71 | /** |
||
72 | * @return \JsonSerializable |
||
73 | */ |
||
74 | protected function getObject() |
||
78 | |||
79 | /** |
||
80 | * @param \JsonSerializable $object |
||
81 | */ |
||
82 | protected function setObject(\JsonSerializable $object) |
||
86 | |||
87 | protected function loadObjectIfNeeded() |
||
100 | |||
101 | /** |
||
102 | * @return array|null |
||
103 | */ |
||
104 | protected function getFileContent() |
||
118 | |||
119 | /** |
||
120 | * @return \JsonSerializable |
||
121 | */ |
||
122 | abstract protected function createNewObject(); |
||
123 | |||
124 | /** |
||
125 | * @param array $file_content |
||
126 | * |
||
127 | * @return \JsonSerializable |
||
128 | */ |
||
129 | abstract protected function createObjectFromFileContent(array $file_content); |
||
130 | |||
131 | /** |
||
132 | * @return int|null |
||
133 | */ |
||
134 | protected function getFileModificationTime() |
||
140 | |||
141 | /** |
||
142 | * @return bool |
||
143 | */ |
||
144 | protected function hasFileBeenUpdated() |
||
152 | |||
153 | /** |
||
154 | * |
||
155 | */ |
||
156 | protected function createAndSaveObject() |
||
162 | |||
163 | protected function saveObject(\JsonSerializable $object) |
||
168 | } |
||
169 |