Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
InvoiceRefundCreationArguments.php
Go to the documentation of this file.
1 <?php
7 
15 
20 {
24  private $returnValidator;
25 
30  public function __construct(
31  ReturnValidator $returnValidator
32  ) {
33  $this->returnValidator = $returnValidator;
34  }
35 
52  public function afterValidate(
53  RefundInvoiceInterface $refundInvoiceValidator,
54  ValidatorResultInterface $validationResults,
58  array $items = [],
59  $isOnline = false,
60  $notify = false,
61  $appendComment = false,
62  \Magento\Sales\Api\Data\CreditmemoCommentCreationInterface $comment = null,
64  ) {
65  if ($this->isReturnToStockItems($arguments)) {
66  return $validationResults;
67  }
68 
70  $returnToStockItems = $arguments->getExtensionAttributes()->getReturnToStockItems();
71  $validationMessage = $this->returnValidator->validate($returnToStockItems, $creditmemo);
72  if ($validationMessage) {
73  $validationResults->addMessage($validationMessage);
74  }
75 
76  return $validationResults;
77  }
78 
83  private function isReturnToStockItems($arguments)
84  {
85  return $arguments === null
86  || $arguments->getExtensionAttributes() === null
87  || $arguments->getExtensionAttributes()->getReturnToStockItems() === null;
88  }
89 }
$order
Definition: order.php:55
$invoice
$arguments
$items