SecurityInfo.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Store\Url\Plugin;
  7. use \Magento\Store\Model\Store;
  8. use \Magento\Store\Model\ScopeInterface as StoreScopeInterface;
  9. /**
  10. * Plugin for \Magento\Framework\Url\SecurityInfo
  11. */
  12. class SecurityInfo
  13. {
  14. /**
  15. * @var \Magento\Framework\App\Config\ScopeConfigInterface
  16. */
  17. protected $scopeConfig;
  18. /**
  19. * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  20. */
  21. public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig)
  22. {
  23. $this->scopeConfig = $scopeConfig;
  24. }
  25. /**
  26. * Check if secure URLs are enabled.
  27. *
  28. * @param \Magento\Framework\Url\SecurityInfo $subject
  29. * @param callable $proceed
  30. * @param string $url
  31. * @return bool
  32. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  33. */
  34. public function aroundIsSecure(\Magento\Framework\Url\SecurityInfo $subject, \Closure $proceed, $url)
  35. {
  36. if ($this->scopeConfig->getValue(Store::XML_PATH_SECURE_IN_FRONTEND, StoreScopeInterface::SCOPE_STORE)) {
  37. return $proceed($url);
  38. } else {
  39. return false;
  40. }
  41. }
  42. }