You are here

public function ConfigEntityProvider::request in oEmbed 8

Parameters

$url:

array $params:

Return value

RequestInterface

File

src/Provider/ConfigEntityProvider.php, line 35

Class

ConfigEntityProvider

Namespace

Drupal\oembed\Provider

Code

public function request($url, array $params = array()) {
  if (empty($this->providers)) {
    $this
      ->loadProviders();
  }
  $schemes = self::getSchemes($this->providers);
  $regexes = array_map(array(
    'Drupal\\oembed\\Provider\\ConfigEntityProvider',
    'schemeToRegex',
  ), $schemes);
  $match = array_filter($regexes, function ($regex) use ($url) {
    return (bool) preg_match($regex, $url);
  });
  $providerName = key($match);

  /** @var \Drupal\oembed\Entity\Provider $providerEntity */
  $providerEntity = $this->providers[$providerName];
  $provider = new StandardProvider($providerEntity
    ->getEndpoint(), $providerEntity
    ->getScheme(), array(), array(
    'format' => 'json',
  ));
  return $provider
    ->request($url, $params);
}