You are here

protected function ThunderArticleBreadcrumbBuilder::getRequestForPath in Thunder 8.2

Same name and namespace in other branches
  1. 8.5 modules/thunder_article/src/Breadcrumb/ThunderArticleBreadcrumbBuilder.php \Drupal\thunder_article\Breadcrumb\ThunderArticleBreadcrumbBuilder::getRequestForPath()
  2. 8.3 modules/thunder_article/src/Breadcrumb/ThunderArticleBreadcrumbBuilder.php \Drupal\thunder_article\Breadcrumb\ThunderArticleBreadcrumbBuilder::getRequestForPath()
  3. 8.4 modules/thunder_article/src/Breadcrumb/ThunderArticleBreadcrumbBuilder.php \Drupal\thunder_article\Breadcrumb\ThunderArticleBreadcrumbBuilder::getRequestForPath()
  4. 6.0.x modules/thunder_article/src/Breadcrumb/ThunderArticleBreadcrumbBuilder.php \Drupal\thunder_article\Breadcrumb\ThunderArticleBreadcrumbBuilder::getRequestForPath()

Matches a path in the router.


string $path: The request path with a leading slash.

array $exclude: An array of paths or system paths to skip.

Return value

\Symfony\Component\HttpFoundation\Request A populated request object or NULL if the path couldn't be matched.


modules/thunder_article/src/Breadcrumb/ThunderArticleBreadcrumbBuilder.php, line 164


Class to define the menu_link breadcrumb builder.




protected function getRequestForPath($path, array $exclude) {
  if (!empty($exclude[$path])) {
    return NULL;

  // @todo Use the RequestHelper once is
  //   fixed.
  $request = Request::create($path);

  // Performance optimization: set a short accept header to reduce overhead in
  // AcceptHeaderMatcher when matching the request.
    ->set('Accept', 'text/html');

  // Find the system path by resolving aliases, language prefix, etc.
  $processed = $this->pathProcessor
    ->processInbound($path, $request);
  if (empty($processed) || !empty($exclude[$processed])) {

    // This resolves to the front page, which we already add.
    return NULL;
    ->setPath($processed, $request);

  // Attempt to match this path to provide a fully built request.
  try {
    return $request;
  } catch (ParamNotConvertedException $e) {
    return NULL;
  } catch (ResourceNotFoundException $e) {
    return NULL;
  } catch (MethodNotAllowedException $e) {
    return NULL;
  } catch (AccessDeniedHttpException $e) {
    return NULL;