@@ -67,36 +67,28 @@ private function doValidate(AddressInterface $address, $customerId)
67
67
try {
68
68
$ customer = $ this ->customerRepository ->getById ($ customerId );
69
69
} catch (NoSuchEntityException $ exception ) {
70
- throw new NoSuchEntityException (
71
- __ ('Invalid customer id %1 ' , $ customerId )
72
- );
70
+ throw new NoSuchEntityException (__ ('Invalid customer id %1 ' , $ customerId ));
73
71
}
74
72
}
75
73
76
74
if ($ address ->getCustomerAddressId ()) {
77
75
//Existing address cannot belong to a guest
78
76
if (!$ customerId ) {
79
- throw new NoSuchEntityException (
80
- __ ('Invalid customer address id %1 ' , $ address ->getCustomerAddressId ())
81
- );
77
+ throw new NoSuchEntityException (__ ('Invalid customer address id %1 ' , $ address ->getCustomerAddressId ()));
82
78
}
83
79
//Validating address ID
84
80
try {
85
81
$ this ->addressRepository ->getById ($ address ->getCustomerAddressId ());
86
82
} catch (NoSuchEntityException $ e ) {
87
- throw new NoSuchEntityException (
88
- __ ('Invalid address id %1 ' , $ address ->getId ())
89
- );
83
+ throw new NoSuchEntityException (__ ('Invalid address id %1 ' , $ address ->getId ()));
90
84
}
91
85
//Finding available customer's addresses
92
86
$ applicableAddressIds = array_map (function ($ address ) {
93
87
/** @var \Magento\Customer\Api\Data\AddressInterface $address */
94
88
return $ address ->getId ();
95
89
}, $ this ->customerRepository ->getById ($ customerId )->getAddresses ());
96
90
if (!in_array ($ address ->getCustomerAddressId (), $ applicableAddressIds )) {
97
- throw new NoSuchEntityException (
98
- __ ('Invalid customer address id %1 ' , $ address ->getCustomerAddressId ())
99
- );
91
+ throw new NoSuchEntityException (__ ('Invalid customer address id %1 ' , $ address ->getCustomerAddressId ()));
100
92
}
101
93
}
102
94
}
0 commit comments