UpdateBackend.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Drupal\Core\Update;
  3. use Drupal\Core\Cache\CacheBackendInterface;
  4. use Drupal\Core\Cache\NullBackend;
  5. /**
  6. * Defines a cache backend for use during Drupal database updates.
  7. *
  8. * Passes on deletes to another backend while extending the NullBackend to avoid
  9. * using anything cached prior to running updates.
  10. */
  11. class UpdateBackend extends NullBackend {
  12. /**
  13. * The regular runtime cache backend.
  14. *
  15. * @var \Drupal\Core\Cache\CacheBackendInterface
  16. */
  17. protected $backend;
  18. /**
  19. * UpdateBackend constructor.
  20. *
  21. * @param \Drupal\Core\Cache\CacheBackendInterface $backend
  22. * The regular runtime cache backend.
  23. */
  24. public function __construct(CacheBackendInterface $backend) {
  25. $this->backend = $backend;
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function delete($cid) {
  31. $this->backend->delete($cid);
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function deleteMultiple(array $cids) {
  37. $this->backend->deleteMultiple($cids);
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function deleteAll() {
  43. $this->backend->deleteAll();
  44. }
  45. }