- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/compatible/eventcompatibility.php
- Класс: BitrixSaleCompatibleEventCompatibility
- Вызов: EventCompatibility::onShipmentAllowDelivery
static function onShipmentAllowDelivery(MainEvent $event)
{
if (static::$disableEvent === true)
{
return new MainEventResult( MainEventResult::SUCCESS, null, 'sale');
}
$parameters = $event->getParameters();
/** @var SaleShipment $shipment */
$shipment = $parameters['ENTITY'];
$oldValues = $parameters['VALUES'];
if (!$shipment instanceof SaleShipment)
{
return new MainEventResult(
MainEventResult::ERROR,
new SaleResultError(MainLocalizationLoc::getMessage('SALE_EVENT_COMPATIBILITY_WRONG_SHIPMENT'), 'SALE_EVENT_COMPATIBILITY_SHIPMENT_ALLOW_DELIVERY_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');
}
if ($shipmentCollection->isAllowDelivery() && array_key_exists('ALLOW_DELIVERY', $oldValues) && strval($shipment->getField('ALLOW_DELIVERY')) != ''
&& $oldValues["ALLOW_DELIVERY"] != $shipment->getField('ALLOW_DELIVERY'))
{
$registry = SaleRegistry::getInstance($shipment::getRegistryType());
/** @var SaleNotify $notifyClassName */
$notifyClassName = $registry->getNotifyClassName();
$notifyClassName::sendShipmentAllowDelivery($shipment);
}
return new MainEventResult( MainEventResult::SUCCESS, null, 'sale');
}