function acquia_connector_show_free_tier_promo in Acquia Connector 8.2
Same name and namespace in other branches
- 8 acquia_connector.module \acquia_connector_show_free_tier_promo()
- 3.x acquia_connector.module \acquia_connector_show_free_tier_promo()
Displays promo DSM for Acquia Cloud Free offering.
1 call to acquia_connector_show_free_tier_promo()
- InitSubscriber::onKernelRequest in src/
EventSubscriber/ InitSubscriber.php - Display a message asking the user to connect to Acquia.
File
- ./
acquia_connector.module, line 290 - Acquia Connector module.
Code
function acquia_connector_show_free_tier_promo() {
$subscription = new Subscription();
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 request.
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;
}
$ac_config = \Drupal::configFactory()
->get('acquia_connector.settings');
if ($ac_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 the promo message.
$message = t('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.', [
'@acquia-free' => Url::fromUri('https://www.acquia.com/acquia-cloud-free')
->getUri(),
'@settings' => Url::fromRoute('acquia_connector.setup')
->toString(),
]);
\Drupal::messenger()
->addWarning($message);
}