You are here

protected function LanguageNegotiationContentEntity::meetsContentEntityRoutesCondition in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity::meetsContentEntityRoutesCondition()

Determines if content entity route condition is met.

Requirements: currently being on an content entity route and processing outbound url pointing to the same content entity.

Parameters

\Symfony\Component\Routing\Route $outbound_route: The route object for the current outbound url being processed.

\Symfony\Component\HttpFoundation\Request $request: The HttpRequest object representing the current request.

Return value

bool TRUE if the content entity route condition is met, FALSE otherwise.

1 call to LanguageNegotiationContentEntity::meetsContentEntityRoutesCondition()
LanguageNegotiationContentEntity::processOutbound in core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php
Processes the outbound path.

File

core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php, line 222

Class

LanguageNegotiationContentEntity
Class for identifying the content translation language.

Namespace

Drupal\language\Plugin\LanguageNegotiation

Code

protected function meetsContentEntityRoutesCondition(Route $outbound_route, Request $request) {
  $outbound_path_pattern = $outbound_route
    ->getPath();
  $storage = isset($this->paths[$request]) ? $this->paths[$request] : [];
  if (!isset($storage[$outbound_path_pattern])) {
    $storage[$outbound_path_pattern] = FALSE;

    // Check if the outbound route points to the current entity.
    if ($content_entity_type_id_for_current_route = $this
      ->getContentEntityTypeIdForCurrentRequest($request)) {
      if (!empty($this
        ->getContentEntityPaths()[$outbound_path_pattern]) && $content_entity_type_id_for_current_route == $this
        ->getContentEntityPaths()[$outbound_path_pattern]) {
        $storage[$outbound_path_pattern] = TRUE;
      }
    }
    $this->paths[$request] = $storage;
  }
  return $storage[$outbound_path_pattern];
}