Supplier/EventListener/SupplierDeliveryItemListener.php
public function onDelete(ResourceEventInterface $event)
    {
        $item = $this->getSupplierDeliveryItemFromEvent($event);

        $this->assertDeletable($item);

        if (null === $orderItem = $item->getOrderItem()) {
            throw new RuntimeException("OrderItem must be set.");
        }

        if (null !== $stockUnit = $orderItem->getStockUnit()) {
            $stockUnit->removeGeocode($item->getGeocode());
        } elseif ($orderItem->hasSubjectIdentity()) {
            throw new RuntimeException("Failed to retrieve stock unit.");
        }

        if ($this->persistenceHelper->isChanged($item, ['quantity'])) {
            $this->handleQuantityChange($item);
        } else {
            if (null !== $stockUnit) {
                // Debit stock unit received quantity
                $this->stockUnitUpdater->updateReceived($stockUnit, -$item->getQuantity(), true);
            }

            // Trigger the supplier order update
            // TODO get from change set
            if (null === $order = $orderItem->getOrder()) {
                throw new RuntimeException("Failed to retrieve supplier order.");
            }

            if (!$this->persistenceHelper->isScheduledForRemove($order)) {
                $this->scheduleSupplierOrderContentChangeEvent($order);
            }
        }

        // Clear association
        $item->setDelivery(null);
    }
public function onDelete(ResourceEventInterface $event)
    {
        $item = $this->getSupplierDeliveryItemFromEvent($event);

        $this->assertDeletable($item);

        if (null === $orderItem = $item->getOrderItem()) {
            throw new RuntimeException("OrderItem must be set.");
        }

        if (null !== $stockUnit = $orderItem->getStockUnit()) {
            $stockUnit->removeGeocode($item->getGeocode());
        } elseif ($orderItem->hasSubjectIdentity()) {
            throw new RuntimeException("Failed to retrieve stock unit.");
        }

        if ($this->persistenceHelper->isChanged($item, ['quantity'])) {
            $this->handleQuantityChange($item);
        } else {
            if (null !== $stockUnit) {
                // Debit stock unit received quantity
                $this->stockUnitUpdater->updateReceived($stockUnit, -$item->getQuantity(), true);
            }

            // Trigger the supplier order update
            // TODO get from change set
            if (null === $order = $orderItem->getOrder()) {
                throw new RuntimeException("Failed to retrieve supplier order.");
            }

            if (!$this->persistenceHelper->isScheduledForRemove($order)) {
                $this->scheduleSupplierOrderContentChangeEvent($order);
            }
        }

        // Clear association
        $item->setDelivery(null);
    }
Delete event handler.

@param ResourceEventInterface $event