You are here

public function NspiController::updateNspiSite in Acquia Connector 8.2

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

Save changes to the site entity.

Parameters

array $spi_data: SPI data array.

Return value

string Message string.

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

File

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

Class

NspiController
Class NspiController.

Namespace

Drupal\acquia_connector_test\Controller

Code

public function updateNspiSite(array $spi_data) {
  $message = '';
  if ($this
    ->checkMachineNameStatusChanged($spi_data)) {
    if (!empty($this->acqtestSiteMachineName)) {
      $message = (string) $this
        ->t('Updated site machine name from @old_machine_name to @new_machine_name.', [
        '@old_machine_name' => $this->acqtestSiteMachineName,
        '@new_machine_name' => $spi_data['machine_name'],
      ]);
    }
    else {
      $message = (string) $this
        ->t('Site machine name set to to @new_machine_name.', [
        '@new_machine_name' => $spi_data['machine_name'],
      ]);
    }
    \Drupal::state()
      ->set('acqtest_site_machine_name', $spi_data['machine_name']);
    $this->acqtestSiteMachineName = $spi_data['machine_name'];
  }
  if ($this
    ->checkAcquiaHostedStatusChanged($spi_data)) {
    if (!is_null($this->acquiaHosted)) {
      $hosted_message = $spi_data['acquia_hosted'] ? (string) $this
        ->t('site is now Acquia hosted') : (string) $this
        ->t('site is no longer Acquia hosted');
      $message = (string) $this
        ->t('Updated Acquia hosted status (@hosted_message).', [
        '@hosted_message' => $hosted_message,
      ]);
    }
    $acquia_hosted = (int) filter_var($spi_data['acquia_hosted'], FILTER_VALIDATE_BOOLEAN);
    \Drupal::state()
      ->set('acqtest_site_acquia_hosted', $acquia_hosted);
    $this->acquiaHosted = $acquia_hosted;
  }
  return $message;
}