Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractDataObject.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Framework\Data;
7 
12 abstract class AbstractDataObject
13 {
17  protected $data;
18 
24  public function toArray()
25  {
27  $hasToArray = function ($model) {
28  return is_object($model) && method_exists($model, 'toArray') && is_callable([$model, 'toArray']);
29  };
30  foreach ($data as $key => $value) {
31  if ($hasToArray($value)) {
32  $data[$key] = $value->toArray();
33  } elseif (is_array($value)) {
34  foreach ($value as $nestedKey => $nestedValue) {
35  if ($hasToArray($nestedValue)) {
36  $value[$nestedKey] = $nestedValue->toArray();
37  }
38  }
39  $data[$key] = $value;
40  }
41  }
42  return $data;
43  }
44 
51  protected function get($key)
52  {
53  return $this->data[$key] ?? null;
54  }
55 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$value
Definition: gender.phtml:16