Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
OrderRefundCreationArguments.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 
49  public function afterValidate(
50  RefundOrderInterface $refundOrderValidator,
51  ValidatorResultInterface $validationResults,
54  array $items = [],
55  $notify = false,
56  $appendComment = false,
57  CreditmemoCommentCreationInterface $comment = null,
59  ) {
60  if ($this->isReturnToStockItems($arguments)) {
61  return $validationResults;
62  }
63 
64  $returnToStockItems = $arguments->getExtensionAttributes()->getReturnToStockItems();
65  $validationMessage = $this->returnValidator->validate($returnToStockItems, $creditmemo);
66  if ($validationMessage) {
67  $validationResults->addMessage($validationMessage);
68  }
69 
70  return $validationResults;
71  }
72 
77  private function isReturnToStockItems($arguments)
78  {
79  return $arguments === null
80  || $arguments->getExtensionAttributes() === null
81  || $arguments->getExtensionAttributes()->getReturnToStockItems() === null;
82  }
83 }
$order
Definition: order.php:55
afterValidate(RefundOrderInterface $refundOrderValidator, ValidatorResultInterface $validationResults, OrderInterface $order, CreditmemoInterface $creditmemo, array $items=[], $notify=false, $appendComment=false, CreditmemoCommentCreationInterface $comment=null, CreditmemoCreationArgumentsInterface $arguments=null)
$arguments
$items