function LanguageNegotiationUserAdmin::isAdminPath

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

Checks whether the given path is an administrative one.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request object.

Return value

bool TRUE if the path is administrative, FALSE otherwise.

1 call to LanguageNegotiationUserAdmin::isAdminPath()
LanguageNegotiationUserAdmin::getLangcode in core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUserAdmin.php
Performs language negotiation.

File

core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUserAdmin.php, line 121

Class

LanguageNegotiationUserAdmin
Identifies admin language from the user preferences.

Namespace

Drupal\user\Plugin\LanguageNegotiation

Code

protected function isAdminPath(Request $request) {
    $result = FALSE;
    if ($request && $this->adminContext) {
        // If called from an event subscriber, the request may not have the route
        // object yet (it is still being built), so use the router to look up
        // based on the path.
        $route_match = $this->stackedRouteMatch
            ->getRouteMatchFromRequest($request);
        if ($route_match && !($route_object = $route_match->getRouteObject())) {
            try {
                // Some inbound path processors make changes to the request. Make a
                // copy as we're not actually routing the request so we do not want to
                // make changes.
                $cloned_request = clone $request;
                // Process the path as an inbound path. This will remove any language
                // prefixes and other path components that inbound processing would
                // clear out, so we can attempt to load the route clearly.
                $path = $this->pathProcessorManager
                    ->processInbound(urldecode(rtrim($cloned_request->getPathInfo(), '/')), $cloned_request);
                $attributes = $this->router
                    ->match($path);
            } catch (ResourceNotFoundException $e) {
                return FALSE;
            } catch (AccessDeniedHttpException $e) {
                return FALSE;
            }
            $route_object = $attributes[RouteObjectInterface::ROUTE_OBJECT];
        }
        $result = $this->adminContext
            ->isAdminRoute($route_object);
    }
    return $result;
}

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