InvalidateCache.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\PageCache\Observer;
  8. use Magento\Framework\Event\ObserverInterface;
  9. class InvalidateCache implements ObserverInterface
  10. {
  11. /**
  12. * @var \Magento\Framework\App\Cache\TypeListInterface
  13. */
  14. protected $_typeList;
  15. /**
  16. * Application config object
  17. *
  18. * @var \Magento\PageCache\Model\Config
  19. */
  20. protected $_config;
  21. /**
  22. * @param \Magento\PageCache\Model\Config $config
  23. * @param \Magento\Framework\App\Cache\TypeListInterface $typeList
  24. */
  25. public function __construct(
  26. \Magento\PageCache\Model\Config $config,
  27. \Magento\Framework\App\Cache\TypeListInterface $typeList
  28. ) {
  29. $this->_config = $config;
  30. $this->_typeList = $typeList;
  31. }
  32. /**
  33. * Invalidate full page cache
  34. *
  35. * @param \Magento\Framework\Event\Observer $observer
  36. * @return void
  37. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  38. */
  39. public function execute(\Magento\Framework\Event\Observer $observer)
  40. {
  41. if ($this->_config->isEnabled()) {
  42. $this->_typeList->invalidate('full_page');
  43. }
  44. }
  45. }