public function pauseActiveExecutions()
    {
        if (!$this->isRequestPost()) {
            throw new \common_exception_BadRequest('Invalid request. Only POST method allowed.');
        }

        $reason = $this->hasRequestParameter('reason') ? $this->getRequestParameter('reason') : [
            'reasons' => ['category' => 'Technical', 'subCategory' => 'ACT'],
            'comment' => __('Pause due to server maintenance'),
        ];
        /** @var DeliveryMonitoringService $monitoringService */
        $monitoringService = $this->getServiceLocator()->get(DeliveryMonitoringService::SERVICE_ID);
        $deliveryExecutions = $monitoringService->find(
            [DeliveryMonitoringService::STATUS => DeliveryExecution::STATE_ACTIVE],
            ['asArray' => true]
        );
        $ids = array_map(function ($deliveryExecution) {
            return $deliveryExecution['delivery_execution_id'];
        }, $deliveryExecutions);
        $stats = DeliveryHelper::pauseExecutions($ids, $reason);
        $paused = $stats['processed'];
        $notPaused = $stats['unprocessed'];

        $this->returnJson([
            'success' => true,
            'data' => [
                'message' => count($paused) . ' ' . __('sessions paused'),
                'processed' => $paused,
                'unprocessed' => $notPaused
            ]
        ]);
    }
public function pauseActiveExecutions()
    {
        if (!$this->isRequestPost()) {
            throw new \common_exception_BadRequest('Invalid request. Only POST method allowed.');
        }

        $reason = $this->hasRequestParameter('reason') ? $this->getRequestParameter('reason') : [
            'reasons' => ['category' => 'Technical', 'subCategory' => 'ACT'],
            'comment' => __('Pause due to server maintenance'),
        ];
        /** @var DeliveryMonitoringService $monitoringService */
        $monitoringService = $this->getServiceLocator()->get(DeliveryMonitoringService::SERVICE_ID);
        $deliveryExecutions = $monitoringService->find(
            [DeliveryMonitoringService::STATUS => DeliveryExecution::STATE_ACTIVE],
            ['asArray' => true]
        );
        $ids = array_map(function ($deliveryExecution) {
            return $deliveryExecution['delivery_execution_id'];
        }, $deliveryExecutions);
        $stats = DeliveryHelper::pauseExecutions($ids, $reason);
        $paused = $stats['processed'];
        $notPaused = $stats['unprocessed'];

        $this->returnJson([
            'success' => true,
            'data' => [
                'message' => count($paused) . ' ' . __('sessions paused'),
                'processed' => $paused,
                'unprocessed' => $notPaused
            ]
        ]);
    }
public function pauseActiveExecutions ( ) { if ( ! $ this -> isRequestPost ( ) ) { throw new \ common_exception_BadRequest ( 'Invalid request. Only POST method allowed.' ) ; } $ reason = $ this -> hasRequestParameter ( 'reason' ) ? $ this -> getRequestParameter ( 'reason' ) : [ 'reasons' => [ 'category' => 'Technical' , 'subCategory' => 'ACT' ] , 'comment' => __ ( 'Pause due to server maintenance' ) , ] ; /** @var DeliveryMonitoringService $monitoringService */ $ monitoringService = $ this -> getServiceLocator ( ) -> get ( DeliveryMonitoringService :: SERVICE_ID ) ; $ deliveryExecutions = $ monitoringService -> find ( [ DeliveryMonitoringService :: STATUS => DeliveryExecution :: STATE_ACTIVE ] , [ 'asArray' => true ] ) ; $ ids = array_map ( function ( $ deliveryExecution ) { return $ deliveryExecution [ 'delivery_execution_id' ] ; } , $ deliveryExecutions ) ; $ stats = DeliveryHelper :: pauseExecutions ( $ ids , $ reason ) ; $ paused = $ stats [ 'processed' ] ; $ notPaused = $ stats [ 'unprocessed' ] ; $ this -> returnJson ( [ 'success' => true , 'data' => [ 'message' => count ( $ paused ) . ' ' . __ ( 'sessions paused' ) , 'processed' => $ paused , 'unprocessed' => $ notPaused ] ] ) ; }
Action pauses all the active delivery executions
Action pauses all the active delivery executions