public function removeConsignment(ConsignmentInterface $consignment)
    {
        $adapter = $this->getAdapter($consignment);
        $event = new EventConsignment($consignment);
        $this->eventDispatcher->dispatch(Events::PRE_CONSIGNMENT_REMOVE, $event);

        if ($consignment->getStatus() != ConsignmentStatusList::STATUS_NEW) {
            throw new OperationNotPermittedException(
                sprintf(
                    'Can not remove Consignment "%s" with status "%s"',
                    $consignment->getId(),
                    $consignment->getStatus()
                )
            );
        }

        try {
            $adapter->removeConsignment($consignment);
            $this->consignmentRepository->removeConsignment($consignment);
        } catch (\Exception $e) {
            throw new VendorAdapterException('Error during consignment removing.', null, $e);
        }

        $event = new EventConsignment($consignment);
        $this->eventDispatcher->dispatch(Events::POST_CONSIGNMENT_REMOVE, $event);
    }
public function removeConsignment(ConsignmentInterface $consignment)
    {
        $adapter = $this->getAdapter($consignment);
        $event = new EventConsignment($consignment);
        $this->eventDispatcher->dispatch(Events::PRE_CONSIGNMENT_REMOVE, $event);

        if ($consignment->getStatus() != ConsignmentStatusList::STATUS_NEW) {
            throw new OperationNotPermittedException(
                sprintf(
                    'Can not remove Consignment "%s" with status "%s"',
                    $consignment->getId(),
                    $consignment->getStatus()
                )
            );
        }

        try {
            $adapter->removeConsignment($consignment);
            $this->consignmentRepository->removeConsignment($consignment);
        } catch (\Exception $e) {
            throw new VendorAdapterException('Error during consignment removing.', null, $e);
        }

        $event = new EventConsignment($consignment);
        $this->eventDispatcher->dispatch(Events::POST_CONSIGNMENT_REMOVE, $event);
    }
public function removeConsignment ( ConsignmentInterface $ consignment ) { $ adapter = $ this -> getAdapter ( $ consignment ) ; $ event = new EventConsignment ( $ consignment ) ; $ this -> eventDispatcher -> dispatch ( Events :: PRE_CONSIGNMENT_REMOVE , $ event ) ; if ( $ consignment -> getStatus ( ) != ConsignmentStatusList :: STATUS_NEW ) { throw new OperationNotPermittedException ( sprintf ( 'Can not remove Consignment "%s" with status "%s"' , $ consignment -> getId ( ) , $ consignment -> getStatus ( ) ) ) ; } try { $ adapter -> removeConsignment ( $ consignment ) ; $ this -> consignmentRepository -> removeConsignment ( $ consignment ) ; } catch ( \ Exception $ e ) { throw new VendorAdapterException ( 'Error during consignment removing.' , null , $ e ) ; } $ event = new EventConsignment ( $ consignment ) ; $ this -> eventDispatcher -> dispatch ( Events :: POST_CONSIGNMENT_REMOVE , $ event ) ; }
Remove given consignment. Allowed only in "new" status
@param ConsignmentInterface $consignment
@throws \Exception
Remove given consignment . Allowed only in new status