protected function actionBasedOnEndDate(DateTimeImmutable $endDateTime, $executionId)
    {
        try {
            $deliveryExecution = $this->getServiceProxy()->getDeliveryExecution($executionId);
            $lastInteraction   = $this->getLastInteractionDateTime($deliveryExecution);

            if ($lastInteraction === null){
                $this->report->add(Report::createFailure('Execution last interaction cannot be found: '. $executionId));
                return false;
            }

            if (new DateTimeImmutable('now') >= $endDateTime) {
                $this->action($deliveryExecution, $executionId, true);
                return true;
            }

            $this->report->add(Report::createInfo('Execution not expired yet:'. $executionId .
                ' Last Interaction:'.$lastInteraction->format('Y-m-d H:i:s') .
                ' Time when will expire:'.$endDateTime->format('Y-m-d H:i:s')
            ));

        } catch (\common_exception_NotFound $e) {
            $this->report->add(Report::createFailure('Execution cannot be found: '. $executionId));
            $this->report->add(Report::createFailure($e->getMessage()));
        }

        return false;
    }
protected function actionBasedOnEndDate(DateTimeImmutable $endDateTime, $executionId)
    {
        try {
            $deliveryExecution = $this->getServiceProxy()->getDeliveryExecution($executionId);
            $lastInteraction   = $this->getLastInteractionDateTime($deliveryExecution);

            if ($lastInteraction === null){
                $this->report->add(Report::createFailure('Execution last interaction cannot be found: '. $executionId));
                return false;
            }

            if (new DateTimeImmutable('now') >= $endDateTime) {
                $this->action($deliveryExecution, $executionId, true);
                return true;
            }

            $this->report->add(Report::createInfo('Execution not expired yet:'. $executionId .
                ' Last Interaction:'.$lastInteraction->format('Y-m-d H:i:s') .
                ' Time when will expire:'.$endDateTime->format('Y-m-d H:i:s')
            ));

        } catch (\common_exception_NotFound $e) {
            $this->report->add(Report::createFailure('Execution cannot be found: '. $executionId));
            $this->report->add(Report::createFailure($e->getMessage()));
        }

        return false;
    }
protected function actionBasedOnEndDate ( DateTimeImmutable $ endDateTime , $ executionId ) { try { $ deliveryExecution = $ this -> getServiceProxy ( ) -> getDeliveryExecution ( $ executionId ) ; $ lastInteraction = $ this -> getLastInteractionDateTime ( $ deliveryExecution ) ; if ( $ lastInteraction === null ) { $ this -> report -> add ( Report :: createFailure ( 'Execution last interaction cannot be found: ' . $ executionId ) ) ; return false ; } if ( new DateTimeImmutable ( 'now' ) >= $ endDateTime ) { $ this -> action ( $ deliveryExecution , $ executionId , true ) ; return true ; } $ this -> report -> add ( Report :: createInfo ( 'Execution not expired yet:' . $ executionId . ' Last Interaction:' . $ lastInteraction -> format ( 'Y-m-d H:i:s' ) . ' Time when will expire:' . $ endDateTime -> format ( 'Y-m-d H:i:s' ) ) ) ; } catch ( \ common_exception_NotFound $ e ) { $ this -> report -> add ( Report :: createFailure ( 'Execution cannot be found: ' . $ executionId ) ) ; $ this -> report -> add ( Report :: createFailure ( $ e -> getMessage ( ) ) ) ; } return false ; }
Run an action if the end date matches the condition

@param DateTimeImmutable $endDateTime
@param $executionId
@return bool
@throws \common_exception_Error
@throws \Exception
Run an action if the end date matches the condition