You are here

public function SpiController::sendFullSpi in Acquia Connector 8.2

Same name and namespace in other branches
  1. 8 src/Controller/SpiController.php \Drupal\acquia_connector\Controller\SpiController::sendFullSpi()
  2. 3.x src/Controller/SpiController.php \Drupal\acquia_connector\Controller\SpiController::sendFullSpi()

Gather full SPI data and send to Acquia.

Parameters

string $method: Optional identifier for the method initiating request. Values could be 'cron' or 'menu callback' or 'drush'.

Return value

mixed FALSE if data is not sent or environment change detected, otherwise return NSPI response array.

1 call to SpiController::sendFullSpi()
SpiController::send in src/Controller/SpiController.php
Callback for sending SPI data.

File

src/Controller/SpiController.php, line 1003

Class

SpiController
SPI Controller class.

Namespace

Drupal\acquia_connector\Controller

Code

public function sendFullSpi($method = '') {
  $spi = self::get($method);
  if ($this
    ->checkEnvironmentChange()) {
    $this
      ->getLogger('acquia spi')
      ->error('SPI data not sent, site environment change detected.');
    $this
      ->messenger()
      ->addError($this
      ->t('SPI data not sent, site environment change detected. Please <a href="@environment_change">indicate how you wish to proceed</a>.', [
      '@environment_change' => Url::fromRoute('acquia_connector.environment_change')
        ->toString(),
    ]));
    return FALSE;
  }
  $storage = new Storage();
  $response = $this->client
    ->sendNspi($storage
    ->getIdentifier(), $storage
    ->getKey(), $spi);
  if ($response === FALSE) {
    return FALSE;
  }
  $this
    ->handleServerResponse($response);
  \Drupal::state()
    ->set('acquia_connector.cron_last', \Drupal::time()
    ->getRequestTime());
  return $response;
}