public function toArray($fetchType = Model::FETCH_ALL)
    {
        if ($fetchType === Model::FETCH_RAW) {
            return $this->attributes;
        }

        $attributes = array();

        if (empty($this->attributes)) {
            $this->attributes = array();
        }

        if ($fetchType === Model::FETCH_ALL or $fetchType === Model::FETCH_HIDDEN) {
            $attributes['$type'] = $this->getClass();
            $attributes['$id'] = $this->getId();

            foreach ($this->attributes as $key => $value) {
                if ($key[0] === '$') {
                    $attributes[$key] = $value;
                }
            }
        }

        if ($fetchType === Model::FETCH_ALL or $fetchType === Model::FETCH_PUBLISHED) {
            foreach ($this->attributes as $key => $value) {
                if ($key[0] !== '$') {
                    $attributes[$key] = $value;
                }
            }
        }

        return $attributes;
    }