class JSDelivr in Libraries CDN API 8
Same name and namespace in other branches
- 7 src/Plugin/LibrariesCDN/JSDelivr.php \Drupal\libraries_cdn\Plugin\LibrariesCDN\JSDelivr
Class JsDelivr.
Plugin annotation
@LibrariesCdn(
id = "jsdelivr",
description = "jsDelivr Integration"
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\libraries_cdn\CdnBase implements CdnBaseInterface
- class \Drupal\libraries_cdn\Plugin\LibrariesCdn\JSDelivr implements CdnBaseInterface
- class \Drupal\libraries_cdn\CdnBase implements CdnBaseInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of JSDelivr
File
- src/
Plugin/ LibrariesCdn/ JsDelivr.php, line 21 - Plugin: jsDelivr.
Namespace
Drupal\libraries_cdn\Plugin\LibrariesCdnView source
class JSDelivr extends CdnBase implements CdnBaseInterface {
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition) {
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);
}
/**
* {@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:: |
|
CdnBase:: |
public | function |
Get library information. Overrides CdnBaseInterface:: |
|
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:: |
|
CdnBase:: |
public | function |
Check if library is available. Overrides CdnBaseInterface:: |
|
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:: |
|
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:: |
|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
JSDelivr:: |
public | function |
Return the data to use in each method. Overrides CdnBase:: |
|
JSDelivr:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides CdnBase:: |
|
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |