Context: How is «Submit Shipment» implemented?
958164/app/code/Magento/Shipping/Controller/Adminhtml/Order/ShipmentLoader.php#L95-L142
/**
* Initialize shipment model instance
*
* @return bool|\Magento\Sales\Model\Order\Shipment
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function load()
{
$shipment = false;
$orderId = $this->getOrderId();
$shipmentId = $this->getShipmentId();
if ($shipmentId) {
$shipment = $this->shipmentRepository->get($shipmentId);
} elseif ($orderId) {
$order = $this->orderRepository->get($orderId);
/**
* Check order existing
*/
if (!$order->getId()) {
$this->messageManager->addError(__('The order no longer exists.'));
return false;
}
/**
* Check shipment is available to create separate from invoice
*/
if ($order->getForcedShipmentWithInvoice()) {
$this->messageManager->addError(__('Cannot do shipment for the order separately from invoice.'));
return false;
}
/**
* Check shipment create availability
*/
if (!$order->canShip()) {
$this->messageManager->addError(__('Cannot do shipment for the order.'));
return false;
}
$shipment = $this->shipmentFactory->create(
$order,
$this->getItemQtys(),
$this->getTracking()
);
}
$this->registry->register('current_shipment', $shipment);
return $shipment;
}
Details: