src/Manager/ConsignmentManager.php
public function cancelConsignment(ConsignmentInterface $consignment)
    {
        $adapter = $this->getAdapter($consignment);
        $event = new EventConsignment($consignment);
        $this->eventDispatcher->dispatch(Events::PRE_CONSIGNMENT_CANCEL, $event);

        try {
            $adapter->cancelConsignment($consignment);
            /** @var ParcelInterface $parcel */
            foreach ($consignment->getParcels() as $parcel) {
                $parcel->setStatus(ConsignmentStatusList::STATUS_CANCELED);
            }
            $consignment->setStatus(ConsignmentStatusList::STATUS_CANCELED);
            $this->consignmentRepository->saveConsignment($consignment);
        } catch (\Exception $e) {
            throw new VendorAdapterException('Error during consignment cancel.', null, $e);
        }

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

        try {
            $adapter->cancelConsignment($consignment);
            /** @var ParcelInterface $parcel */
            foreach ($consignment->getParcels() as $parcel) {
                $parcel->setStatus(ConsignmentStatusList::STATUS_CANCELED);
            }
            $consignment->setStatus(ConsignmentStatusList::STATUS_CANCELED);
            $this->consignmentRepository->saveConsignment($consignment);
        } catch (\Exception $e) {
            throw new VendorAdapterException('Error during consignment cancel.', null, $e);
        }

        $event = new EventConsignment($consignment);
        $this->eventDispatcher->dispatch(Events::POST_CONSIGNMENT_CANCEL, $event);
    }
Cancel given consignment. Allowed only in status different than "new".
@param ConsignmentInterface $consignment
@throws \Exception