public function UrlToVideoFilterService::convertVimeoUrls in URL to Video Filter 8
Same name and namespace in other branches
- 2.0.x src/Service/UrlToVideoFilterService.php \Drupal\url_to_video_filter\Service\UrlToVideoFilterService::convertVimeoUrls()
Converts URLs to embedded Vimeo videos.
Parameters
string $text: The text to be parsed for Vimeo URLs.
Return value
array An array containing the following keys:
- text: The text with the URLs replaced by the YouTube embed code
- url_found: A boolean indicating whether any URLs were found in the given text.
Overrides UrlToVideoFilterServiceInterface::convertVimeoUrls
File
- src/
Service/ UrlToVideoFilterService.php, line 36
Class
- UrlToVideoFilterService
- Service class for the URL To Video Filter module.
Namespace
Drupal\url_to_video_filter\ServiceCode
public function convertVimeoUrls($text) {
$return = [
'text' => $text,
'url_found' => FALSE,
];
$urls = $this
->parseVimeoUrls($text);
if (count($urls)) {
$return['url_found'] = TRUE;
foreach ($urls as $url) {
$embed_code = $this
->convertVimeoUrlToEmbedCode($url);
$return['text'] = str_replace($url, $embed_code, $return['text']);
}
}
return $return;
}