You are here

class CronService in Acquia Connector 3.x

Same name and namespace in other branches
  1. 8.2 src/CronService.php \Drupal\acquia_connector\CronService
  2. 8 src/CronService.php \Drupal\acquia_connector\CronService

Runs Connector related tasks during Cron.

@package Drupal\acquia_connector

Hierarchy

Expanded class hierarchy of CronService

1 string reference to 'CronService'
acquia_connector.services.yml in ./acquia_connector.services.yml
acquia_connector.services.yml
1 service uses CronService
logger.acquia_connector in ./acquia_connector.services.yml
Drupal\acquia_connector\CronService

File

src/CronService.php, line 13

Namespace

Drupal\acquia_connector
View source
class CronService implements LoggerInterface {
  use RfcLoggerTrait;

  /**
   * {@inheritdoc}
   */
  public function log($level, $message, array $context = []) {

    // Make sure that even when cron failures prevent hook_cron() from being
    // called, we still send out a heartbeat.
    if (!empty($context['channel']) && $context['channel'] == 'cron' && $message == 'Attempting to re-run cron while it is already running.') {

      // Avoid doing this too frequently.
      $last_update_attempt = \Drupal::state()
        ->get('acquia_subscription_data.timestamp', FALSE);
      if (!$last_update_attempt || \Drupal::time()
        ->getRequestTime() - $last_update_attempt >= 60 * 60) {
        $subscription = new Subscription();
        $subscription
          ->update();
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CronService::log public function Overrides RfcLoggerTrait::log
RfcLoggerTrait::alert public function
RfcLoggerTrait::critical public function
RfcLoggerTrait::debug public function
RfcLoggerTrait::emergency public function
RfcLoggerTrait::error public function
RfcLoggerTrait::info public function
RfcLoggerTrait::notice public function
RfcLoggerTrait::warning public function