• Модуль: catalogmobile
  • Путь к файлу: ~/bitrix/modules/catalogmobile/lib/EntityEditor/RealizationDocumentProvider.php
  • Класс: BitrixCatalogMobileEntityEditorRealizationDocumentProvider
  • Вызов: RealizationDocumentProvider::__construct
public function __construct(?int $documentId, array $context = [])
{
	$this->context = $context;
	if ($documentId)
	{
		$this->shipment = BitrixSaleRepositoryShipmentRepository::getInstance()->getById($documentId);
		if (!$this->shipment)
		{
			throw new DomainException('Realization document not found!');
		}
		$this->order = $this->shipment->getOrder();
	}
	else if ($context['paymentId'])
	{
		$this->payment = BitrixSaleRepositoryPaymentRepository::getInstance()->getById($context['paymentId']);
		if ($this->payment)
		{
			$this->order = $this->payment->getOrder();
			$this->shipment = $this->order->getShipmentCollection()->createItem();
		}
		else
		{
			throw new DomainException('Payment document not found!');
		}
	}
	elseif ($context['orderId'] && $context['orderId'] > 0)
	{
		$this->order = BitrixCrmOrderOrder::load($context['orderId']);
		if ($this->order)
		{
			$this->shipment = $this->order->getShipmentCollection()->createItem();
		}
		else
		{
			throw new DomainException('Order not found!');
		}
	}
	else
	{
		$this->order = BitrixCrmOrderManager::createEmptyOrder(SITE_ID);
		$this->shipment = $this->order->getShipmentCollection()->createItem();
	}
}