You are here

class HttpClientManagerEventSubscriber in HTTP Client Manager 8

Class HttpClientManagerEventSubscriber.

@package Drupal\conftool

Hierarchy

Expanded class hierarchy of HttpClientManagerEventSubscriber

1 string reference to 'HttpClientManagerEventSubscriber'
http_client_manager.services.yml in ./http_client_manager.services.yml
http_client_manager.services.yml
1 service uses HttpClientManagerEventSubscriber
http_client_manager.event_subscriber in ./http_client_manager.services.yml
Drupal\http_client_manager\EventSubscriber\HttpClientManagerEventSubscriber

File

src/EventSubscriber/HttpClientManagerEventSubscriber.php, line 15

Namespace

Drupal\http_client_manager\EventSubscriber
View source
class HttpClientManagerEventSubscriber implements EventSubscriberInterface {

  /**
   * {@inheritdoc}
   */
  static function getSubscribedEvents() {
    return [
      'command.before_prepare' => array(
        'onCommandBeforePrepare',
        -9000,
      ),
    ];
  }

  /**
   * Command before-prepare event handler
   *
   * @param \Guzzle\Common\Event $event
   *   Event received
   */
  public function onCommandBeforePrepare(Event $event) {

    /** @var OperationCommand $command */
    $command = $event['command'];
    $description = $command
      ->getClient()
      ->getDescription();
    $command
      ->set(OperationCommand::HEADERS_OPTION, [
      HttpClientInterface::HEADER_API => $description
        ->getName(),
      HttpClientInterface::HEADER_COMMAND => $command
        ->getName(),
    ]);
  }

}

Members