![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/amasty/base/Model/ |
<?php declare(strict_types=1); /** * @author Amasty Team * @copyright Copyright (c) Amasty (https://www.amasty.com) * @package Magento 2 Base Package */ namespace Amasty\Base\Model; use Magento\Framework\DataObject; /** * phpcs:ignoreFile */ class SimpleDataObject extends DataObject { /** * @param array $keys * @return array */ public function toArray(array $keys = []): array { if (empty($keys)) { return $this->__toArray(); } return parent::toArray($keys); } public function __toArray(): array { $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; } }