/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
lib/internal/Magento/Framework/Data/AbstractDataObject.php
55 строк
1 KB
Alexandra Zota
ACP2E-4019: CE copyright updates for 2.4.9-beta1
22 окт 2025, 17:47
22 окт 2025, 17:47
1b769b7
Код
Авторство
О чём код?
<?php /** * Copyright 2014 Adobe * All Rights Reserved. */ namespace Magento\Framework\Data; /** * Base Class for simple data Objects * @SuppressWarnings(PHPMD.NumberOfChildren) */ abstract class AbstractDataObject { /** * @var array */ protected $data; /** * Return Data Object data in array format. * * @return array */ public function toArray() { $data = $this->data; $hasToArray = function ($model) { return is_object($model) && method_exists($model, 'toArray') && is_callable([$model, 'toArray']); }; foreach ($data as $key => $value) { if ($hasToArray($value)) { $data[$key] = $value->toArray(); } elseif (is_array($value)) { foreach ($value as $nestedKey => $nestedValue) { if ($hasToArray($nestedValue)) { $value[$nestedKey] = $nestedValue->toArray(); } } $data[$key] = $value; } } return $data; } /** * Retrieves a value from the data array if set, or null otherwise. * * @param string $key * @return mixed|null */ protected function get($key) { return $this->data[$key] ?? null; } }