class JSDelivr in Libraries CDN API 7
Same name and namespace in other branches
- 8 src/Plugin/LibrariesCdn/JsDelivr.php \Drupal\libraries_cdn\Plugin\LibrariesCdn\JSDelivr
Class JSDelivr.
Plugin annotation
@LibrariesCDNPlugin(
id = "jsdelivr",
description = "jsDelivr Integration",
arguments = {
"@drupal7"
}
)
Hierarchy
- class \Drupal\libraries_cdn\Type\CDNBase extends \Drupal\Component\Plugin\PluginBase implements CDNBaseInterface
- class \Drupal\libraries_cdn\Plugin\LibrariesCDN\JSDelivr
Expanded class hierarchy of JSDelivr
1 file declares its use of JSDelivr
- JSDelivrTest.php in tests/
src/ Plugin/ LibrariesCDN/ JSDelivrTest.php - Contains \Drupal\Tests\Libraries_cdn\Plugin\LibrariesCDN\JSDelivrTest.
File
- src/
Plugin/ LibrariesCDN/ JSDelivr.php, line 25 - Plugin: jsDelivr.
Namespace
Drupal\libraries_cdn\Plugin\LibrariesCDNView source
class JSDelivr extends CDNBase {
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition, Drupal7 $drupal7) {
if (empty($configuration['urls'])) {
$configuration['urls'] = array();
}
$configuration['urls'] += array(
'isAvailable' => 'http://api.jsdelivr.com/v1/jsdelivr/libraries/%s',
'getInformation' => 'http://api.jsdelivr.com/v1/jsdelivr/libraries?name=%s&fields=name,mainfile,lastversion,description,homepage,github,author',
'getVersions' => 'http://api.jsdelivr.com/v1/jsdelivr/libraries?name=%s&fields=versions',
'getFiles' => 'http://api.jsdelivr.com/v1/jsdelivr/libraries?name=%s&fields=assets',
'search' => 'http://api.jsdelivr.com/v1/jsdelivr/libraries?name=*%s*',
'convertFiles' => '//cdn.jsdelivr.net/%s/%s/',
);
parent::__construct($configuration, $plugin_id, $plugin_definition, $drupal7);
}
/**
* {@inheritdoc}
*/
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;
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CDNBase:: |
public | function | ||
CDNBase:: |
public | function |
Return the configuration of the object. Overrides CDNBaseInterface:: |
|
CDNBase:: |
public | function |
Return all available file(s). Overrides CDNBaseInterface:: |
1 |
CDNBase:: |
public | function |
Get library information. Overrides CDNBaseInterface:: |
1 |
CDNBase:: |
public | function |
Get latest version available of a library. Overrides CDNBaseInterface:: |
|
CDNBase:: |
public | function |
Get the library in use. Overrides CDNBaseInterface:: |
|
CDNBase:: |
public | function |
Copy a library from the CDN to the local filesystem. Overrides CDNBaseInterface:: |
|
CDNBase:: |
public | function |
Get the local directory name of a library. Overrides CDNBaseInterface:: |
|
CDNBase:: |
public | function |
Get the local file name of a library file. Overrides CDNBaseInterface:: |
|
CDNBase:: |
public | function |
Get the default scheme. Overrides CDNBaseInterface:: |
|
CDNBase:: |
public | function |
Get a particular URL. Overrides CDNBaseInterface:: |
|
CDNBase:: |
public | function |
Get URLs. Overrides CDNBaseInterface:: |
|
CDNBase:: |
public | function |
Return all available version(s). Overrides CDNBaseInterface:: |
2 |
CDNBase:: |
public | function |
Check if library is available. Overrides CDNBaseInterface:: |
1 |
CDNBase:: |
public | function |
Check if a file is available locally. Overrides CDNBaseInterface:: |
|
CDNBase:: |
public | function |
Request wrapper for querying a CDN. Overrides CDNBaseInterface:: |
|
CDNBase:: |
public | function |
Make an HTTP Request. Overrides CDNBaseInterface:: |
|
CDNBase:: |
public | function |
Perform a search for a library. Overrides CDNBaseInterface:: |
1 |
CDNBase:: |
public | function |
Set the configuration of the object. Overrides CDNBaseInterface:: |
|
CDNBase:: |
public | function |
Set the library to work with. Overrides CDNBaseInterface:: |
|
CDNBase:: |
public | function |
Set default scheme for an url. Overrides CDNBaseInterface:: |
|
CDNBase:: |
public | function |
Set a particular URL. Overrides CDNBaseInterface:: |
|
CDNBase:: |
public | function |
Set URLs. Overrides CDNBaseInterface:: |
|
JSDelivr:: |
public | function |
Return the data to use in each method. Overrides CDNBase:: |
|
JSDelivr:: |
public | function |
Overrides CDNBase:: |