class PluginManagerCacheClearer

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/modules/module_test/src/PluginManagerCacheClearer.php \Drupal\module_test\PluginManagerCacheClearer

Helps test module uninstall.

Hierarchy

Expanded class hierarchy of PluginManagerCacheClearer

1 file declares its use of PluginManagerCacheClearer
UninstallKernelTest.php in core/modules/system/tests/src/Kernel/Installer/UninstallKernelTest.php
1 string reference to 'PluginManagerCacheClearer'
module_test.services.yml in core/modules/system/tests/modules/module_test/module_test.services.yml
core/modules/system/tests/modules/module_test/module_test.services.yml
1 service uses PluginManagerCacheClearer
plugin.manager.module_test.cache_clear_test in core/modules/system/tests/modules/module_test/module_test.services.yml
Drupal\module_test\PluginManagerCacheClearer

File

core/modules/system/tests/modules/module_test/src/PluginManagerCacheClearer.php, line 11

Namespace

Drupal\module_test
View source
class PluginManagerCacheClearer extends DefaultPluginManager {
  
  /**
   * @var \Drupal\Core\State\StateInterface
   */
  protected $state;
  
  /**
   * An optional service dependency.
   *
   * @var object|null
   */
  protected $optionalService;
  
  /**
   * PluginManagerCacheClearer constructor.
   *
   * @param \Drupal\Core\State\StateInterface $state
   *   The state service for recording what happens.
   * @param null $optional_service
   *   An optional service for testing.
   */
  public function __construct(StateInterface $state, $optional_service = NULL) {
    $this->state = $state;
    $this->optionalService = $optional_service;
  }
  
  /**
   * Tests call to CachedDiscoveryInterface::clearCachedDefinitions().
   *
   * @see \Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface::clearCachedDefinitions()
   */
  public function clearCachedDefinitions() {
    $this->state
      ->set(self::class, isset($this->optionalService));
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.