hryvinskyi /
magento2-quote-address-validator
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Hryvinskyi\QuoteAddressValidator\Plugin; |
||||
| 4 | |||||
| 5 | use Hryvinskyi\QuoteAddressValidator\Model\AddressValidationInterface; |
||||
| 6 | use Hryvinskyi\QuoteAddressValidator\Model\ConfigInterface; |
||||
| 7 | use Magento\Quote\Api\Data\AddressInterface; |
||||
| 8 | use Magento\Quote\Api\Data\CartInterface; |
||||
| 9 | use Magento\Quote\Model\QuoteAddressValidator; |
||||
| 10 | |||||
| 11 | class AddAttributesValidation |
||||
| 12 | { |
||||
| 13 | /** |
||||
| 14 | * @var AddressValidationInterface |
||||
| 15 | */ |
||||
| 16 | private $addressValidation; |
||||
| 17 | |||||
| 18 | /** |
||||
| 19 | * @var ConfigInterface |
||||
| 20 | */ |
||||
| 21 | private $config; |
||||
| 22 | |||||
| 23 | public function __construct( |
||||
| 24 | AddressValidationInterface $addressValidation, |
||||
| 25 | ConfigInterface $config |
||||
| 26 | ) { |
||||
| 27 | $this->addressValidation = $addressValidation; |
||||
| 28 | $this->config = $config; |
||||
| 29 | } |
||||
| 30 | |||||
| 31 | /** |
||||
| 32 | * @param QuoteAddressValidator $subject |
||||
| 33 | * @param null $result |
||||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||||
| 34 | * @param CartInterface $cart |
||||
| 35 | * @param AddressInterface $address |
||||
| 36 | * @return void |
||||
| 37 | * @noinspection UnusedFormalParameterInspection |
||||
| 38 | * @noinspection PhpUnusedParameterInspection |
||||
| 39 | */ |
||||
| 40 | public function afterValidateForCart( |
||||
| 41 | QuoteAddressValidator $subject, |
||||
| 42 | $result, |
||||
| 43 | CartInterface $cart, |
||||
| 44 | AddressInterface $address |
||||
| 45 | ): void { |
||||
| 46 | if ($this->config->isEnabled()) { |
||||
| 47 | $this->addressValidation->validate($address); |
||||
| 48 | } |
||||
| 49 | } |
||||
| 50 | |||||
| 51 | /** |
||||
| 52 | * @param QuoteAddressValidator $subject |
||||
| 53 | * @param bool $result |
||||
| 54 | * @param AddressInterface $address |
||||
| 55 | * @return void |
||||
| 56 | */ |
||||
| 57 | public function afterValidate( |
||||
| 58 | QuoteAddressValidator $subject, |
||||
|
0 ignored issues
–
show
The parameter
$subject is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 59 | bool $result, |
||||
| 60 | AddressInterface $address |
||||
| 61 | ): bool { |
||||
| 62 | if ($this->config->isEnabled()) { |
||||
| 63 | $this->addressValidation->validate($address); |
||||
| 64 | } |
||||
| 65 | |||||
| 66 | return $result; |
||||
|
0 ignored issues
–
show
|
|||||
| 67 | } |
||||
| 68 | } |
||||
| 69 |