You are here

public function JSDelivr::formatData in Libraries CDN API 8

Same name and namespace in other branches
  1. 7 src/Plugin/LibrariesCDN/JSDelivr.php \Drupal\libraries_cdn\Plugin\LibrariesCDN\JSDelivr::formatData()

Return the data to use in each method.

Parameters

string $function: The method name.

array $data: The data from query.

Return value

array The resulting array.

Overrides CdnBase::formatData

File

src/Plugin/LibrariesCdn/JsDelivr.php, line 44
Plugin: jsDelivr.

Class

JSDelivr
Class JsDelivr.

Namespace

Drupal\libraries_cdn\Plugin\LibrariesCdn

Code

public function formatData($function, array $data = array()) {
  switch ($function) {
    case 'getVersions':
      return isset($data[0]) && isset($data[0]['versions']) ? $data[0]['versions'] : array();
    case 'getFiles':
      return isset($data[0]) && isset($data[0]['assets']) ? $data[0]['assets'] : array();
    case 'getLatestVersion':
      return isset($data['lastversion']) ? $data['lastversion'] : NULL;
    case 'getInformation':
      return isset($data[0]) ? $data[0] : array();
    default:
      return $data;
  }
}