• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/compatible/eventcompatibility.php
  • Класс: BitrixSaleCompatibleEventCompatibility
  • Вызов: EventCompatibility::onSaleDeliveryOrder
static function onSaleDeliveryOrder(MainEvent $event)
{
	if (static::$disableEvent === true)
	{
		return new MainEventResult( MainEventResult::SUCCESS, null, 'sale');
	}

	$parameters = $event->getParameters();

	/** @var SaleShipment $shipment */
	$shipment = $parameters['ENTITY'];
	if (!$shipment instanceof SaleShipment)
	{
		return new MainEventResult(
			MainEventResult::ERROR,
			new SaleResultError(MainLocalizationLoc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_SHIPMENT'), 'SALE_EVENT_COMPATIBILITY_DELIVER_ORDER_WRONG_SHIPMENT'),
			'sale'
		);
	}

	/** @var SaleShipmentCollection $shipmentCollection */
	if (!$shipmentCollection = $shipment->getCollection())
	{
		throw new MainObjectNotFoundException('Entity "ShipmentCollection" not found');
	}

	/** @var SaleOrder $order */
	if (!$order = $shipmentCollection->getOrder())
	{
		throw new MainObjectNotFoundException('Entity "Order" not found');
	}

	$id = $order->getId();

	static::setDisableEvent(true);
	foreach(GetModuleEvents("sale", static::EVENT_COMPATIBILITY_ON_SHIPMENT_DELIVER, true) as $oldEvent)
	{
		ExecuteModuleEventEx($oldEvent, array($id, $shipment->getField('ALLOW_DELIVERY')));
	}
	static::setDisableEvent(false);

	return new MainEventResult( MainEventResult::SUCCESS, null, 'sale');
}