Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <type name="MagentoCustomerModelAddressAbstractAddress">
- <plugin name="aroundAddressValidation" type="XxxOptionalLastnamePluginCustomerModelAddressAbstractAddress" sortOrder="10"/>
- </type>
- <?php
- namespace XxxOptionalLastnamePluginCustomerModelAddress;
- class AbstractAddress
- {
- protected $_directoryData = null;
- protected $_eavConfig;
- public function __construct(
- MagentoDirectoryHelperData $directoryData ,MagentoEavModelConfig $eavConfig
- )
- {
- $this->_directoryData = $directoryData;
- $this->_eavConfig = $eavConfig;
- }
- public function aroundValidate(
- MagentoCustomerModelAddressAbstractAddress $subject,
- callable $proceed)
- {
- $errors = [];
- if (!Zend_Validate::is( $subject->getFirstname(), 'NotEmpty')) {
- $errors[] = __('%fieldName is a required field.', ['fieldName' => 'firstname']);
- }
- // if (!Zend_Validate::is($this->getLastname(), 'NotEmpty')) {
- // $errors[] = __('%fieldName is a required field.', ['fieldName' => 'lastname']);
- // }
- if (!Zend_Validate::is( $subject->getStreetLine(1), 'NotEmpty')) {
- $errors[] = __('%fieldName is a required field.', ['fieldName' => 'street']);
- }
- if (!Zend_Validate::is( $subject->getCity(), 'NotEmpty')) {
- $errors[] = __('%fieldName is a required field.', ['fieldName' => 'city']);
- }
- if ($this->isTelephoneRequired()) {
- if (!Zend_Validate::is( $subject->getTelephone(), 'NotEmpty')) {
- $errors[] = __('%fieldName is a required field.', ['fieldName' => 'telephone']);
- }
- }
- if ($this->isFaxRequired()) {
- if (!Zend_Validate::is( $subject->getFax(), 'NotEmpty')) {
- $errors[] = __('%fieldName is a required field.', ['fieldName' => 'fax']);
- }
- }
- if ($this->isCompanyRequired()) {
- if (!Zend_Validate::is( $subject->getCompany(), 'NotEmpty')) {
- $errors[] = __('%fieldName is a required field.', ['fieldName' => 'company']);
- }
- }
- return $errors;
- } }
Add Comment
Please, Sign In to add comment