yii\mongodb\ActiveRecord::toArrayInternal PHP Method

toArrayInternal() private method

Converts data to array recursively, converting MongoDB BSON objects to readable values.
Since: 2.1
private toArrayInternal ( mixed $data ) : array
$data mixed the data to be converted into an array.
return array the array representation of the data.
    private function toArrayInternal($data)
    {
        if (is_array($data)) {
            foreach ($data as $key => $value) {
                if (is_array($value)) {
                    $data[$key] = $this->toArrayInternal($value);
                }
                if (is_object($value)) {
                    if ($value instanceof Type) {
                        $data[$key] = $this->dumpBsonObject($value);
                    } else {
                        $data[$key] = ArrayHelper::toArray($value);
                    }
                }
            }
            return $data;
        } elseif (is_object($data)) {
            return ArrayHelper::toArray($data);
        } else {
            return [$data];
        }
    }