public function InitSubscriber::onKernelRequest in Acquia Connector 8
Same name and namespace in other branches
- 8.2 src/EventSubscriber/InitSubscriber.php \Drupal\acquia_connector\EventSubscriber\InitSubscriber::onKernelRequest()
- 3.x src/EventSubscriber/InitSubscriber.php \Drupal\acquia_connector\EventSubscriber\InitSubscriber::onKernelRequest()
Display a message asking the user to connect to Acquia.
Parameters
\Symfony\Component\HttpKernel\Event\GetResponseEvent $event: Event.
File
- src/
EventSubscriber/ InitSubscriber.php, line 79
Class
- InitSubscriber
- Class InitSubscriber.
Namespace
Drupal\acquia_connector\EventSubscriberCode
public function onKernelRequest(GetResponseEvent $event) {
acquia_connector_auto_connect();
acquia_connector_show_free_tier_promo();
// Move site data to State API.
$site_name = $this->state
->get('spi.site_name');
$current_site_name = $this->spiController
->checkAcquiaHosted() ? getenv('AH_SITE_ENVIRONMENT') . '_' . getenv('AH_SITE_NAME') : '';
if (empty($site_name) || $site_name != $current_site_name) {
$config = $this->configFactory
->getEditable('acquia_connector.settings');
// Handle site name.
$site_name = $this->spiController
->checkAcquiaHosted() ? getenv('AH_SITE_ENVIRONMENT') . '_' . getenv('AH_SITE_NAME') : $config
->get('spi.site_name');
$site_machine_name = $this->spiController
->getAcquiaHostedMachineName() ?? $config
->get('spi.site_machine_name');
if ($site_name) {
$this->state
->set('spi.site_name', $site_name);
$config
->clear('spi.site_name')
->save();
$this->state
->set('spi.site_machine_name', $site_machine_name);
$config
->clear('spi.site_machine_name')
->save();
}
}
}