protected function getValue($value, $spaceId, $locale)
    {
        if (is_scalar($value)) {
            return Option::fromValue($value);
        }
        if (is_object($value)) {
            // TODO: Generalize?
            if ($value instanceof \DateTime) {
                return Option::fromValue($value);
            }
        }
        if (is_array($value)) {
            if ($this->isLink($value)) {
                /** @var ContentfulItem $entry */
                $optionalEntry = $this->contentAdapter->findByTypeAndId($spaceId, $value['sys']['linkType'], $value['sys']['id']);
                if ($optionalEntry->isEmpty()) {
                    return None::create();
                }
                $entry = $optionalEntry->get();

                $fields                       = $this->localize($entry, $locale);
                $fields['cfMeta']             = array();
                $fields['cfMeta']['itemType'] = $value['sys']['linkType'];
                $fields['cfMeta']['itemId']   = $value['sys']['id'];
                $fields['cfMeta']['url']      = $entry->getContentfulUrl();
                if ($entry instanceof ContentfulEntry) {
                    /** @var ContentfulEntry $entry */
                    $fields['cfMeta']['contentType'] = $this->contentAdapter->getContentTypeById($spaceId, $entry->getContentTypeId())->getName();
                    $fields['cfMeta']['itemName']    = $entry->getName();
                    $fields['cfMeta']['createdAt']   = $entry->getCreatedAt();
                    $fields['cfMeta']['updatedAt']   = $entry->getUpdatedAt();
                }
                if ($entry instanceof ContentfulAsset) {
                    /** @var ContentfulAsset $entry */
                    $fields['cfMeta']['itemName']    = $fields['title'];
                    $fields['cfMeta']['contentType'] = 'Asset';
                    $fields['cfMeta']['createdAt']   = $entry->getCreatedAt();
                    $fields['cfMeta']['updatedAt']   = $entry->getUpdatedAt();
                }
                return Option::fromValue($this->createView($fields, $spaceId, $locale));
            } else {
                $newValue = array();
                foreach ($value as $k => $v) {
                    $vv = $this->getValue($v, $spaceId, $locale);
                    if ($vv->isDefined()) {
                        $newValue[$k] = $vv->get();
                    }

                }
                return Option::fromValue($newValue);
            }
        }
    }
protected function getValue($value, $spaceId, $locale)
    {
        if (is_scalar($value)) {
            return Option::fromValue($value);
        }
        if (is_object($value)) {
            // TODO: Generalize?
            if ($value instanceof \DateTime) {
                return Option::fromValue($value);
            }
        }
        if (is_array($value)) {
            if ($this->isLink($value)) {
                /** @var ContentfulItem $entry */
                $optionalEntry = $this->contentAdapter->findByTypeAndId($spaceId, $value['sys']['linkType'], $value['sys']['id']);
                if ($optionalEntry->isEmpty()) {
                    return None::create();
                }
                $entry = $optionalEntry->get();

                $fields                       = $this->localize($entry, $locale);
                $fields['cfMeta']             = array();
                $fields['cfMeta']['itemType'] = $value['sys']['linkType'];
                $fields['cfMeta']['itemId']   = $value['sys']['id'];
                $fields['cfMeta']['url']      = $entry->getContentfulUrl();
                if ($entry instanceof ContentfulEntry) {
                    /** @var ContentfulEntry $entry */
                    $fields['cfMeta']['contentType'] = $this->contentAdapter->getContentTypeById($spaceId, $entry->getContentTypeId())->getName();
                    $fields['cfMeta']['itemName']    = $entry->getName();
                    $fields['cfMeta']['createdAt']   = $entry->getCreatedAt();
                    $fields['cfMeta']['updatedAt']   = $entry->getUpdatedAt();
                }
                if ($entry instanceof ContentfulAsset) {
                    /** @var ContentfulAsset $entry */
                    $fields['cfMeta']['itemName']    = $fields['title'];
                    $fields['cfMeta']['contentType'] = 'Asset';
                    $fields['cfMeta']['createdAt']   = $entry->getCreatedAt();
                    $fields['cfMeta']['updatedAt']   = $entry->getUpdatedAt();
                }
                return Option::fromValue($this->createView($fields, $spaceId, $locale));
            } else {
                $newValue = array();
                foreach ($value as $k => $v) {
                    $vv = $this->getValue($v, $spaceId, $locale);
                    if ($vv->isDefined()) {
                        $newValue[$k] = $vv->get();
                    }

                }
                return Option::fromValue($newValue);
            }
        }
    }
@param mixed  $value
@param string $spaceId
@param string $locale

@return Option