You are here

BatApiMiddleware.php in Booking and Availability Management API 8

File

src/StackMiddleware/BatApiMiddleware.php
View source
<?php

/**
 * @file
 * Contains \Drupal\bat_api\StackMiddleware\BatApiMiddleware.php
 */
namespace Drupal\bat_api\StackMiddleware;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;

/**
 * Provides a HTTP middleware.
 */
class BatApiMiddleware implements HttpKernelInterface {

  /**
   * The wrapped HTTP kernel.
   *
   * @var \Symfony\Component\HttpKernel\HttpKernelInterface
   */
  protected $httpKernel;

  /**
   * Constructs a BatApiMiddleware object.
   *
   * @param \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel
   *   The decorated kernel.
   */
  public function __construct(HttpKernelInterface $http_kernel) {
    $this->httpKernel = $http_kernel;
  }

  /**
   * {@inheritdoc}
   */
  public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
    if ($format = $request
      ->get('_format')) {
      $request
        ->setRequestFormat($format);
    }
    return $this->httpKernel
      ->handle($request, $type, $catch);
  }

}

Classes

Namesort descending Description
BatApiMiddleware Provides a HTTP middleware.