protected function actionBasedOnTTL($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;
            }

            $ttl = $this->getTtlAsActive();
            if ($ttl === null) {
                $this->report->add(Report::createFailure('Execution ttl not set: '. $executionId));
                return false;
            }

            $timeUntilToLive = clone $lastInteraction;
            $timeUntilToLive = $timeUntilToLive->add(new DateInterval($ttl));

            if ((new DateTimeImmutable('now')) >= $timeUntilToLive) {
                $this->action($deliveryExecution, $executionId);
                return true;
            } else {
                $this->report->add(Report::createInfo('Execution not expired yet:'. $executionId .
                    ' Last Interaction: '.$lastInteraction->format('Y-m-d H:i:s') .
                    ' Time when will expire: '.$timeUntilToLive->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 actionBasedOnTTL($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;
            }

            $ttl = $this->getTtlAsActive();
            if ($ttl === null) {
                $this->report->add(Report::createFailure('Execution ttl not set: '. $executionId));
                return false;
            }

            $timeUntilToLive = clone $lastInteraction;
            $timeUntilToLive = $timeUntilToLive->add(new DateInterval($ttl));

            if ((new DateTimeImmutable('now')) >= $timeUntilToLive) {
                $this->action($deliveryExecution, $executionId);
                return true;
            } else {
                $this->report->add(Report::createInfo('Execution not expired yet:'. $executionId .
                    ' Last Interaction: '.$lastInteraction->format('Y-m-d H:i:s') .
                    ' Time when will expire: '.$timeUntilToLive->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 actionBasedOnTTL ( $ 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 ; } $ ttl = $ this -> getTtlAsActive ( ) ; if ( $ ttl === null ) { $ this -> report -> add ( Report :: createFailure ( 'Execution ttl not set: ' . $ executionId ) ) ; return false ; } $ timeUntilToLive = clone $ lastInteraction ; $ timeUntilToLive = $ timeUntilToLive -> add ( new DateInterval ( $ ttl ) ) ; if ( ( new DateTimeImmutable ( 'now' ) ) >= $ timeUntilToLive ) { $ this -> action ( $ deliveryExecution , $ executionId ) ; return true ; } else { $ this -> report -> add ( Report :: createInfo ( 'Execution not expired yet:' . $ executionId . ' Last Interaction: ' . $ lastInteraction -> format ( 'Y-m-d H:i:s' ) . ' Time when will expire: ' . $ timeUntilToLive -> 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 TTL matches the condition

@param $executionId
@return bool
@throws \common_exception_Error
@throws \Exception
Run an action if TTL matches the condition