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

        // Disallow product change
        if ($this->persistenceHelper->isChanged($item, 'product')) {
            $productCs = $this->persistenceHelper->getChangeSet($item, 'product');
            if ($productCs[0] != $productCs[1]) {
                // TODO message as translation id
                throw new IllegalOperationException("Changing supplier order item product is not supported yet.");
            }
        }

        $changed = $this->synchronizeWithProduct($item);
        if ($changed) {
            $this->persistenceHelper->persistAndRecompute($item, false);
        }

        // TODO These tests are made in the supplier order listener and should not be done twice...
        $order = $item->getOrder();
        if ($this->persistenceHelper->isChanged($order, 'state')) {
            $stateCs = $this->persistenceHelper->getChangeSet($order, 'state');

            // If order just did a stockable state transition
            if (
                SupplierOrderStates::hasChangedFromStockable($stateCs) ||
                SupplierOrderStates::hasChangedToStockable($stateCs)
            ) {
                // Abort (handled by the supplier order listener)
                return;
            }
        }

        if (SupplierOrderStates::isStockableState($order->getState())) {
            // Updates the ordered quantity and price
            if ($this->stockUnitLinker->applyItem($item)) {
                // Dispatch supplier order content change event
                $this->scheduleSupplierOrderContentChangeEvent($item->getOrder());
            }
        }
    }
public function onUpdate(ResourceEventInterface $event)
    {
        $item = $this->getSupplierOrderItemFromEvent($event);

        // Disallow product change
        if ($this->persistenceHelper->isChanged($item, 'product')) {
            $productCs = $this->persistenceHelper->getChangeSet($item, 'product');
            if ($productCs[0] != $productCs[1]) {
                // TODO message as translation id
                throw new IllegalOperationException("Changing supplier order item product is not supported yet.");
            }
        }

        $changed = $this->synchronizeWithProduct($item);
        if ($changed) {
            $this->persistenceHelper->persistAndRecompute($item, false);
        }

        // TODO These tests are made in the supplier order listener and should not be done twice...
        $order = $item->getOrder();
        if ($this->persistenceHelper->isChanged($order, 'state')) {
            $stateCs = $this->persistenceHelper->getChangeSet($order, 'state');

            // If order just did a stockable state transition
            if (
                SupplierOrderStates::hasChangedFromStockable($stateCs) ||
                SupplierOrderStates::hasChangedToStockable($stateCs)
            ) {
                // Abort (handled by the supplier order listener)
                return;
            }
        }

        if (SupplierOrderStates::isStockableState($order->getState())) {
            // Updates the ordered quantity and price
            if ($this->stockUnitLinker->applyItem($item)) {
                // Dispatch supplier order content change event
                $this->scheduleSupplierOrderContentChangeEvent($item->getOrder());
            }
        }
    }
public function onUpdate ( ResourceEventInterface $ event ) { $ item = $ this -> getSupplierOrderItemFromEvent ( $ event ) ; // Disallow product change if ( $ this -> persistenceHelper -> isChanged ( $ item , 'product' ) ) { $ productCs = $ this -> persistenceHelper -> getChangeSet ( $ item , 'product' ) ; if ( $ productCs [ 0 ] != $ productCs [ 1 ] ) { // TODO message as translation id throw new IllegalOperationException ( "Changing supplier order item product is not supported yet." ) ; } } $ changed = $ this -> synchronizeWithProduct ( $ item ) ; if ( $ changed ) { $ this -> persistenceHelper -> persistAndRecompute ( $ item , false ) ; } // TODO These tests are made in the supplier order listener and should not be done twice... $ order = $ item -> getOrder ( ) ; if ( $ this -> persistenceHelper -> isChanged ( $ order , 'state' ) ) { $ stateCs = $ this -> persistenceHelper -> getChangeSet ( $ order , 'state' ) ; // If order just did a stockable state transition if ( SupplierOrderStates :: hasChangedFromStockable ( $ stateCs ) || SupplierOrderStates :: hasChangedToStockable ( $ stateCs ) ) { // Abort (handled by the supplier order listener) return ; } } if ( SupplierOrderStates :: isStockableState ( $ order -> getState ( ) ) ) { // Updates the ordered quantity and price if ( $ this -> stockUnitLinker -> applyItem ( $ item ) ) { // Dispatch supplier order content change event $ this -> scheduleSupplierOrderContentChangeEvent ( $ item -> getOrder ( ) ) ; } } }
Update event handler.

@param ResourceEventInterface $event
@throws IllegalOperationException
Update event handler .