You are here

public function Dummy::formatData in Libraries CDN API 7

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

modules/libraries_cdn_example_plugin/src/Plugin/LibrariesCDN/Dummy.php, line 49
Plugin: jsDelivr.

Class

Dummy
Class Dummy.

Namespace

Drupal\libraries_cdn_example_plugin\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;
  }
}