|
11 | 11 | use Magento\Sales\Api\ShipOrderInterface; |
12 | 12 | use Magento\Sales\Model\Order\Config as OrderConfig; |
13 | 13 | use Magento\Sales\Model\Order\OrderStateResolverInterface; |
| 14 | +use Magento\Sales\Model\Order\OrderValidatorInterface; |
14 | 15 | use Magento\Sales\Model\Order\ShipmentDocumentFactory; |
15 | 16 | use Magento\Sales\Model\Order\Shipment\NotifierInterface; |
| 17 | +use Magento\Sales\Model\Order\Shipment\ShipmentValidatorInterface; |
16 | 18 | use Magento\Sales\Model\Order\Shipment\OrderRegistrarInterface; |
17 | 19 | use Magento\Sales\Model\Order\Validation\ShipOrderInterface as ShipOrderValidator; |
18 | 20 | use Psr\Log\LoggerInterface; |
| 21 | +use Magento\Framework\App\ObjectManager; |
19 | 22 |
|
20 | 23 | /** |
21 | 24 | * Class ShipOrder |
@@ -77,37 +80,46 @@ class ShipOrder implements ShipOrderInterface |
77 | 80 | * @param ResourceConnection $resourceConnection |
78 | 81 | * @param OrderRepositoryInterface $orderRepository |
79 | 82 | * @param ShipmentDocumentFactory $shipmentDocumentFactory |
| 83 | + * @param ShipmentValidatorInterface $shipmentValidator |
| 84 | + * @param OrderValidatorInterface $orderValidator |
80 | 85 | * @param OrderStateResolverInterface $orderStateResolver |
81 | 86 | * @param OrderConfig $config |
82 | 87 | * @param ShipmentRepositoryInterface $shipmentRepository |
83 | | - * @param ShipOrderValidator $shipOrderValidator |
84 | 88 | * @param NotifierInterface $notifierInterface |
85 | 89 | * @param OrderRegistrarInterface $orderRegistrar |
86 | | - * @param LoggerInterface $logger |
| 90 | + * @param LoggerInterface $logger, |
| 91 | + * @param ShipOrderValidator|null $shipOrderValidator |
87 | 92 | * @SuppressWarnings(PHPMD.ExcessiveParameterList) |
| 93 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
88 | 94 | */ |
89 | 95 | public function __construct( |
90 | 96 | ResourceConnection $resourceConnection, |
91 | 97 | OrderRepositoryInterface $orderRepository, |
92 | 98 | ShipmentDocumentFactory $shipmentDocumentFactory, |
| 99 | + ShipmentValidatorInterface $shipmentValidator, |
| 100 | + OrderValidatorInterface $orderValidator, |
93 | 101 | OrderStateResolverInterface $orderStateResolver, |
94 | 102 | OrderConfig $config, |
95 | 103 | ShipmentRepositoryInterface $shipmentRepository, |
96 | | - ShipOrderValidator $shipOrderValidator, |
97 | 104 | NotifierInterface $notifierInterface, |
98 | 105 | OrderRegistrarInterface $orderRegistrar, |
99 | | - LoggerInterface $logger |
| 106 | + LoggerInterface $logger, |
| 107 | + ShipOrderValidator $shipOrderValidator = null |
100 | 108 | ) { |
101 | 109 | $this->resourceConnection = $resourceConnection; |
102 | 110 | $this->orderRepository = $orderRepository; |
103 | 111 | $this->shipmentDocumentFactory = $shipmentDocumentFactory; |
| 112 | + $this->shipmentValidator = $shipmentValidator; |
| 113 | + $this->orderValidator = $orderValidator; |
104 | 114 | $this->orderStateResolver = $orderStateResolver; |
105 | 115 | $this->config = $config; |
106 | 116 | $this->shipmentRepository = $shipmentRepository; |
107 | | - $this->shipOrderValidator = $shipOrderValidator; |
108 | 117 | $this->notifierInterface = $notifierInterface; |
109 | 118 | $this->logger = $logger; |
110 | 119 | $this->orderRegistrar = $orderRegistrar; |
| 120 | + $this->shipOrderValidator = $shipOrderValidator ?: ObjectManager::getInstance()->get( |
| 121 | + ShipOrderValidator::class |
| 122 | + ); |
111 | 123 | } |
112 | 124 |
|
113 | 125 | /** |
|
0 commit comments