Guest User

Untitled

a guest
Nov 23rd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. <type name="MagentoCustomerModelAddressAbstractAddress">
  2. <plugin name="aroundAddressValidation" type="XxxOptionalLastnamePluginCustomerModelAddressAbstractAddress" sortOrder="10"/>
  3. </type>
  4.  
  5. <?php
  6.  
  7. namespace XxxOptionalLastnamePluginCustomerModelAddress;
  8.  
  9. class AbstractAddress
  10. {
  11.  
  12. protected $_directoryData = null;
  13. protected $_eavConfig;
  14.  
  15. public function __construct(
  16. MagentoDirectoryHelperData $directoryData ,MagentoEavModelConfig $eavConfig
  17. )
  18. {
  19. $this->_directoryData = $directoryData;
  20. $this->_eavConfig = $eavConfig;
  21.  
  22. }
  23.  
  24. public function aroundValidate(
  25. MagentoCustomerModelAddressAbstractAddress $subject,
  26. callable $proceed)
  27. {
  28.  
  29. $errors = [];
  30. if (!Zend_Validate::is( $subject->getFirstname(), 'NotEmpty')) {
  31. $errors[] = __('%fieldName is a required field.', ['fieldName' => 'firstname']);
  32. }
  33.  
  34. // if (!Zend_Validate::is($this->getLastname(), 'NotEmpty')) {
  35. // $errors[] = __('%fieldName is a required field.', ['fieldName' => 'lastname']);
  36. // }
  37. if (!Zend_Validate::is( $subject->getStreetLine(1), 'NotEmpty')) {
  38. $errors[] = __('%fieldName is a required field.', ['fieldName' => 'street']);
  39. }
  40.  
  41. if (!Zend_Validate::is( $subject->getCity(), 'NotEmpty')) {
  42. $errors[] = __('%fieldName is a required field.', ['fieldName' => 'city']);
  43. }
  44.  
  45. if ($this->isTelephoneRequired()) {
  46. if (!Zend_Validate::is( $subject->getTelephone(), 'NotEmpty')) {
  47. $errors[] = __('%fieldName is a required field.', ['fieldName' => 'telephone']);
  48. }
  49. }
  50.  
  51. if ($this->isFaxRequired()) {
  52. if (!Zend_Validate::is( $subject->getFax(), 'NotEmpty')) {
  53. $errors[] = __('%fieldName is a required field.', ['fieldName' => 'fax']);
  54. }
  55. }
  56.  
  57. if ($this->isCompanyRequired()) {
  58. if (!Zend_Validate::is( $subject->getCompany(), 'NotEmpty')) {
  59. $errors[] = __('%fieldName is a required field.', ['fieldName' => 'company']);
  60. }
  61. }
  62. return $errors;
  63. } }
Add Comment
Please, Sign In to add comment