/**
  * Access callback for sendModuleData() callback.
  */
 public function access()
 {
     $request = \Drupal::request();
     $data = json_decode($request->getContent(), TRUE);
     // We only do this if we are on SSL
     $via_ssl = $request->isSecure();
     if ($this->config('acquia_connector.settings')->get('spi.ssl_override')) {
         $via_ssl = TRUE;
     }
     if ($this->config('acquia_connector.settings')->get('spi.module_diff_data') && $via_ssl) {
         if (Subscription::hasCredentials() && isset($data['body']['file']) && $this->isValidRequest($data, $data['body']['file'])) {
             return AccessResultAllowed::allowed();
         }
         // Log the request if validation failed and debug is enabled.
         if ($this->config('acquia_connector.settings')->get('debug')) {
             $info = array('data' => $data, 'get' => $request->query->all(), 'server' => $request->server->all(), 'request' => $request->request->all());
             \Drupal::logger('acquia module data')->notice('Site Module Data request: @data', array('@data' => var_export($info, TRUE)));
         }
     }
     return AccessResultForbidden::forbidden();
 }
 /**
  * @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);
 }