/** * {@inheritdoc} */ public function castToArray() { return Arr::arToArray($this->model); }
/** * Convert this implementation object to array. * * @param mixed $attributes Something you want to convert to array. * * @return array * * @see Arr::arToArray() */ public function toArray($attributes = null) { if ($this->jsonAble === null) { $jsonAble = array(); if ($attributes === null) { $attributes = $this->attributes; } foreach ($attributes as $key => $value) { if ($value instanceof CActiveRecord) { $jsonAble[$key] = Arr::arToArray($value); } elseif ($value instanceof Arrayable) { $jsonAble[$key] = $value->castToArray(); } elseif (is_object($value)) { $jsonAble[$key] = (array) $value; } elseif (is_array($value)) { $jsonAble[$key] = $this->toArray($value); } else { $jsonAble[$key] = $value; } } $this->jsonAble = $jsonAble; } return $this->jsonAble; }