You are here

public function NspiController::detectChanges in Acquia Connector 8

Same name and namespace in other branches
  1. 8.2 tests/modules/src/Controller/NspiController.php \Drupal\acquia_connector_test\Controller\NspiController::detectChanges()
  2. 3.x tests/modules/src/Controller/NspiController.php \Drupal\acquia_connector_test\Controller\NspiController::detectChanges()

Detect potential environment changes.

Parameters

array $spi_data: SPI data array.

Return value

array|bool FALSE or changes message.

1 call to NspiController::detectChanges()
NspiController::nspiUpdate in tests/modules/src/Controller/NspiController.php
SPI API site update.

File

tests/modules/src/Controller/NspiController.php, line 194

Class

NspiController
Class NspiController.

Namespace

Drupal\acquia_connector_test\Controller

Code

public function detectChanges(array $spi_data) {
  $changes = [];
  $site_blocked = \Drupal::state()
    ->get('acqtest_site_blocked');
  if ($site_blocked) {
    $changes['changes']['blocked'] = (string) $this
      ->t('Your site has been enabled.');
  }
  else {
    if ($this
      ->checkAcquiaHostedStatusChanged($spi_data) && !is_null($this->acquiaHosted)) {
      if ($spi_data['acquia_hosted']) {
        $changes['changes']['acquia_hosted'] = (string) $this
          ->t('Your site is now Acquia hosted.');
      }
      else {
        $changes['changes']['acquia_hosted'] = (string) $this
          ->t('Your site is no longer Acquia hosted.');
      }
    }
    if ($this
      ->checkMachineNameStatusChanged($spi_data)) {
      $changes['changes']['machine_name'] = (string) $this
        ->t('Your site machine name changed from @old_machine_name to @new_machine_name.', [
        '@old_machine_name' => $this->acqtestSiteMachineName,
        '@new_machine_name' => $spi_data['machine_name'],
      ]);
    }
  }
  if (empty($changes)) {
    return FALSE;
  }
  $changes['response'] = (string) $this
    ->t('A change has been detected in your site environment. Please check the Acquia SPI status on your Status Report page for more information.');
  return $changes;
}