@@ 199-231 (lines=33) @@ | ||
196 | foreach ($this->getFillable() as $key) { |
|
197 | if ($this->checkOnyExceptInArray($key, $options)) { |
|
198 | if (is_object($this->$key)) { |
|
199 | if ($this->$key instanceof \DateTime) { |
|
200 | $metaDataKey = $classMetadata->hasField($key) ? $classMetadata->getFieldMapping($key) : null; |
|
201 | ||
202 | if ($this->$key) { |
|
203 | $dateFormat = 'Y-m-d H:i:s'; |
|
204 | ||
205 | if ($metaDataKey) { |
|
206 | switch ($metaDataKey['type']) { |
|
207 | case 'date': |
|
208 | $dateFormat = 'Y-m-d'; |
|
209 | break; |
|
210 | ||
211 | case 'time': |
|
212 | $dateFormat = 'H:i:s'; |
|
213 | break; |
|
214 | ||
215 | default: |
|
216 | break; |
|
217 | } |
|
218 | } |
|
219 | $array[$key] = $this->$key->format($dateFormat); |
|
220 | } |
|
221 | } elseif ($this->$key instanceof \MongoTimestamp) { |
|
222 | $array[$key] = $this->$key; |
|
223 | } elseif ($this->$key instanceof ArrayCollection || $this->$key instanceof PersistentCollection) { |
|
224 | $ids = []; |
|
225 | foreach ($this->$key->getValues() as $item) { |
|
226 | $ids[] = $item->getId(); |
|
227 | } |
|
228 | $array[$key] = $ids; |
|
229 | } else { |
|
230 | $array[$key] = $this->$key->getId(); |
|
231 | } |
|
232 | } else { |
|
233 | $array[$key] = $this->$key; |
|
234 | } |
@@ 205-239 (lines=35) @@ | ||
202 | ||
203 | foreach ($this->getFillable() as $key) { |
|
204 | if ($this->checkOnyExceptInArray($key, $options)) { |
|
205 | if (is_object($this->$key)) { |
|
206 | if ($this->$key instanceof DateTime) { |
|
207 | $metaDataKey = $classMetadata->hasField($key) ? $classMetadata->getFieldMapping($key) : null; |
|
208 | ||
209 | if ($this->$key) { |
|
210 | $dateFormat = 'Y-m-d'; |
|
211 | ||
212 | if ($metaDataKey) { |
|
213 | switch ($metaDataKey['type']) { |
|
214 | case 'datetime': |
|
215 | $dateFormat = 'Y-m-d H:i:s'; |
|
216 | break; |
|
217 | ||
218 | case 'time': |
|
219 | $dateFormat = 'H:i:s'; |
|
220 | break; |
|
221 | ||
222 | default: |
|
223 | break; |
|
224 | } |
|
225 | } |
|
226 | $array[$key] = $this->$key->format($dateFormat); |
|
227 | } |
|
228 | } elseif ($this->$key instanceof ArrayCollection || $this->$key instanceof PersistentCollection) { |
|
229 | $ids = []; |
|
230 | foreach ($this->$key->getValues() as $item) { |
|
231 | $ids[] = $item->getId(); |
|
232 | } |
|
233 | $array[$key] = $ids; |
|
234 | } else { |
|
235 | $array[$key] = $this->$key->getId(); |
|
236 | } |
|
237 | } else { |
|
238 | $array[$key] = $this->$key; |
|
239 | } |
|
240 | } |
|
241 | } |
|
242 |