public function SpiController::spiProcessMessages in Acquia Connector 8
Same name and namespace in other branches
- 8.2 src/Controller/SpiController.php \Drupal\acquia_connector\Controller\SpiController::spiProcessMessages()
- 3.x src/Controller/SpiController.php \Drupal\acquia_connector\Controller\SpiController::spiProcessMessages()
Parses and displays messages from the NSPI response.
Parameters
array|mixed $response: Response array from NSPI.
1 call to SpiController::spiProcessMessages()
- SpiController::send in src/
Controller/ SpiController.php - Callback for sending SPI data.
File
- src/
Controller/ SpiController.php, line 1073
Class
- SpiController
- SPI Controller class.
Namespace
Drupal\acquia_connector\ControllerCode
public function spiProcessMessages($response) {
if (empty($response['body'])) {
$this
->messenger()
->addError($this
->t('Error sending SPI data. Consult the logs for more information.'));
return;
}
$message_type = 'status';
if (isset($response['body']['spi_data_received']) && $response['body']['spi_data_received'] === TRUE) {
$this
->messenger()
->addStatus($this
->t('SPI data sent.'));
}
if (!empty($response['body']['nspi_messages'])) {
$this
->messenger()
->addStatus($this
->t('Acquia Subscription returned the following messages. Further information may be in the logs.'));
foreach ($response['body']['nspi_messages'] as $nspi_message) {
if (!empty($response['body']['spi_error'])) {
$message_type = $response['body']['spi_error'];
}
$this
->messenger()
->addMessage(Html::escape($nspi_message), (string) $message_type);
}
}
if (!empty($response['body']['spi_environment_changes'])) {
$this->configFactory
->getEditable('acquia_connector.settings')
->set('spi.environment_changes', Json::decode($response['body']['spi_environment_changes']))
->save();
}
}