/** * Fetches embed information from the given endpoint. * * @param string $endpoint Endpoint to fetch informations from. * @param string $format Response format. * @return Media Embed informations. */ protected function _embedEndpoint($endpoint, $format) { $response = $this->_Http->get($endpoint); switch ($format) { case self::json: $data = Json::parse($response); break; case self::xml: $data = Xml::parse($response); break; default: throw new Exception('Unsupported response format.'); } return new Media(Hash::reindex($data, ['author_name' => 'authorName', 'author_url' => 'authorUrl', 'provider_name' => 'providerName', 'provider_url' => 'providerUrl', 'cache_age' => 'cacheAge', 'thumbnail_url' => 'thumbnailUrl', 'thumbnail_width' => 'thumbnailWidth', 'thumbnail_height' => 'thumbnailHeight'])); }
/** * {@inheritDoc} */ protected function _embed($url, array $options) { return new Media(Hash::reindex($this->_extractInformations($url), ['og:type' => 'type', 'og:title' => 'title', 'og:description' => 'description', 'og:site_name' => 'providerName', 'og:image' => 'thumbnailUrl', 'og:image:url' => 'thumbnailUrl', 'og:image:width' => 'width', 'og:image:height' => 'height', 'og:video:width' => 'width', 'og:video:height' => 'height', 'og:url' => 'url'])); }
/** * */ public function testReindex() { $data = Hash::reindex(['one' => 'value'], ['one' => 'two']); $this->assertEquals(['two' => 'value'], $data); }
/** * {@inheritDoc} */ public function present(Media $Media) { return $Media->setProperties(Hash::reindex($Media->properties(), $this->_mapping)); }