function LanguageNegotiationContentEntity::getContentEntityTypeIdForCurrentRequest

Same name and namespace in other branches
  1. 8.9.x core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity::getContentEntityTypeIdForCurrentRequest()
  2. 10 core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity::getContentEntityTypeIdForCurrentRequest()
  3. 11.x core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php \Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationContentEntity::getContentEntityTypeIdForCurrentRequest()

Returns the content entity type ID from the current request for the route.

Parameters

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

Return value

string The entity type ID for the route from the request.

1 call to LanguageNegotiationContentEntity::getContentEntityTypeIdForCurrentRequest()
LanguageNegotiationContentEntity::meetsContentEntityRoutesCondition in core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php
Determines if content entity route condition is met.

File

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

Class

LanguageNegotiationContentEntity
Class for identifying the content translation language.

Namespace

Drupal\language\Plugin\LanguageNegotiation

Code

protected function getContentEntityTypeIdForCurrentRequest(Request $request) {
    $content_entity_type_id_for_current_route = '';
    if ($current_route = $request->attributes
        ->get(RouteObjectInterface::ROUTE_OBJECT)) {
        $current_route_path = $current_route->getPath();
        $content_entity_type_id_for_current_route = isset($this->getContentEntityPaths()[$current_route_path]) ? $this->getContentEntityPaths()[$current_route_path] : '';
    }
    return $content_entity_type_id_for_current_route;
}

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