You are here

abstract class ServiceBase in Purge 8.3

Provides a generic service for all DIC-registered service classes by Purge.

Hierarchy

Expanded class hierarchy of ServiceBase

8 files declare their use of ServiceBase
DiagnosticsService.php in src/Plugin/Purge/DiagnosticCheck/DiagnosticsService.php
InvalidationsService.php in src/Plugin/Purge/Invalidation/InvalidationsService.php
ProcessorsService.php in src/Plugin/Purge/Processor/ProcessorsService.php
PurgersService.php in src/Plugin/Purge/Purger/PurgersService.php
QueuersService.php in src/Plugin/Purge/Queuer/QueuersService.php

... See full list

File

src/ServiceBase.php, line 10

Namespace

Drupal\purge
View source
abstract class ServiceBase extends ServiceProviderBase implements ServiceInterface {

  /**
   * The plugin manager for the given service.
   *
   * @var \Drupal\Component\Plugin\PluginManagerInterface
   */
  protected $pluginManager;

  /**
   * The list of all available plugins and their definitions.
   *
   * @var null|array
   */
  protected $plugins = NULL;

  /**
   * The list of all enabled plugins and their definitions.
   *
   * @var null|array
   */
  protected $pluginsEnabled = NULL;

  /**
   * {@inheritdoc}
   */
  public function getPlugins() {
    if (is_null($this->plugins)) {
      $this->plugins = $this->pluginManager
        ->getDefinitions();
    }
    return $this->plugins;
  }

  /**
   * {@inheritdoc}
   */
  public function getPluginsEnabled() {
    if (is_null($this->pluginsEnabled)) {
      $this->pluginsEnabled = array_keys($this
        ->getPlugins());
    }
    return $this->pluginsEnabled;
  }

  /**
   * {@inheritdoc}
   */
  public function isPluginEnabled($plugin_id) {
    return in_array($plugin_id, $this
      ->getPluginsEnabled());
  }

  /**
   * {@inheritdoc}
   */
  public function reload() {
    $this->plugins = NULL;
    $this->pluginsEnabled = NULL;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ServiceBase::$pluginManager protected property The plugin manager for the given service.
ServiceBase::$plugins protected property The list of all available plugins and their definitions.
ServiceBase::$pluginsEnabled protected property The list of all enabled plugins and their definitions.
ServiceBase::getPlugins public function Retrieve a list of all available plugins providing the service. Overrides ServiceInterface::getPlugins 1
ServiceBase::getPluginsEnabled public function Retrieve the configured plugin_ids that the service will use. Overrides ServiceInterface::getPluginsEnabled 6
ServiceBase::isPluginEnabled public function Find out whether the given plugin_id is enabled. Overrides ServiceInterface::isPluginEnabled
ServiceBase::reload public function Reload the service and reinstantiate all enabled plugins. Overrides ServiceInterface::reload 6
ServiceProviderBase::alter public function Modifies existing service definitions. Overrides ServiceModifierInterface::alter 5
ServiceProviderBase::register public function Registers services to the container. Overrides ServiceProviderInterface::register 1