HttpClientManagerEventSubscriber.php in HTTP Client Manager 8
File
src/EventSubscriber/HttpClientManagerEventSubscriber.php
View source
<?php
namespace Drupal\http_client_manager\EventSubscriber;
use Drupal\http_client_manager\HttpClientInterface;
use Guzzle\Service\Command\OperationCommand;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Guzzle\Common\Event;
class HttpClientManagerEventSubscriber implements EventSubscriberInterface {
static function getSubscribedEvents() {
return [
'command.before_prepare' => array(
'onCommandBeforePrepare',
-9000,
),
];
}
public function onCommandBeforePrepare(Event $event) {
$command = $event['command'];
$description = $command
->getClient()
->getDescription();
$command
->set(OperationCommand::HEADERS_OPTION, [
HttpClientInterface::HEADER_API => $description
->getName(),
HttpClientInterface::HEADER_COMMAND => $command
->getName(),
]);
}
}