66namespace Magento \Customer \Model \Metadata \Form ;
77
88use Magento \Customer \Api \Data \AttributeMetadataInterface ;
9- use Magento \Customer \Model \Metadata \ElementFactory ;
109use Magento \Directory \Helper \Data as DirectoryHelper ;
11- use Magento \Framework \Api \ArrayObjectSearch ;
1210use Magento \Framework \Stdlib \StringUtils ;
1311use Magento \Framework \Locale \ResolverInterface ;
1412use Psr \Log \LoggerInterface as PsrLogger ;
1715/**
1816 * Customer Address Postal/Zip Code Attribute Data Model
1917 */
20- class Postcode extends AbstractData
18+ class Postcode extends Text
2119{
2220 /**
2321 * @var DirectoryHelper
2422 */
25- protected $ directoryHelper ;
23+ protected DirectoryHelper $ directoryHelper ;
2624
2725 /**
2826 * @var StringUtils
@@ -52,7 +50,7 @@ public function __construct(
5250 StringUtils $ stringHelper = null
5351 ) {
5452 $ this ->directoryHelper = $ directoryHelper ;
55- if (is_null ( $ stringHelper) ) {
53+ if ($ stringHelper === null ) {
5654 $ stringHelper = \Magento \Framework \App \ObjectManager::getInstance ()->get (StringUtils::class);
5755 }
5856 $ this ->_string = $ stringHelper ;
@@ -63,7 +61,8 @@ public function __construct(
6361 $ localeResolver ,
6462 $ value ,
6563 $ entityTypeCode ,
66- $ isAjax
64+ $ isAjax ,
65+ $ stringHelper
6766 );
6867 }
6968
@@ -102,74 +101,4 @@ public function validateValue($value)
102101 }
103102 return $ errors ;
104103 }
105-
106- /**
107- * @inheritdoc
108- */
109- public function extractValue (\Magento \Framework \App \RequestInterface $ request )
110- {
111- return $ this ->_applyInputFilter ($ this ->_getRequestValue ($ request ));
112- }
113-
114- /**
115- * @inheritdoc
116- */
117- public function compactValue ($ value )
118- {
119- return $ value ;
120- }
121-
122- /**
123- * @inheritdoc
124- */
125- public function restoreValue ($ value )
126- {
127- return $ this ->compactValue ($ value );
128- }
129-
130- /**
131- * @inheritdoc
132- */
133- public function outputValue ($ format = ElementFactory::OUTPUT_FORMAT_TEXT )
134- {
135- return $ this ->_applyOutputFilter ($ this ->_value );
136- }
137-
138- /**
139- * Length validation
140- *
141- * @param mixed $value
142- * @param AttributeMetadataInterface $attribute
143- * @param array $errors
144- * @return array
145- */
146- private function validateLength ($ value , AttributeMetadataInterface $ attribute , array $ errors ): array
147- {
148- // validate length
149- $ label = __ ($ attribute ->getStoreLabel ());
150-
151- $ length = $ value ? $ this ->_string ->strlen (trim ($ value )) : 0 ;
152-
153- $ validateRules = $ attribute ->getValidationRules ();
154-
155- if (!empty (ArrayObjectSearch::getArrayElementByName ($ validateRules , 'input_validation ' ))) {
156- $ minTextLength = ArrayObjectSearch::getArrayElementByName (
157- $ validateRules ,
158- 'min_text_length '
159- );
160- if ($ minTextLength !== null && $ length < $ minTextLength ) {
161- $ errors [] = __ ('"%1" length must be equal or greater than %2 characters. ' , $ label , $ minTextLength );
162- }
163-
164- $ maxTextLength = ArrayObjectSearch::getArrayElementByName (
165- $ validateRules ,
166- 'max_text_length '
167- );
168- if ($ maxTextLength !== null && $ length > $ maxTextLength ) {
169- $ errors [] = __ ('"%1" length must be equal or less than %2 characters. ' , $ label , $ maxTextLength );
170- }
171- }
172-
173- return $ errors ;
174- }
175104}
0 commit comments