function LanguageNegotiationContentEntity::meetsContentEntityRoutesCondition

Same name and namespace in other branches
  1. 9 core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity::meetsContentEntityRoutesCondition()
  2. 8.9.x core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity::meetsContentEntityRoutesCondition()
  3. 11.x 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 a 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 221

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 = $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];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.