Config.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\View\Asset;
  7. use Magento\Store\Model\ScopeInterface;
  8. use Magento\Framework\App\Config\ScopeConfigInterface;
  9. /**
  10. * View asset configuration interface
  11. */
  12. class Config implements \Magento\Framework\View\Asset\ConfigInterface
  13. {
  14. /**
  15. * XML path for CSS files merge configuration
  16. */
  17. const XML_PATH_MERGE_CSS_FILES = 'dev/css/merge_css_files';
  18. /**
  19. * XML path for JavaScript files merge configuration
  20. */
  21. const XML_PATH_MERGE_JS_FILES = 'dev/js/merge_files';
  22. /**
  23. * XML path for asset minification adapter configuration
  24. */
  25. const XML_PATH_JS_BUNDLING = 'dev/js/enable_js_bundling';
  26. /**
  27. * XML path for HTML minification configuration
  28. */
  29. const XML_PATH_MINIFICATION_HTML = 'dev/template/minify_html';
  30. /**
  31. * @var ScopeConfigInterface
  32. */
  33. protected $scopeConfig;
  34. /**
  35. * @param ScopeConfigInterface $scopeConfig
  36. */
  37. public function __construct(ScopeConfigInterface $scopeConfig)
  38. {
  39. $this->scopeConfig = $scopeConfig;
  40. }
  41. /**
  42. * Check whether merging of CSS files is on
  43. *
  44. * @return bool
  45. */
  46. public function isMergeCssFiles()
  47. {
  48. return $this->scopeConfig->isSetFlag(
  49. self::XML_PATH_MERGE_CSS_FILES,
  50. ScopeInterface::SCOPE_STORE
  51. );
  52. }
  53. /**
  54. * Check whether bundling of JavScript files is on
  55. *
  56. * @return bool
  57. */
  58. public function isBundlingJsFiles()
  59. {
  60. return $this->scopeConfig->isSetFlag(
  61. self::XML_PATH_JS_BUNDLING,
  62. ScopeInterface::SCOPE_STORE
  63. );
  64. }
  65. /**
  66. * Check whether merging of JavScript files is on
  67. *
  68. * @return bool
  69. */
  70. public function isMergeJsFiles()
  71. {
  72. return $this->scopeConfig->isSetFlag(
  73. self::XML_PATH_MERGE_JS_FILES,
  74. ScopeInterface::SCOPE_STORE
  75. );
  76. }
  77. /**
  78. * Check whether minify of HTML is on
  79. *
  80. * @return bool
  81. */
  82. public function isMinifyHtml()
  83. {
  84. return $this->scopeConfig->isSetFlag(
  85. self::XML_PATH_MINIFICATION_HTML,
  86. ScopeInterface::SCOPE_STORE
  87. );
  88. }
  89. }