/**
  * {@inheritdoc}
  */
 public function matches(Request $request)
 {
     $path = $request->getPathInfo();
     $patterns = $this->configFactory->get('xhprof.config')->get('exclude');
     // never collect phpinfo page.
     $patterns .= "\r\n/admin/reports/status/php";
     return !$this->pathMatcher->matchPath($path, $patterns);
 }
 /**
  * {@inheritdoc}
  */
 public function matches(Request $request)
 {
     $path = $request->getPathInfo();
     $patterns = $this->configFactory->get('webprofiler.config')->get('exclude');
     // never add Webprofiler to phpinfo page.
     $patterns .= "\r\n/admin/reports/status/php";
     // never add Webprofiler to uninstall confirm page.
     $patterns .= "\r\n/admin/modules/uninstall/*";
     return !$this->pathMatcher->matchPath($path, $patterns);
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function build()
 {
     $build = array();
     $route_name = $this->pathMatcher->isFrontPage() ? '<front>' : '<current>';
     $type = $this->getDerivativeId();
     $links = $this->languageManager->getLanguageSwitchLinks($type, Url::fromRoute($route_name));
     if (isset($links->links)) {
         $build = array('#theme' => 'links__language_block', '#links' => $links->links, '#attributes' => array('class' => array("language-switcher-{$links->method_id}")), '#set_active_class' => TRUE);
     }
     return $build;
 }
 /**
  * Sets the 'is-active' class on links.
  *
  * @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event
  *   The response event.
  */
 public function onResponse(FilterResponseEvent $event)
 {
     // Only care about HTML responses.
     if (stripos($event->getResponse()->headers->get('Content-Type'), 'text/html') === FALSE) {
         return;
     }
     // For authenticated users, the 'is-active' class is set in JavaScript.
     // @see system_page_attachments()
     if ($this->currentUser->isAuthenticated()) {
         return;
     }
     $response = $event->getResponse();
     $response->setContent(static::setLinkActiveClass($response->getContent(), ltrim($this->currentPath->getPath(), '/'), $this->pathMatcher->isFrontPage(), $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId(), $event->getRequest()->query->all()));
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 public function evaluate()
 {
     // Convert path to lowercase. This allows comparison of the same path
     // with different case. Ex: /Page, /page, /PAGE.
     $pages = Unicode::strtolower($this->configuration['pages']);
     if (!$pages) {
         return TRUE;
     }
     $request = $this->requestStack->getCurrentRequest();
     // Compare the lowercase path alias (if any) and internal path.
     $path = rtrim($this->currentPath->getPath($request), '/');
     $path_alias = Unicode::strtolower($this->aliasManager->getAliasByPath($path));
     return $this->pathMatcher->matchPath($path_alias, $pages) || $path != $path_alias && $this->pathMatcher->matchPath($path, $pages);
 }
 /**
  * {@inheritdoc}
  */
 public function evaluate()
 {
     // Convert path to lowercase. This allows comparison of the same path
     // with different case. Ex: /Page, /page, /PAGE.
     $pages = Unicode::strtolower($this->configuration['pages']);
     if (!$pages) {
         return TRUE;
     }
     $request = $this->requestStack->getCurrentRequest();
     // Compare the lowercase path alias (if any) and internal path.
     // @todo Remove dependency on the internal _system_path attribute:
     //   https://www.drupal.org/node/2293581.
     $path = $request->attributes->get('_system_path');
     $path_alias = Unicode::strtolower($this->aliasManager->getAliasByPath($path));
     return $this->pathMatcher->matchPath($path_alias, $pages) || $path != $path_alias && $this->pathMatcher->matchPath($path, $pages);
 }
Example #7
0
 /**
  * Checks whether a give path matches the ng-lightbox path rules.
  * This function checks both internal paths and aliased paths.
  *
  * @param \Drupal\Core\Url $url
  *   The Url object.
  *
  * @return bool
  *   TRUE if it matches the given rules.
  */
 public function isNgLightboxEnabledPath(Url $url)
 {
     // No lightbox on external Urls.
     if ($url->isExternal()) {
         return FALSE;
     }
     // If we don't want to enable the Lightbox on admin pages.
     if ($this->config->get('skip_admin_paths') && $this->adminContext->isAdminRoute()) {
         return FALSE;
     }
     // @TODO, decide whether we want to try and support paths or to adopt routes
     // like core is trying to force us into.
     $path = strtolower($url->toString());
     // We filter out empty paths because some modules (such as Media) use
     // theme_link() to generate links with empty paths.
     if (empty($path)) {
         return FALSE;
     }
     // Remove the base path.
     if ($base_path = \Drupal::request()->getBasePath()) {
         $path = substr($path, strlen($base_path));
     }
     // Check the cache, see if we've handled this before.
     if (isset($this->matches[$path])) {
         return $this->matches[$path];
     }
     // Normalise the patterns as well so they match the normalised paths.
     $patterns = strtolower($this->config->get('patterns'));
     // Check for internal paths first which is much quicker than the alias lookup.
     if ($this->pathMatcher->matchPath($path, $patterns)) {
         $this->matches[$path] = TRUE;
     } else {
         // Now check for aliases paths.
         $aliased_path = strtolower($this->aliasManager->getAliasByPath($path));
         if ($path != $aliased_path && $this->pathMatcher->matchPath($aliased_path, $patterns)) {
             $this->matches[$path] = TRUE;
         } else {
             // No match.
             $this->matches[$path] = FALSE;
         }
     }
     return $this->matches[$path];
 }