You are here

protected function OEmbedProcessor::getProviderUri in Gutenberg 8.2

Get a configured provider for the oEmbed resource.

Parameters

string $url: The resource url to find a provider for.

Return value

array Array containing [regex, provider url].

1 call to OEmbedProcessor::getProviderUri()
OEmbedProcessor::processBlock in src/BlockProcessor/OEmbedProcessor.php
Process the Gutenberg block and its content.

File

src/BlockProcessor/OEmbedProcessor.php, line 246

Class

OEmbedProcessor
Processes oEmbed blocks.

Namespace

Drupal\gutenberg\BlockProcessor

Code

protected function getProviderUri($url) {
  foreach ($this
    ->getOembedProviders() as $matchmask => $data) {
    $provider_url = NULL;
    $regex = NULL;
    list($provider_url, $regex) = $data;
    $regex = preg_replace('/\\s+/', '', $regex);
    if ($regex === 'false') {
      $regex = FALSE;
    }
    if (!$regex) {
      $matchmask = '#' . str_replace('___wildcard___', '(.+)', preg_quote(str_replace('*', '___wildcard___', $matchmask), '#')) . '#i';
    }
    if (preg_match($matchmask, $url)) {
      $provider = $provider_url;
      return [
        $regex,
        $provider,
      ];
    }
  }
  return [
    NULL,
    NULL,
  ];
}