You are here

protected function SubscriptionManagerFormTrait::isResponseSuccessful in Acquia Content Hub 8.2

Returns the success status of the response.

Parameters

\Psr\Http\Message\ResponseInterface $response: The response object.

string $operation_label: The label of an operation.

string $item_label: The label of an item/entity.

string $uuid: The uuid of the entity.

\Drupal\Core\Messenger\MessengerInterface $messenger: The messenger.

Return value

bool Whether the response is successful or is not.

4 calls to SubscriptionManagerFormTrait::isResponseSuccessful()
ClientEditForm::submitForm in modules/acquia_contenthub_publisher/src/Form/Client/ClientEditForm.php
WebhookDeleteConfirmForm::deleteFilters in modules/acquia_contenthub_publisher/src/Form/Webhook/WebhookDeleteConfirmForm.php
Delete orphaned and default filters from event.
WebhookDeleteConfirmForm::deleteWebhook in modules/acquia_contenthub_publisher/src/Form/Webhook/WebhookDeleteConfirmForm.php
Delete webhook.
WebhookEditForm::submitForm in modules/acquia_contenthub_publisher/src/Form/Webhook/WebhookEditForm.php

File

modules/acquia_contenthub_publisher/src/Form/SubscriptionManagerFormTrait.php, line 31

Class

SubscriptionManagerFormTrait
Trait for consistency in subscription manager form.

Namespace

Drupal\acquia_contenthub_publisher\Form

Code

protected function isResponseSuccessful(ResponseInterface $response, $operation_label, $item_label, $uuid, MessengerInterface $messenger) {
  if ((new HttpFoundationFactory())
    ->createResponse($response)
    ->isSuccessful()) {
    return TRUE;
  }
  $messenger
    ->addError($this
    ->t('Unable to %operation %item %uuid. Status code: %status_code. Message: %message', [
    '%operation' => $operation_label,
    '%item' => $item_label,
    '%uuid' => $uuid,
    '%status_code' => $response
      ->getStatusCode(),
    '%message' => $response
      ->getReasonPhrase(),
  ]));
  return FALSE;
}