You are here

class JSDelivr 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

Class JsDelivr.

Plugin annotation


@LibrariesCdn(
 id = "jsdelivr",
 description = "jsDelivr Integration"
)

Hierarchy

Expanded class hierarchy of JSDelivr

File

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

Namespace

Drupal\libraries_cdn\Plugin\LibrariesCdn
View 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

Namesort descending Modifiers Type Description Overrides
CdnBase::convertFiles public function
CdnBase::getConfiguration public function Return the configuration of the object. Overrides CdnBaseInterface::getConfiguration
CdnBase::getFiles public function Return all available file(s). Overrides CdnBaseInterface::getFiles
CdnBase::getInformation public function Get library information. Overrides CdnBaseInterface::getInformation
CdnBase::getLatestVersion public function Get latest version available of a library. Overrides CdnBaseInterface::getLatestVersion
CdnBase::getLibrary public function Get the library in use. Overrides CdnBaseInterface::getLibrary
CdnBase::getLocalCopy public function Copy a library from the CDN to the local filesystem. Overrides CdnBaseInterface::getLocalCopy
CdnBase::getLocalDirectoryName public function Get the local directory name of a library. Overrides CdnBaseInterface::getLocalDirectoryName
CdnBase::getLocalFileName public function Get the local file name of a library file. Overrides CdnBaseInterface::getLocalFileName
CdnBase::getScheme public function Get the default scheme. Overrides CdnBaseInterface::getScheme
CdnBase::getURL public function Get a particular URL. Overrides CdnBaseInterface::getURL
CdnBase::getURLs public function Get URLs. Overrides CdnBaseInterface::getURLs
CdnBase::getVersions public function Return all available version(s). Overrides CdnBaseInterface::getVersions
CdnBase::isAvailable public function Check if library is available. Overrides CdnBaseInterface::isAvailable
CdnBase::isLocalAvailable public function Check if a file is available locally. Overrides CdnBaseInterface::isLocalAvailable
CdnBase::query public function Request wrapper for querying a CDN. Overrides CdnBaseInterface::query
CdnBase::request public function Make an HTTP Request. Overrides CdnBaseInterface::request
CdnBase::search public function Perform a search for a library. Overrides CdnBaseInterface::search
CdnBase::setConfiguration public function Set the configuration of the object. Overrides CdnBaseInterface::setConfiguration
CdnBase::setLibrary public function Set the library to work with. Overrides CdnBaseInterface::setLibrary
CdnBase::setScheme public function Set default scheme for an url. Overrides CdnBaseInterface::setScheme
CdnBase::setURL public function Set a particular URL. Overrides CdnBaseInterface::setURL
CdnBase::setURLs public function Set URLs. Overrides CdnBaseInterface::setURLs
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
JSDelivr::formatData public function Return the data to use in each method. Overrides CdnBase::formatData
JSDelivr::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides CdnBase::__construct
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.