Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-customer
Model
Attribute
Data
Postcode.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Customer\Model\Attribute\Data
;
7
8
use
Magento\Directory\Helper\Data
as DirectoryHelper;
9
use
Magento\Eav\Model\AttributeDataFactory
;
10
use
Magento\Framework\App\RequestInterface
;
11
use
Magento\Framework\Locale\ResolverInterface
;
12
use Psr\Log\LoggerInterface as PsrLogger;
13
use
Magento\Framework\Stdlib\DateTime\TimezoneInterface
as MagentoTimezone;
14
19
class
Postcode
extends
\Magento\Eav\Model\Attribute\Data\AbstractData
20
{
24
protected
$directoryHelper
;
25
32
public
function
__construct
(
33
MagentoTimezone $localeDate,
34
PsrLogger
$logger
,
35
ResolverInterface
$localeResolver,
36
DirectoryHelper
$directoryHelper
37
) {
38
$this->directoryHelper =
$directoryHelper
;
39
parent::__construct($localeDate,
$logger
, $localeResolver);
40
}
41
49
public
function
validateValue
(
$value
)
50
{
51
$attribute
= $this->
getAttribute
();
52
53
$countryId = $this->
getExtractedData
(
'country_id'
);
54
if
($this->directoryHelper->isZipCodeOptional($countryId)) {
55
return
true
;
56
}
57
58
$errors
= [];
59
if
(empty(
$value
) &&
$value
!==
'0'
) {
60
$label
=
__
(
$attribute
->getStoreLabel());
61
$errors
[] =
__
(
'"%1" is a required value.'
,
$label
);
62
}
63
if
(count(
$errors
) == 0) {
64
return
true
;
65
}
66
return
$errors
;
67
}
68
75
public
function
extractValue
(
RequestInterface
$request
)
76
{
77
$value
= $this->
_getRequestValue
($request);
78
return
$this->
_applyInputFilter
(
$value
);
79
}
80
87
public
function
compactValue
(
$value
)
88
{
89
if
(
$value
!==
false
) {
90
$this->
getEntity
()->setDataUsingMethod($this->
getAttribute
()->
getAttributeCode
(),
$value
);
91
}
92
return
$this;
93
}
94
101
public
function
restoreValue
(
$value
)
102
{
103
return
$this->
compactValue
(
$value
);
104
}
105
113
public
function
outputValue
(
$format
= AttributeDataFactory::OUTPUT_FORMAT_TEXT)
114
{
115
$value
= $this->
getEntity
()
116
->getData($this->
getAttribute
()->
getAttributeCode
());
117
$value
= $this->
_applyOutputFilter
(
$value
);
118
return
$value
;
119
}
120
}
Magento\Directory\Helper\Data
Definition:
Data.php:17
Magento\Eav\Model\Attribute\Data\AbstractData\_applyInputFilter
_applyInputFilter($value)
Definition:
AbstractData.php:221
Magento\Eav\Model\Attribute\Data\AbstractData\getExtractedData
getExtractedData($index=null)
Definition:
AbstractData.php:204
Magento\Customer\Model\Attribute\Data\Postcode\compactValue
compactValue($value)
Definition:
Postcode.php:87
Magento\Eav\Model\Attribute\Data\AbstractData\getEntity
getEntity()
Definition:
AbstractData.php:177
$attribute
$attribute
Definition:
attribute_set_with_image_attribute.php:41
Magento\Eav\Model\Attribute\Data\AbstractData\_getRequestValue
_getRequestValue(RequestInterface $request)
Definition:
AbstractData.php:507
Magento\Customer\Model\Attribute\Data
Definition:
AbstractData.php:12
Magento\Eav\Model\Attribute\Data\AbstractData\getAttribute
getAttribute()
Definition:
AbstractData.php:123
Magento\Customer\Model\Attribute\Data\Postcode\$directoryHelper
$directoryHelper
Definition:
Postcode.php:24
__
__()
Definition:
__.php:13
$logger
$logger
Definition:
health_check.php:20
Magento\Framework\Stdlib\DateTime\TimezoneInterface
Definition:
TimezoneInterface.php:14
Magento\Eav\Model\AttributeDataFactory
Definition:
AttributeDataFactory.php:14
$label
$label
Definition:
details.phtml:21
$value
$value
Definition:
gender.phtml:16
$format
$format
Definition:
list.phtml:12
Magento\Customer\Model\Attribute\Data\Postcode\outputValue
outputValue($format=AttributeDataFactory::OUTPUT_FORMAT_TEXT)
Definition:
Postcode.php:113
Magento\Framework\Locale\ResolverInterface
Definition:
ResolverInterface.php:14
Magento\Eav\Model\Entity\Attribute\AbstractAttribute\getAttributeCode
getAttributeCode()
Definition:
AbstractAttribute.php:321
Magento\Customer\Model\Attribute\Data\Postcode
Definition:
Postcode.php:19
Magento\Framework\App\RequestInterface
Definition:
RequestInterface.php:14
Magento\Customer\Model\Attribute\Data\Postcode\restoreValue
restoreValue($value)
Definition:
Postcode.php:101
$request
$request
Definition:
quote_with_configurable_product_last_variation.php:22
Magento\Customer\Model\Attribute\Data\Postcode\extractValue
extractValue(RequestInterface $request)
Definition:
Postcode.php:75
Magento\Customer\Model\Attribute\Data\Postcode\validateValue
validateValue($value)
Definition:
Postcode.php:49
Magento\Customer\Model\Attribute\Data\Postcode\__construct
__construct(MagentoTimezone $localeDate, PsrLogger $logger, ResolverInterface $localeResolver, DirectoryHelper $directoryHelper)
Definition:
Postcode.php:32
Magento\Eav\Model\Attribute\Data\AbstractData\_applyOutputFilter
_applyOutputFilter($value)
Definition:
AbstractData.php:285
$errors
$errors
Definition:
overview.phtml:9