SitemapConfigReader.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sitemap\Model;
  7. use Magento\Framework\App\Config\ScopeConfigInterface;
  8. use Magento\Store\Model\ScopeInterface;
  9. class SitemapConfigReader implements SitemapConfigReaderInterface
  10. {
  11. /**
  12. * Config path to sitemap valid paths
  13. */
  14. const XML_PATH_SITEMAP_VALID_PATHS = 'sitemap/file/valid_paths';
  15. /**
  16. * Config path to valid file paths
  17. */
  18. const XML_PATH_PUBLIC_FILES_VALID_PATHS = 'general/file/public_files_valid_paths';
  19. /**#@+
  20. * Limits xpath config settings
  21. */
  22. const XML_PATH_MAX_LINES = 'sitemap/limit/max_lines';
  23. const XML_PATH_MAX_FILE_SIZE = 'sitemap/limit/max_file_size';
  24. /**#@-*/
  25. /**
  26. * Search Engine Submission Settings
  27. */
  28. const XML_PATH_SUBMISSION_ROBOTS = 'sitemap/search_engines/submission_robots';
  29. /**
  30. * Include product image setting
  31. */
  32. const XML_PATH_PRODUCT_IMAGES_INCLUDE = 'sitemap/product/image_include';
  33. /**
  34. * Scope config
  35. *
  36. * @var ScopeConfigInterface
  37. */
  38. private $scopeConfig;
  39. /**
  40. * Sitemap Config Reader constructor.
  41. *
  42. * @param ScopeConfigInterface $scopeConfig
  43. */
  44. public function __construct(ScopeConfigInterface $scopeConfig)
  45. {
  46. $this->scopeConfig = $scopeConfig;
  47. }
  48. /**
  49. * {@inheritdoc}
  50. */
  51. public function getEnableSubmissionRobots($storeId)
  52. {
  53. return $this->scopeConfig->getValue(
  54. self::XML_PATH_SUBMISSION_ROBOTS,
  55. ScopeInterface::SCOPE_STORE,
  56. $storeId
  57. );
  58. }
  59. /**
  60. * {@inheritdoc}
  61. */
  62. public function getMaximumFileSize($storeId)
  63. {
  64. return $this->scopeConfig->getValue(
  65. self::XML_PATH_MAX_FILE_SIZE,
  66. ScopeInterface::SCOPE_STORE,
  67. $storeId
  68. );
  69. }
  70. /**
  71. * {@inheritdoc}
  72. */
  73. public function getMaximumLinesNumber($storeId)
  74. {
  75. return $this->scopeConfig->getValue(
  76. self::XML_PATH_MAX_LINES,
  77. ScopeInterface::SCOPE_STORE,
  78. $storeId
  79. );
  80. }
  81. /**
  82. * {@inheritdoc}
  83. */
  84. public function getProductImageIncludePolicy($storeId)
  85. {
  86. return (string)$this->scopeConfig->getValue(
  87. self::XML_PATH_PRODUCT_IMAGES_INCLUDE,
  88. ScopeInterface::SCOPE_STORE,
  89. $storeId
  90. );
  91. }
  92. /**
  93. * {@inheritdoc}
  94. */
  95. public function getValidPaths()
  96. {
  97. return array_merge(
  98. $this->scopeConfig->getValue(self::XML_PATH_SITEMAP_VALID_PATHS, ScopeInterface::SCOPE_STORE),
  99. $this->scopeConfig->getValue(self::XML_PATH_PUBLIC_FILES_VALID_PATHS, ScopeInterface::SCOPE_STORE)
  100. );
  101. }
  102. }