/** * @inheritdoc */ public function readLink(LinkInterface $link) { $client = $this->getClient(); try { $response = $client->request('GET', $link->getUrl(), array_merge($this->config, ['on_stats' => function (TransferStats $stats) use(&$link) { $link->setEffectiveUrl($stats->getEffectiveUri()); }])); $link->setContent($response->getBody())->setContentType($response->getHeader('Content-Type')[0]); } catch (ConnectException $e) { $link->setContent(false)->setContentType(false); } return $link; }
/** * @inheritdoc */ public function parseLink(LinkInterface $link) { preg_match(static::PATTERN, $link->getUrl(), $matches); $this->getPreview()->setId($matches[1])->setEmbed('<iframe id="viplayer" width="640" height="390" src="//player.vimeo.com/video/' . $this->getPreview()->getId() . '"" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'); return $this; }
/** * @inheritdoc */ public function canParseLink(LinkInterface $link) { return !filter_var($link->getUrl(), FILTER_VALIDATE_URL) === false; }
/** * @inheritdoc */ public function parseLink(LinkInterface $link) { preg_match(static::PATTERN, $link->getUrl(), $matches); $this->getPreview()->setId($matches[1])->setEmbed('<iframe id="ytplayer" type="text/html" width="640" height="390" src="//www.youtube.com/embed/' . $this->getPreview()->getId() . '" frameborder="0"></iframe>'); return $this; }