You are here

acquia_lift.install in Acquia Lift Connector 8.4

File

acquia_lift.install
View source
<?php

use Drupal\acquia_lift\Service\Helper\SettingsHelper;
use Drupal\Core\Url;

/**
 * Implements hook_requirements().
 */
function acquia_lift_requirements($phase) {
  $requirements = [];
  if ($phase !== 'runtime') {
    return $requirements;
  }
  $credentialSettings = \Drupal::config('acquia_lift.settings')
    ->get('credential');
  if (!SettingsHelper::isInvalidCredential($credentialSettings)) {
    return $requirements;
  }
  $requirements['acquia_lift_credential'] = [
    'title' => t('Acquia Lift module'),
    'description' => t('Acquia Lift module has not been fully configured yet. Please configure its settings from the <a href=":url">Acquia Lift Settings page</a>.', [
      ':url' => Url::fromRoute('acquia_lift.admin_settings_form')
        ->toString(),
    ]),
    'severity' => REQUIREMENT_WARNING,
    'value' => t('Incomplete or invalid credential'),
  ];
  return $requirements;
}

/**
 * Remove deprecated configuration and update content replacement mode.
 */
function acquia_lift_update_8400() {
  $config = Drupal::configFactory()
    ->getEditable('acquia_lift.settings');

  // Remove stored values of authentication url and content origin.
  $config
    ->clear('credential.oauth_url');
  $config
    ->clear('credential.content_origin');

  // Save trusted mode for sites having the deprecated untrusted mode set.
  if ($config
    ->get('advanced.content_replacement_mode') == 'untrusted') {
    $config
      ->set('advanced.content_replacement_mode', 'trusted');
  }
  $config
    ->save();
}

Functions

Namesort descending Description
acquia_lift_requirements Implements hook_requirements().
acquia_lift_update_8400 Remove deprecated configuration and update content replacement mode.