/** * Return an associative array of the data * * Skip the properties that start with an underscore as they are considered private * * @return array */ public function toArray() { $data = parent::toArray(); foreach ($this->getComputedProperties() as $property) { if ($this->{$property} instanceof ModelEntityInterface) { $data[$property] = array_values($this->{$property}->toArray()); } else { $data[$property] = $this->{$property}; } } foreach (array_keys($data) as $key) { if (substr($key, 0, 1) === '_') { unset($data[$key]); } } return $data; }
/** * Return an associative array of the data * * Skip the properties that start with an underscore as they are considered private * * @return array */ public function toArray() { $data = parent::toArray(); foreach (array_keys($data) as $key) { if (substr($key, 0, 1) === '_') { unset($data[$key]); } } return $data; }