Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Baseurl.php
Go to the documentation of this file.
1 <?php
8 
10 
15 {
19  protected $_urlBuilder;
20 
24  protected $_config;
25 
29  protected $_storeManager;
30 
35 
42  public function __construct(
43  \Magento\Framework\App\Config\ScopeConfigInterface $config,
44  \Magento\Store\Model\StoreManagerInterface $storeManager,
45  \Magento\Framework\UrlInterface $urlBuilder,
46  \Magento\Framework\App\Config\ValueFactory $configValueFactory
47  ) {
48  $this->_urlBuilder = $urlBuilder;
49  $this->_config = $config;
50  $this->_storeManager = $storeManager;
51  $this->_configValueFactory = $configValueFactory;
52  }
53 
59  protected function _getConfigUrl()
60  {
61  $output = '';
62  $defaultUnsecure = $this->_config->getValue(Store::XML_PATH_UNSECURE_BASE_URL, 'default');
63 
64  $defaultSecure = $this->_config->getValue(Store::XML_PATH_SECURE_BASE_URL, 'default');
65 
66  if ($defaultSecure == \Magento\Store\Model\Store::BASE_URL_PLACEHOLDER ||
67  $defaultUnsecure == \Magento\Store\Model\Store::BASE_URL_PLACEHOLDER
68  ) {
69  $output = $this->_urlBuilder->getUrl('adminhtml/system_config/edit', ['section' => 'web']);
70  } else {
72  $dataCollection = $this->_configValueFactory->create()->getCollection();
73  $dataCollection->addValueFilter(\Magento\Store\Model\Store::BASE_URL_PLACEHOLDER);
74 
76  foreach ($dataCollection as $data) {
77  if ($data->getScope() == 'stores') {
78  $code = $this->_storeManager->getStore($data->getScopeId())->getCode();
79  $output = $this->_urlBuilder->getUrl(
80  'adminhtml/system_config/edit',
81  ['section' => 'web', 'store' => $code]
82  );
83  break;
84  } elseif ($data->getScope() == 'websites') {
85  $code = $this->_storeManager->getWebsite($data->getScopeId())->getCode();
86  $output = $this->_urlBuilder->getUrl(
87  'adminhtml/system_config/edit',
88  ['section' => 'web', 'website' => $code]
89  );
90  break;
91  }
92  }
93  }
94  return $output;
95  }
96 
102  public function getIdentity()
103  {
104  return md5('BASE_URL' . $this->_getConfigUrl());
105  }
106 
112  public function isDisplayed()
113  {
114  return (bool)$this->_getConfigUrl();
115  }
116 
122  public function getText()
123  {
124  return __(
125  '{{base_url}} is not recommended to use in a production environment to declare the Base Unsecure '
126  . 'URL / Base Secure URL. We highly recommend changing this value in your Magento '
127  . '<a href="%1">configuration</a>.',
128  $this->_getConfigUrl()
129  );
130  }
131 
137  public function getSeverity()
138  {
140  }
141 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$config
Definition: fraud_order.php:17
$storeManager
__()
Definition: __.php:13
__construct(\Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\App\Config\ValueFactory $configValueFactory)
Definition: Baseurl.php:42
$code
Definition: info.phtml:12