Value.php 2.6 KB

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