acquia_connector-8.x-1.22/acquia_connector.install
acquia_connector.install
<?php
/**
* @file
* Install, update, and uninstall functions for the Acquia Connector module.
*/
use Drupal\Core\Url;
/**
* Implements hook_uninstall().
*/
function acquia_connector_uninstall() {
$subscription = \Drupal::service('acquia_connector.subscription');
$settings = $subscription->getSettings();
$settings->deleteAllData();
}
/**
* Implements hook_requirements().
*/
function acquia_connector_requirements($phase) {
$requirements = [];
if ($phase !== 'runtime') {
return $requirements;
}
$subscription = \Drupal::service('acquia_connector.subscription');
$has_credentials = $subscription->hasCredentials();
// Inform users on subscription status. Either we know they are active,
// or we know they have credentials but not active (not set up yet) or
// we have credentials but an inactive subscription (either bad
// credentials or expired subscription).
if ($subscription->isActive()) {
$requirements['acquia_subscription_status'] = [
'title' => t('Acquia Subscription status'),
'severity' => REQUIREMENT_OK,
'value' => t('Active'),
'description' => t('You can <a href=":refresh-status">manually refresh the subscription status</a>.', [
':refresh-status' => Url::fromRoute('acquia_connector.refresh_status', [], ['absolute' => TRUE])
->toString(),
]),
];
}
elseif (!$has_credentials) {
$requirements['acquia_subscription_status'] = [
'title' => t('Acquia Subscription status'),
'severity' => REQUIREMENT_WARNING,
'value' => t('Unknown'),
'description' => t('You did not complete your signup to Acquia. You can provide the subscription identifier and the subscription key at the <a href=":settings">Acquia settings</a> page or try to <a href=":refresh-status">manually refresh the subscription status</a>.', [
':settings' => Url::fromRoute('acquia_connector.settings')
->toString(),
':refresh-status' => Url::fromRoute('acquia_connector.refresh_status')
->toString(),
]),
];
}
else {
// Should get cached data if it exists.
$subscription = $subscription->getSubscription();
$href = isset($subscription['uuid']) ? 'https://cloud.acquia.com/app/develop/applications/' . $subscription['uuid'] : 'https://cloud.acquia.com';
$requirements['acquia_subscription_status'] = [
'title' => t('Acquia Subscription status'),
'severity' => REQUIREMENT_WARNING,
'value' => t('Inactive'),
'description' => t('Your subscription is expired or you are using an invalid identifier and key pair. You can check the subscription identifier and the subscription key at the <a href=":settings">Acquia settings</a> page or try to <a href=":refresh-status">manually refresh the subscription status</a>. Check <a href=":acquia-network">your subscription on the Acquia Subscription</a> for further status information.', [
':settings' => Url::fromRoute('acquia_connector.settings')
->toString(),
':refresh-status' => Url::fromRoute('acquia_connector.refresh_status')
->toString(),
':acquia-network' => $href,
]),
];
}
return $requirements;
}
/**
* Implements hook_requirements_alter().
*/
function acquia_connector_requirements_alter(array &$requirements): void {
$php_severity = $requirements['php']['severity'] ?? NULL;
// Customers always use a supported version of PHP on the Acquia Platform.
if ($php_severity === REQUIREMENT_ERROR) {
$requirements['php']['severity'] = REQUIREMENT_WARNING;
$requirements['php']['description'] = t('<p>@requirement</p><p>As part of your subscription, Acquia supports older versions of PHP in an effort to provide additional
time for our customers to make the transition to a supported version. Read our <a href="https://docs.acquia.com/cloud-platform/manage/php/">PHP Documentation</a> for more information.</p>',
[
'@requirement' => $requirements['php']['description'] ?? '',
]);
}
}
