|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright © 2021 O2TI. All rights reserved. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Bruno Elisei <[email protected]> |
|
6
|
|
|
* See LICENSE.txt for license details. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
declare(strict_types=1); |
|
10
|
|
|
|
|
11
|
|
|
namespace O2TI\AdvancedStreetAddress\Block\Customer\Address; |
|
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\AdvancedStreetAddress\Helper\Config; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Edit - Change Template Edit Account. |
|
22
|
|
|
*/ |
|
23
|
|
|
class Edit 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 if Use Label. |
|
62
|
|
|
* |
|
63
|
|
|
* @param int $position |
|
64
|
|
|
* |
|
65
|
|
|
* @return bool|null |
|
66
|
|
|
*/ |
|
67
|
|
|
public function getUseLabel(int $position): ?bool |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->config->getConfigForLabel($position, 'use_label'); |
|
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Get Label. |
|
74
|
|
|
* |
|
75
|
|
|
* @param int $position |
|
76
|
|
|
* |
|
77
|
|
|
* @return string|null |
|
78
|
|
|
*/ |
|
79
|
|
|
public function getLabel(int $position): ?string |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->config->getConfigForLabel($position, 'label'); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Get Is Required. |
|
86
|
|
|
* |
|
87
|
|
|
* @param int $position |
|
88
|
|
|
* |
|
89
|
|
|
* @return string |
|
90
|
|
|
*/ |
|
91
|
|
|
public function getIsRequired(int $position): ?string |
|
92
|
|
|
{ |
|
93
|
|
|
if ($this->config->getConfigForValidation($position, 'is_required')) { |
|
|
|
|
|
|
94
|
|
|
return 'required-entry'; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
return ''; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* Get Max Length. |
|
102
|
|
|
* |
|
103
|
|
|
* @param int $position |
|
104
|
|
|
* |
|
105
|
|
|
* @return int|null |
|
106
|
|
|
*/ |
|
107
|
|
|
public function getMaxLength($position): ?int |
|
108
|
|
|
{ |
|
109
|
|
|
return $this->config->getConfigForValidation($position, 'max_length'); |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|
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..