You are here

protected function MediaElementConfigForm::getApiData in MediaElement 8

Get the results from the CDN.

Parameters

array $params: Optional query paramaters to pass onto the URL.

Return value

object The data from the API.

1 call to MediaElementConfigForm::getApiData()
MediaElementConfigForm::getVersionList in src/Form/MediaElementConfigForm.php
Gets the list of available version numbers for the library.

File

src/Form/MediaElementConfigForm.php, line 47

Class

MediaElementConfigForm
Configuration form for MediaElement.js module.

Namespace

Drupal\mediaelement\Form

Code

protected function getApiData($params = []) {

  // @todo: Use dependency injection for this.
  $client = \Drupal::httpClient();
  $url = empty($params) ? $this->cndjsUrl : $this->cndjsUrl . '?' . http_build_query($params);
  try {
    $res = $client
      ->get($url);
    return json_decode($res
      ->getBody());
  } catch (RequestException $e) {
    watchdog_exception('mediaelement', $e
      ->getMessage());
  }
}