You are here

function acquia_connector_auto_connect in Acquia Connector 8

Same name and namespace in other branches
  1. 8.2 acquia_connector.module \acquia_connector_auto_connect()
  2. 3.x acquia_connector.module \acquia_connector_auto_connect()

Auto-connects the site to Acquia.

1 call to acquia_connector_auto_connect()
InitSubscriber::onKernelRequest in src/EventSubscriber/InitSubscriber.php
Display a message asking the user to connect to Acquia.

File

./acquia_connector.module, line 367
Acquia Connector module.

Code

function acquia_connector_auto_connect() {
  $subscription = new Subscription();
  $storage = new Storage();
  $user = \Drupal::currentUser();
  global $config;
  $auto_connector = new AutoConnector($subscription, $storage, $config);
  $connected = $auto_connector
    ->connectToAcquia();
  if ($connected && $user
    ->hasPermission('administer site configuration')) {
    $url = Url::fromRoute('acquia_connector.setup')
      ->toString();
    $text = t('Your site has been automatically connected to Acquia. <a href=":url">Change subscription</a>', [
      ':url' => $url,
    ]);
    \Drupal::messenger()
      ->addStatus($text);
  }
}