|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright © O2TI. All rights reserved. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Bruno Elisei <[email protected]> |
|
6
|
|
|
* See COPYING.txt for license details. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
declare(strict_types=1); |
|
10
|
|
|
|
|
11
|
|
|
namespace O2TI\InputMasking\Block\Customer; |
|
12
|
|
|
|
|
13
|
|
|
use Magento\Framework\App\Config\ScopeConfigInterface; |
|
14
|
|
|
use Magento\Framework\View\Element\Template; |
|
15
|
|
|
use Magento\Framework\View\Element\Template\Context; |
|
16
|
|
|
use Magento\Store\Model\ScopeInterface; |
|
17
|
|
|
use Magento\Store\Model\StoreManagerInterface; |
|
18
|
|
|
use O2TI\InputMasking\Helper\Config; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Class Block Address - Implements Input Masking. |
|
22
|
|
|
*/ |
|
23
|
|
|
class Address extends Template |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @var Config |
|
27
|
|
|
*/ |
|
28
|
|
|
private $config; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var ScopeInterface |
|
32
|
|
|
*/ |
|
33
|
|
|
private $scopeConfig; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var StoreManagerInterface |
|
37
|
|
|
*/ |
|
38
|
|
|
private $storeManagerInterface; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @param ScopeConfigInterface $scopeConfig |
|
42
|
|
|
* @param StoreManagerInterface $storeManagerInterface |
|
43
|
|
|
* @param Context $context |
|
44
|
|
|
* @param Config $config |
|
45
|
|
|
* @param array $data |
|
46
|
|
|
*/ |
|
47
|
|
|
public function __construct( |
|
48
|
|
|
ScopeConfigInterface $scopeConfig, |
|
49
|
|
|
StoreManagerInterface $storeManagerInterface, |
|
50
|
|
|
Context $context, |
|
51
|
|
|
Config $config, |
|
52
|
|
|
array $data = [] |
|
53
|
|
|
) { |
|
54
|
|
|
$this->scopeConfig = $scopeConfig; |
|
|
|
|
|
|
55
|
|
|
$this->storeManagerInterface = $storeManagerInterface; |
|
56
|
|
|
$this->config = $config; |
|
57
|
|
|
parent::__construct($context, $data); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Get Configs Module. |
|
62
|
|
|
* |
|
63
|
|
|
* @param string $field |
|
64
|
|
|
* |
|
65
|
|
|
* @return string |
|
66
|
|
|
*/ |
|
67
|
|
|
public function getConfigModule(string $field): ?string |
|
68
|
|
|
{ |
|
69
|
|
|
$storeId = $this->_storeManager->getStore()->getId(); |
|
70
|
|
|
$configPath = sprintf(Config::CONFIG_PATH_GENERAL, $field); |
|
71
|
|
|
|
|
72
|
|
|
return $this->_scopeConfig->getValue($configPath, ScopeInterface::SCOPE_STORE, $storeId); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Get Config Address For Input. |
|
77
|
|
|
* |
|
78
|
|
|
* @param string $input |
|
79
|
|
|
* @param string $field |
|
80
|
|
|
* |
|
81
|
|
|
* @return string |
|
82
|
|
|
*/ |
|
83
|
|
|
public function getConfigAddressForInput(string $input, string $field): ?string |
|
84
|
|
|
{ |
|
85
|
|
|
$storeId = $this->_storeManager->getStore()->getId(); |
|
86
|
|
|
$configPath = sprintf(Config::CONFIG_PATH_ADDRESS_INPUT, $input, $field); |
|
87
|
|
|
|
|
88
|
|
|
return $this->_scopeConfig->getValue($configPath, ScopeInterface::SCOPE_STORE, $storeId); |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..