TagsHeadersService.php in Purge 8.3
File
src/Plugin/Purge/TagsHeader/TagsHeadersService.php
View source
<?php
namespace Drupal\purge\Plugin\Purge\TagsHeader;
use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\purge\IteratingServiceBaseTrait;
use Drupal\purge\ServiceBase;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
class TagsHeadersService extends ServiceBase implements TagsHeadersServiceInterface {
use ContainerAwareTrait;
use IteratingServiceBaseTrait;
private $purgePurgers;
public function __construct(PluginManagerInterface $pluginManager) {
$this->pluginManager = $pluginManager;
}
public function getPluginsEnabled() {
if (!is_null($this->pluginsEnabled)) {
return $this->pluginsEnabled;
}
$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;
}
protected function getPurgers() {
if (is_null($this->purgePurgers)) {
$this->purgePurgers = $this->container
->get('purge.purgers');
}
return $this->purgePurgers;
}
public function count() {
$this
->initializePluginInstances();
return count($this->instances);
}
public function reload() {
parent::reload();
$this
->reloadIterator();
}
}