Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigProvider.php
Go to the documentation of this file.
1 <?php
7 
16 
18 {
22  protected $storeManager;
23 
28  protected $urlBuilder;
29 
33  protected $scopeConfig;
34 
38  private $customerUrl;
39 
46  public function __construct(
50  Url $customerUrl = null
51  ) {
52  $this->urlBuilder = $urlBuilder;
53  $this->storeManager = $storeManager;
54  $this->scopeConfig = $scopeConfig;
55  $this->customerUrl = $customerUrl ?? ObjectManager::getInstance()
56  ->get(Url::class);
57  }
58 
62  public function getConfig()
63  {
64  return [
65  'customerLoginUrl' => $this->getLoginUrl(),
66  'isRedirectRequired' => $this->isRedirectRequired(),
67  'autocomplete' => $this->isAutocompleteEnabled(),
68  ];
69  }
70 
77  protected function isAutocompleteEnabled()
78  {
79  return $this->scopeConfig->getValue(
82  ) ? 'on' : 'off';
83  }
84 
90  protected function getLoginUrl()
91  {
92  return $this->customerUrl->getLoginUrl();
93  }
94 
100  protected function isRedirectRequired()
101  {
102  $baseUrl = $this->storeManager->getStore()->getBaseUrl();
103 
104  if (strpos($this->getLoginUrl(), $baseUrl) !== false) {
105  return false;
106  }
107 
108  return true;
109  }
110 }
const XML_PATH_ENABLE_AUTOCOMPLETE
Definition: Form.php:19
__construct(UrlInterface $urlBuilder, StoreManagerInterface $storeManager, ScopeConfigInterface $scopeConfig, Url $customerUrl=null)