/**
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     // Store server information for SPI in case data is being sent from PHP CLI.
     if (PHP_SAPI == 'cli') {
         return;
     }
     // Check that there's no form submission in progress.
     if (\Drupal::request()->server->get('REQUEST_METHOD') == 'POST') {
         return;
     }
     // Check that we're not on an AJAX overlay page.
     if (\Drupal::request()->isXmlHttpRequest()) {
         return;
     }
     // Check that we're not serving a private file or image
     $controller_name = \Drupal::request()->attributes->get('_controller');
     if (strpos($controller_name, 'FileDownloadController') !== FALSE || strpos($controller_name, 'ImageStyleDownloadController') !== FALSE) {
         return;
     }
     $config = $this->configFactory->get('acquia_connector.settings');
     // Get the last time we processed data.
     $last = $this->state->get('acquia_connector.boot_last', 0);
     // 60 minute interval for storing the global variable.
     $interval = $config->get('cron_interval');
     if ($config->get('cron_interval_override')) {
         $interval = $config->get('cron_interval_override');
     }
     // Determine if the required interval has passed.
     $now = REQUEST_TIME;
     if ($now - $last > $interval * 60) {
         $platform = Controller\SpiController::getPlatform();
         // acquia_spi_data_store_set() replacement.
         $expire = REQUEST_TIME + 60 * 60 * 24;
         $this->cache->set('acquia.spi.platform', $platform, $expire);
         $this->state->set('acquia_connector.boot_last', $now);
     }
     if ($config->get('hide_signup_messages')) {
         return;
     }
     // Check that we're not on one of our own config pages, all of which are prefixed
     // with admin/config/system/acquia-connector.
     $current_path = \Drupal::Request()->attributes->get('_system_path');
     if (\Drupal::service('path.matcher')->matchPath($current_path, 'admin/config/system/acquia-connector/*')) {
         return;
     }
     // Check that the user has 'administer site configuration' permission.
     if (!\Drupal::currentUser()->hasPermission('administer site configuration')) {
         return;
     }
     // Check that there are no Acquia credentials currently set up.
     if (Subscription::hasCredentials()) {
         return;
     }
     // Display a message asking to connect to the Acquia Network.
     $text = 'Sign up for Acquia Cloud Free, a free Drupal sandbox to experiment with new features, test your code quality, and apply continuous integration best practices. Check out the <a href="@acquia-free">epic set of dev features and tools</a> that come with your free subscription.<br/>If you have an Acquia Subscription, <a href="@settings">connect now</a>. Otherwise, you can turn this message off by disabling the Acquia Connector modules.';
     if (\Drupal::request()->server->has('AH_SITE_GROUP')) {
         $text = '<a href="@settings">Connect your site to the Acquia Subscription now</a>. <a href="@more">Learn more</a>.';
     }
     $message = t($text, ['@more' => Url::fromUri('https://docs.acquia.com/network/install')->getUri(), '@acquia-free' => Url::fromUri('https://www.acquia.com/acquia-cloud-free')->getUri(), '@settings' => Url::fromRoute('acquia_connector.setup')->toString()]);
     drupal_set_message($message, 'warning', FALSE);
 }