Robots.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sitemap\Model\Config\Backend;
  7. use Magento\Framework\App\Cache\TypeListInterface;
  8. use Magento\Framework\App\Config\ScopeConfigInterface;
  9. use Magento\Framework\App\Config\Value;
  10. use Magento\Framework\Data\Collection\AbstractDb;
  11. use Magento\Framework\DataObject\IdentityInterface;
  12. use Magento\Framework\Model\Context;
  13. use Magento\Framework\Model\ResourceModel\AbstractResource;
  14. use Magento\Framework\Registry;
  15. use Magento\Robots\Model\Config\Value as RobotsValue;
  16. use Magento\Store\Model\StoreResolver;
  17. use Magento\Store\Model\StoreManagerInterface;
  18. /**
  19. * Backend model for sitemap/search_engines/submission_robots configuration value.
  20. *
  21. * Required to implement Page Cache functionality.
  22. */
  23. class Robots extends Value implements IdentityInterface
  24. {
  25. /**
  26. * Model cache tag for clear cache in after save and after delete
  27. *
  28. * @var string
  29. */
  30. protected $_cacheTag = true;
  31. /**
  32. * @var StoreManagerInterface
  33. */
  34. private $storeManager;
  35. /**
  36. * @param Context $context
  37. * @param Registry $registry
  38. * @param ScopeConfigInterface $config
  39. * @param TypeListInterface $cacheTypeList
  40. * @param StoreResolver $storeResolver
  41. * @param StoreManagerInterface|null $storeManager
  42. * @param AbstractResource|null $resource
  43. * @param AbstractDb|null $resourceCollection
  44. * @param array $data
  45. *
  46. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  47. */
  48. public function __construct(
  49. Context $context,
  50. Registry $registry,
  51. ScopeConfigInterface $config,
  52. TypeListInterface $cacheTypeList,
  53. StoreResolver $storeResolver,
  54. StoreManagerInterface $storeManager = null,
  55. AbstractResource $resource = null,
  56. AbstractDb $resourceCollection = null,
  57. array $data = []
  58. ) {
  59. $this->storeManager = $storeManager ?: \Magento\Framework\App\ObjectManager::getInstance()
  60. ->get(StoreManagerInterface::class);
  61. parent::__construct(
  62. $context,
  63. $registry,
  64. $config,
  65. $cacheTypeList,
  66. $resource,
  67. $resourceCollection,
  68. $data
  69. );
  70. }
  71. /**
  72. * Get unique page cache identities
  73. *
  74. * @return array
  75. */
  76. public function getIdentities()
  77. {
  78. return [
  79. RobotsValue::CACHE_TAG . '_' . $this->storeManager->getStore()->getId(),
  80. ];
  81. }
  82. }