You are here

class RedirectMiddleware in Opigno dashboard 3.x

Executes redirect before the main kernel takes over the request.

Hierarchy

  • class \Drupal\opigno_dashboard\RedirectMiddleware implements \Symfony\Component\HttpKernel\HttpKernelInterface

Expanded class hierarchy of RedirectMiddleware

1 string reference to 'RedirectMiddleware'
opigno_dashboard.services.yml in ./opigno_dashboard.services.yml
opigno_dashboard.services.yml
1 service uses RedirectMiddleware
opigno_dashboard.redirect_after_login in ./opigno_dashboard.services.yml
Drupal\opigno_dashboard\RedirectMiddleware

File

src/RedirectMiddleware.php, line 15

Namespace

Drupal\opigno_dashboard
View source
class RedirectMiddleware implements HttpKernelInterface {

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

  /**
   * The redirect URL.
   *
   * @var \Symfony\Component\HttpFoundation\RedirectResponse
   */
  protected $redirectResponse;

  /**
   * Constructs a RedirectMiddleware
   * 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) {
    $response = $this->httpKernel
      ->handle($request, $type, $catch);
    return $this->redirectResponse ?: $response;
  }

  /**
   * Stores the requested redirect response.
   *
   * @param \Symfony\Component\HttpFoundation\RedirectResponse|null $redirectResponse
   *   Redirect response.
   */
  public function setRedirectResponse(?RedirectResponse $redirectResponse) {
    $this->redirectResponse = $redirectResponse;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RedirectMiddleware::$httpKernel protected property The wrapped HTTP kernel.
RedirectMiddleware::$redirectResponse protected property The redirect URL.
RedirectMiddleware::handle public function
RedirectMiddleware::setRedirectResponse public function Stores the requested redirect response.
RedirectMiddleware::__construct public function Constructs a RedirectMiddleware object.