public function deleteDeferred()
    {
        try {
            if ($this->getRequestMethod() !== \Request::HTTP_DELETE) {
                throw new \common_exception_NotImplemented('Only delete method is accepted to deleting delivery');
            }

            if (!$this->hasRequestParameter('uri')) {
                throw new \common_exception_MissingParameter('uri', $this->getRequestURI());
            }

            $uri = $this->getRequestParameter('uri');
            $delivery  = $this->getResource($uri);

            if (!$delivery->exists()) {
                $this->returnFailure(new \common_exception_NotFound('Delivery has not been found'));
            }

            /** @var QueueDispatcher $queueDispatcher */
            $queueDispatcher = $this->getServiceManager()->get(QueueDispatcher::SERVICE_ID);

            $task = new DeliveryDeleteTask();
            $task->setServiceLocator($this->getServiceLocator());
            $taskParameters = ['deliveryId' => $uri];

            $task = $queueDispatcher->createTask($task, $taskParameters, __('Deleting of "%s"', $delivery->getLabel()), null, true);

            $data = $this->getTaskLogReturnData(
                $task->getId(),
                DeliveryDeleteTask::class
            );
            $this->returnSuccess($data);
        } catch (\Exception $e) {
            $this->returnFailure($e);
        }
    }
public function deleteDeferred()
    {
        try {
            if ($this->getRequestMethod() !== \Request::HTTP_DELETE) {
                throw new \common_exception_NotImplemented('Only delete method is accepted to deleting delivery');
            }

            if (!$this->hasRequestParameter('uri')) {
                throw new \common_exception_MissingParameter('uri', $this->getRequestURI());
            }

            $uri = $this->getRequestParameter('uri');
            $delivery  = $this->getResource($uri);

            if (!$delivery->exists()) {
                $this->returnFailure(new \common_exception_NotFound('Delivery has not been found'));
            }

            /** @var QueueDispatcher $queueDispatcher */
            $queueDispatcher = $this->getServiceManager()->get(QueueDispatcher::SERVICE_ID);

            $task = new DeliveryDeleteTask();
            $task->setServiceLocator($this->getServiceLocator());
            $taskParameters = ['deliveryId' => $uri];

            $task = $queueDispatcher->createTask($task, $taskParameters, __('Deleting of "%s"', $delivery->getLabel()), null, true);

            $data = $this->getTaskLogReturnData(
                $task->getId(),
                DeliveryDeleteTask::class
            );
            $this->returnSuccess($data);
        } catch (\Exception $e) {
            $this->returnFailure($e);
        }
    }
public function deleteDeferred ( ) { try { if ( $ this -> getRequestMethod ( ) !== \ Request :: HTTP_DELETE ) { throw new \ common_exception_NotImplemented ( 'Only delete method is accepted to deleting delivery' ) ; } if ( ! $ this -> hasRequestParameter ( 'uri' ) ) { throw new \ common_exception_MissingParameter ( 'uri' , $ this -> getRequestURI ( ) ) ; } $ uri = $ this -> getRequestParameter ( 'uri' ) ; $ delivery = $ this -> getResource ( $ uri ) ; if ( ! $ delivery -> exists ( ) ) { $ this -> returnFailure ( new \ common_exception_NotFound ( 'Delivery has not been found' ) ) ; } /** @var QueueDispatcher $queueDispatcher */ $ queueDispatcher = $ this -> getServiceManager ( ) -> get ( QueueDispatcher :: SERVICE_ID ) ; $ task = new DeliveryDeleteTask ( ) ; $ task -> setServiceLocator ( $ this -> getServiceLocator ( ) ) ; $ taskParameters = [ 'deliveryId' => $ uri ] ; $ task = $ queueDispatcher -> createTask ( $ task , $ taskParameters , __ ( 'Deleting of "%s"' , $ delivery -> getLabel ( ) ) , null , true ) ; $ data = $ this -> getTaskLogReturnData ( $ task -> getId ( ) , DeliveryDeleteTask :: class ) ; $ this -> returnSuccess ( $ data ) ; } catch ( \ Exception $ e ) { $ this -> returnFailure ( $ e ) ; } }
Delete delivery by URI
Delete delivery by URI