SubscriptionManagerFormTrait.php in Acquia Content Hub 8.2
File
modules/acquia_contenthub_publisher/src/Form/SubscriptionManagerFormTrait.php
View source
<?php
namespace Drupal\acquia_contenthub_publisher\Form;
use Drupal\Core\Messenger\MessengerInterface;
use Psr\Http\Message\ResponseInterface;
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
trait SubscriptionManagerFormTrait {
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;
}
}