Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PathConfig.php
Go to the documentation of this file.
1 <?php
2 /***
3  * Copyright © Magento, Inc. All rights reserved.
4  * See COPYING.txt for license details.
5  */
6 namespace Magento\Store\Model;
7 
9 {
13  private $scopeConfig;
14 
18  private $urlSecurityInfo;
19 
23  private $storeManager;
24 
30  public function __construct(
31  \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
32  \Magento\Framework\Url\SecurityInfoInterface $urlSecurityInfo,
33  StoreManagerInterface $storeManager
34  ) {
35  $this->scopeConfig = $scopeConfig;
36  $this->urlSecurityInfo = $urlSecurityInfo;
37  $this->storeManager = $storeManager;
38  }
39 
46  public function getCurrentSecureUrl(\Magento\Framework\App\RequestInterface $request)
47  {
48  $alias = $request->getAlias(\Magento\Framework\Url::REWRITE_REQUEST_PATH_ALIAS) ?: $request->getPathInfo();
49  return $this->storeManager->getStore()->getBaseUrl('link', true) . ltrim($alias, '/');
50  }
51 
58  public function shouldBeSecure($path)
59  {
60  return parse_url(
61  $this->scopeConfig->getValue(
64  ),
65  PHP_URL_SCHEME
66  ) === 'https'
67  || $this->scopeConfig->isSetFlag(
70  ) && parse_url(
71  $this->scopeConfig->getValue(
74  ),
75  PHP_URL_SCHEME
76  ) == 'https' && $this->urlSecurityInfo->isSecure($path);
77  }
78 
84  public function getDefaultPath()
85  {
86  $store = $this->storeManager->getStore();
87  $value = $this->scopeConfig->getValue('web/default/front', ScopeInterface::SCOPE_STORE, $store);
88  return $value;
89  }
90 }
const XML_PATH_UNSECURE_BASE_URL
Definition: Store.php:66
$storeManager
getCurrentSecureUrl(\Magento\Framework\App\RequestInterface $request)
Definition: PathConfig.php:46
$value
Definition: gender.phtml:16
const XML_PATH_SECURE_IN_FRONTEND
Definition: Store.php:70
const XML_PATH_SECURE_BASE_URL
Definition: Store.php:68
if(!trim($html)) $alias
Definition: details.phtml:20
__construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Url\SecurityInfoInterface $urlSecurityInfo, StoreManagerInterface $storeManager)
Definition: PathConfig.php:30