You are here

private function DomainRedirectEventSubscriber::checkPath in Domain 301 Redirect 8

Checks if the current path should be protected or not.

Return value

bool Whether to bypass the redirection or not.

1 call to DomainRedirectEventSubscriber::checkPath()
DomainRedirectEventSubscriber::requestHandler in src/EventSubscriber/DomainRedirectEventSubscriber.php
This method is called whenever the kernel.request event is dispatched.

File

src/EventSubscriber/DomainRedirectEventSubscriber.php, line 169

Class

DomainRedirectEventSubscriber
Class DomainRedirectEventSubscriber.

Namespace

Drupal\domain_301_redirect\EventSubscriber

Code

private function checkPath() {

  // Get current path but always get the alias.
  $current_path = $this->request
    ->getRequestUri();
  $path = $this->pathAliasManager
    ->getAliasByPath($current_path);
  $path_match = FALSE;
  $bypass = FALSE;
  if ($this->pathMatcher
    ->matchPath($path, $this->config
    ->get('pages'))) {
    $path_match = TRUE;
  }
  switch ($this->config
    ->get('applicability')) {
    case Domain301Redirect::EXCLUDE_METHOD:
      if ($path_match) {
        $bypass = TRUE;
      }
      break;
    case Domain301Redirect::INCLUDE_METHOD:
      if (!$path_match) {
        $bypass = TRUE;
      }
      break;
  }
  return $bypass;
}