CachedDiscoveryClearer.php 793 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace Drupal\Core\Plugin;
  3. use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface;
  4. /**
  5. * Defines a class which is capable of clearing the cache on plugin managers.
  6. */
  7. class CachedDiscoveryClearer implements CachedDiscoveryClearerInterface {
  8. /**
  9. * The stored discoveries.
  10. *
  11. * @var \Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface[]
  12. */
  13. protected $cachedDiscoveries = [];
  14. /**
  15. * {@inheritdoc}
  16. */
  17. public function addCachedDiscovery(CachedDiscoveryInterface $cached_discovery) {
  18. $this->cachedDiscoveries[] = $cached_discovery;
  19. }
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function clearCachedDefinitions() {
  24. foreach ($this->cachedDiscoveries as $cached_discovery) {
  25. $cached_discovery->clearCachedDefinitions();
  26. }
  27. }
  28. }