class TagsHeadersService in Purge 8.3
Provides a service that provides access to available tags headers.
Hierarchy
- class \Drupal\Core\DependencyInjection\ServiceProviderBase implements ServiceModifierInterface, ServiceProviderInterface
- class \Drupal\purge\ServiceBase implements ServiceInterface
- class \Drupal\purge\Plugin\Purge\TagsHeader\TagsHeadersService implements TagsHeadersServiceInterface uses \Symfony\Component\DependencyInjection\ContainerAwareTrait, IteratingServiceBaseTrait
- class \Drupal\purge\ServiceBase implements ServiceInterface
Expanded class hierarchy of TagsHeadersService
1 string reference to 'TagsHeadersService'
1 service uses TagsHeadersService
File
- src/
Plugin/ Purge/ TagsHeader/ TagsHeadersService.php, line 13
Namespace
Drupal\purge\Plugin\Purge\TagsHeaderView source
class TagsHeadersService extends ServiceBase implements TagsHeadersServiceInterface {
use ContainerAwareTrait;
use IteratingServiceBaseTrait;
/**
* The purge executive service, which wipes content from external caches.
*
* Do not access this property directly, use ::getPurgers.
*
* @var \Drupal\purge\Plugin\Purge\Purger\PurgersServiceInterface
*/
private $purgePurgers;
/**
* Construct the tags headers service.
*
* @param \Drupal\Component\Plugin\PluginManagerInterface $pluginManager
* The plugin manager for this service.
*/
public function __construct(PluginManagerInterface $pluginManager) {
$this->pluginManager = $pluginManager;
}
/**
* {@inheritdoc}
*/
public function getPluginsEnabled() {
if (!is_null($this->pluginsEnabled)) {
return $this->pluginsEnabled;
}
// We blindly load all tag header plugins that we discovered, but not
// when plugins put dependencies on purger plugins. When plugins do depend,
// we load 'purge.purgers' and verify if we should load them or not.
$load = function ($needles, $haystack) {
if (empty($needles)) {
return TRUE;
}
foreach ($needles as $needle) {
if (in_array($needle, $haystack)) {
return TRUE;
}
}
return FALSE;
};
$this->pluginsEnabled = [];
foreach ($this
->getPlugins() as $plugin) {
if (!empty($plugin['dependent_purger_plugins'])) {
if (!$load($plugin['dependent_purger_plugins'], $this
->getPurgers()
->getPluginsEnabled())) {
continue;
}
}
$this->pluginsEnabled[] = $plugin['id'];
}
return $this->pluginsEnabled;
}
/**
* Retrieve the 'purge.purgers' service - lazy loaded.
*
* @return \Drupal\purge\Plugin\Purge\Purger\PurgersServiceInterface
* The 'purge.purgers' service.
*/
protected function getPurgers() {
if (is_null($this->purgePurgers)) {
$this->purgePurgers = $this->container
->get('purge.purgers');
}
return $this->purgePurgers;
}
/**
* {@inheritdoc}
*
* @ingroup countable
*/
public function count() {
$this
->initializePluginInstances();
return count($this->instances);
}
/**
* {@inheritdoc}
*/
public function reload() {
parent::reload();
$this
->reloadIterator();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
IteratingServiceBaseTrait:: |
protected | property | Holds all instantiated plugins. | |
IteratingServiceBaseTrait:: |
protected | property | Current iterator position. | |
IteratingServiceBaseTrait:: |
public | function | Return the current element. | |
IteratingServiceBaseTrait:: |
protected | function | Instantiate all enabled plugins or check that they are present. | |
IteratingServiceBaseTrait:: |
public | function | Return the key of the current element. | |
IteratingServiceBaseTrait:: |
public | function | Move forward to next element. | 1 |
IteratingServiceBaseTrait:: |
protected | function | Rewind the iterator and destruct loaded plugin instances. | |
IteratingServiceBaseTrait:: |
public | function | Rewind the Iterator to the first element. | |
IteratingServiceBaseTrait:: |
public | function | Checks if current position is valid. | |
ServiceBase:: |
protected | property | The plugin manager for the given service. | |
ServiceBase:: |
protected | property | The list of all available plugins and their definitions. | |
ServiceBase:: |
protected | property | The list of all enabled plugins and their definitions. | |
ServiceBase:: |
public | function |
Retrieve a list of all available plugins providing the service. Overrides ServiceInterface:: |
1 |
ServiceBase:: |
public | function |
Find out whether the given plugin_id is enabled. Overrides ServiceInterface:: |
|
ServiceProviderBase:: |
public | function |
Modifies existing service definitions. Overrides ServiceModifierInterface:: |
5 |
ServiceProviderBase:: |
public | function |
Registers services to the container. Overrides ServiceProviderInterface:: |
1 |
TagsHeadersService:: |
private | property | The purge executive service, which wipes content from external caches. | |
TagsHeadersService:: |
public | function | ||
TagsHeadersService:: |
public | function |
Retrieve the configured plugin_ids that the service will use. Overrides ServiceBase:: |
|
TagsHeadersService:: |
protected | function | Retrieve the 'purge.purgers' service - lazy loaded. | |
TagsHeadersService:: |
public | function |
Reload the service and reinstantiate all enabled plugins. Overrides ServiceBase:: |
|
TagsHeadersService:: |
public | function | Construct the tags headers service. |