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

        $this->assertDeletable($item);

        // TODO If not made by the supplierOrderListener ?
        //$this->deleteSupplierOrderItemStockUnit($item);
        $this->stockUnitLinker->unlinkItem($item);

        // Supplier order has been set to null by the removeItem method.
        // Retrieve it from the change set.
        if (null === $order = $item->getOrder()) {
            $changeSet = $this->persistenceHelper->getChangeSet($item);
            if (array_key_exists('order', $changeSet)) {
                $order = $changeSet['order'][0];
            }
        }
        if (null === $order) {
            throw new RuntimeException("Failed to retrieve supplier order.");
        }

        // Clear association
        $item->setOrder(null);
        /* @see SupplierDeliveryListener::onDelete */
        //$order->getItems()->removeElement($item);

        // Trigger the supplier order update
        if (!$this->persistenceHelper->isScheduledForRemove($order)) {
            $this->scheduleSupplierOrderContentChangeEvent($order);
        }
    }
public function onDelete(ResourceEventInterface $event)
    {
        $item = $this->getSupplierOrderItemFromEvent($event);

        $this->assertDeletable($item);

        // TODO If not made by the supplierOrderListener ?
        //$this->deleteSupplierOrderItemStockUnit($item);
        $this->stockUnitLinker->unlinkItem($item);

        // Supplier order has been set to null by the removeItem method.
        // Retrieve it from the change set.
        if (null === $order = $item->getOrder()) {
            $changeSet = $this->persistenceHelper->getChangeSet($item);
            if (array_key_exists('order', $changeSet)) {
                $order = $changeSet['order'][0];
            }
        }
        if (null === $order) {
            throw new RuntimeException("Failed to retrieve supplier order.");
        }

        // Clear association
        $item->setOrder(null);
        /* @see SupplierDeliveryListener::onDelete */
        //$order->getItems()->removeElement($item);

        // Trigger the supplier order update
        if (!$this->persistenceHelper->isScheduledForRemove($order)) {
            $this->scheduleSupplierOrderContentChangeEvent($order);
        }
    }
public function onDelete ( ResourceEventInterface $ event ) { $ item = $ this -> getSupplierOrderItemFromEvent ( $ event ) ; $ this -> assertDeletable ( $ item ) ; // TODO If not made by the supplierOrderListener ? //$this->deleteSupplierOrderItemStockUnit($item); $ this -> stockUnitLinker -> unlinkItem ( $ item ) ; // Supplier order has been set to null by the removeItem method. // Retrieve it from the change set. if ( null === $ order = $ item -> getOrder ( ) ) { $ changeSet = $ this -> persistenceHelper -> getChangeSet ( $ item ) ; if ( array_key_exists ( 'order' , $ changeSet ) ) { $ order = $ changeSet [ 'order' ] [ 0 ] ; } } if ( null === $ order ) { throw new RuntimeException ( "Failed to retrieve supplier order." ) ; } // Clear association $ item -> setOrder ( null ) ; /* @see SupplierDeliveryListener::onDelete */ //$order->getItems()->removeElement($item); // Trigger the supplier order update if ( ! $ this -> persistenceHelper -> isScheduledForRemove ( $ order ) ) { $ this -> scheduleSupplierOrderContentChangeEvent ( $ order ) ; } }
Delete event handler.

@param ResourceEventInterface $event
Delete event handler .