/** * Creates the discovery object. * * @param string|bool $subdir * The plugin's subdirectory, for example Plugin/views/filter. * @param \Traversable $namespaces * An object that implements \Traversable which contains the root paths * keyed by the corresponding namespace to look for plugin implementations. * @param string|null $plugin_interface * (optional) The interface each plugin should implement. * @param string $plugin_definition_annotation_name * (optional) The name of the annotation that contains the plugin definition. * Defaults to 'Drupal\Component\Annotation\Plugin'. */ public function __construct($subdir, \Traversable $namespaces, $plugin_interface = NULL, $plugin_definition_annotation_name = 'Drupal\\Component\\Annotation\\Plugin') { $this->subdir = $subdir; $this->namespaces = $namespaces; $this->pluginDefinitionAnnotationName = $plugin_definition_annotation_name; $this->pluginInterface = $plugin_interface; // Add the file cache prefix. $configuration['default'] = ['class' => '\\Drupal\\Component\\FileCache\\FileCache', 'cache_backend_class' => NULL, 'cache_backend_configuration' => []]; // @todo Use extension_loaded('apcu') for non-testbot // https://www.drupal.org/node/2447753. if (function_exists('apc_fetch')) { $configuration['default']['cache_backend_class'] = '\\Drupal\\Component\\FileCache\\ApcuFileCacheBackend'; } FileCacheFactory::setConfiguration($configuration); $identifier = 'file_cache'; FileCacheFactory::setPrefix('drupal.' . $identifier . '.' . hash_hmac('sha256', $identifier, drupal_get_hash_salt())); }
/** * Set a secure componentId based on the options values and the drupal private key. */ protected function setComponentID() { $base64 = implode('@', $this->getOptions()); $base64 = base64_encode($base64); $this->_componentID = $this->pluginType['name'] . md5($base64 . drupal_get_private_key() . drupal_get_hash_salt()); }