public function generateDeferred()
    {
        try {
            if (! $this->hasRequestParameter(self::REST_DELIVERY_TEST_ID)) {
                throw new \common_exception_MissingParameter(self::REST_DELIVERY_TEST_ID, $this->getRequestURI());
            }

            $test = $this->getResource($this->getRequestParameter(self::REST_DELIVERY_TEST_ID));
            if (! $test->exists()) {
                throw new \common_exception_NotFound('Unable to find a test associated to the given uri.');
            }

            $deliveryClass = $this->getDeliveryClassByParameters();

            /** @var DeliveryFactory $deliveryFactoryService */
            $deliveryFactoryService = $this->getServiceManager()->get(DeliveryFactory::SERVICE_ID);
            $initialProperties = $deliveryFactoryService->getInitialPropertiesFromRequest($this->getRequest());

            $task = CompileDelivery::createTask($test, $deliveryClass, $initialProperties);

            $result = [
                'reference_id' => $task->getId()
            ];

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

            $report = $taskLog->getReport($task->getId());

            if (!empty($report)) {
                if ($report instanceof \common_report_Report) {
                    //serialize report to array
                    $report = json_decode($report);
                }
                $result['common_report_Report'] = $report;
            }

            return $this->returnSuccess($result);
        } catch (\Exception $e) {
            $this->returnFailure($e);
        }
    }
public function generateDeferred()
    {
        try {
            if (! $this->hasRequestParameter(self::REST_DELIVERY_TEST_ID)) {
                throw new \common_exception_MissingParameter(self::REST_DELIVERY_TEST_ID, $this->getRequestURI());
            }

            $test = $this->getResource($this->getRequestParameter(self::REST_DELIVERY_TEST_ID));
            if (! $test->exists()) {
                throw new \common_exception_NotFound('Unable to find a test associated to the given uri.');
            }

            $deliveryClass = $this->getDeliveryClassByParameters();

            /** @var DeliveryFactory $deliveryFactoryService */
            $deliveryFactoryService = $this->getServiceManager()->get(DeliveryFactory::SERVICE_ID);
            $initialProperties = $deliveryFactoryService->getInitialPropertiesFromRequest($this->getRequest());

            $task = CompileDelivery::createTask($test, $deliveryClass, $initialProperties);

            $result = [
                'reference_id' => $task->getId()
            ];

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

            $report = $taskLog->getReport($task->getId());

            if (!empty($report)) {
                if ($report instanceof \common_report_Report) {
                    //serialize report to array
                    $report = json_decode($report);
                }
                $result['common_report_Report'] = $report;
            }

            return $this->returnSuccess($result);
        } catch (\Exception $e) {
            $this->returnFailure($e);
        }
    }
public function generateDeferred ( ) { try { if ( ! $ this -> hasRequestParameter ( self :: REST_DELIVERY_TEST_ID ) ) { throw new \ common_exception_MissingParameter ( self :: REST_DELIVERY_TEST_ID , $ this -> getRequestURI ( ) ) ; } $ test = $ this -> getResource ( $ this -> getRequestParameter ( self :: REST_DELIVERY_TEST_ID ) ) ; if ( ! $ test -> exists ( ) ) { throw new \ common_exception_NotFound ( 'Unable to find a test associated to the given uri.' ) ; } $ deliveryClass = $ this -> getDeliveryClassByParameters ( ) ; /** @var DeliveryFactory $deliveryFactoryService */ $ deliveryFactoryService = $ this -> getServiceManager ( ) -> get ( DeliveryFactory :: SERVICE_ID ) ; $ initialProperties = $ deliveryFactoryService -> getInitialPropertiesFromRequest ( $ this -> getRequest ( ) ) ; $ task = CompileDelivery :: createTask ( $ test , $ deliveryClass , $ initialProperties ) ; $ result = [ 'reference_id' => $ task -> getId ( ) ] ; /** @var TaskLogInterface $taskLog */ $ taskLog = $ this -> getServiceManager ( ) -> get ( TaskLogInterface :: SERVICE_ID ) ; $ report = $ taskLog -> getReport ( $ task -> getId ( ) ) ; if ( ! empty ( $ report ) ) { if ( $ report instanceof \ common_report_Report ) { //serialize report to array $ report = json_decode ( $ report ) ; } $ result [ 'common_report_Report' ] = $ report ; } return $ this -> returnSuccess ( $ result ) ; } catch ( \ Exception $ e ) { $ this -> returnFailure ( $ e ) ; } }
Put task to generate a delivery from test uri to the task queue
Test uri has to be set and existing
Put task to generate a delivery from test uri to the task queue Test uri has to be set and existing