You are here

class CdnJs in Libraries CDN API 8

Same name and namespace in other branches
  1. 7 src/Plugin/LibrariesCDN/CDNJS.php \Drupal\libraries_cdn\Plugin\LibrariesCDN\CDNJS

Class CdnJs.

Plugin annotation


@LibrariesCdn(
 id = "cdnjs",
 description = "CDNJS Integration"
)

Hierarchy

Expanded class hierarchy of CdnJs

File

src/Plugin/LibrariesCdn/CdnJs.php, line 21
Plugin: CDNJS.

Namespace

Drupal\libraries_cdn\Plugin\LibrariesCdn
View source
class CdnJs 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.cdnjs.com/libraries?search=%s',
      'getInformation' => 'http://api.cdnjs.com/libraries/%s',
      'getVersions' => 'http://api.cdnjs.com/libraries/%s',
      'getFiles' => 'http://api.cdnjs.com/libraries/%s',
      'search' => 'http://api.cdnjs.com/libraries?search=%s',
      'convertFiles' => '//cdnjs.cloudflare.com/ajax/libs/%s/%s/',
    );
    parent::__construct($configuration, $plugin_id, $plugin_definition);
  }

  /**
   * {@inheritdoc}
   */
  public function formatData($function, array $data = array()) {
    switch ($function) {
      case 'search':
      case 'isAvailable':
        return isset($data['results']) ? (array) $data['results'] : $data;
      case 'getVersions':
      case 'getFiles':
        return isset($data['assets']) ? (array) $data['assets'] : $data;
      case 'getLatestVersion':
        return isset($data['version']) ? $data['version'] : NULL;
      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
CdnJs::formatData public function Return the data to use in each method. Overrides CdnBase::formatData
CdnJs::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides CdnBase::__construct
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
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.