You are here

public function CDNBase::getFiles in Libraries CDN API 7

Return all available file(s).

Parameters

array $version: Filter the returning array with this one.

Return value

array Return an array with available files of the library.

Overrides CDNBaseInterface::getFiles

1 call to CDNBase::getFiles()
CDNBase::getLocalCopy in src/Type/CDNBase.php
Copy a library from the CDN to the local filesystem.
1 method overrides CDNBase::getFiles()
Dummy::getFiles in modules/libraries_cdn_example_plugin/src/Plugin/LibrariesCDN/Dummy.php
Return all available file(s).

File

src/Type/CDNBase.php, line 183
Class CDNBase.

Class

CDNBase
Class CDNBase.

Namespace

Drupal\libraries_cdn\Type

Code

public function getFiles(array $versions = array()) {
  if (!$this
    ->isAvailable()) {
    return array();
  }
  $data = $this
    ->formatData(__FUNCTION__, $this
    ->query($this
    ->getURL(__FUNCTION__)));
  $results = array();
  foreach ($data as $asset) {
    if (isset($asset['version']) && isset($asset['files']) && is_array($asset['files'])) {
      $results[$asset['version']] = $this
        ->convertFiles($asset['files'], $asset['version']);
    }
  }
  return empty($versions) ? $results : array_intersect_key($results, array_combine(array_values($versions), array_values($versions)));
}