class LanguageNegotiationUserAdmin extends LanguageNegotiationMethodBase implements ContainerFactoryPluginInterface (View source)

Identifies admin language from the user preferences.

Constants

METHOD_ID

The language negotiation method id.

Properties

protected LanguageManagerInterface $languageManager

The language manager.

from  LanguageNegotiationMethodBase
protected ConfigFactoryInterface $config

The configuration factory.

from  LanguageNegotiationMethodBase
protected AccountInterface $currentUser

The current active user.

from  LanguageNegotiationMethodBase
protected AdminContext $adminContext

The admin context.

protected UrlMatcherInterface $router

The router.

protected PathProcessorManager $pathProcessorManager

The path processor manager.

protected StackedRouteMatchInterface $stackedRouteMatch

The stacked route match.

Methods

setLanguageManager(ConfigurableLanguageManagerInterface $language_manager)

Injects the language manager.

setConfig(ConfigFactoryInterface $config)

Injects the configuration factory.

setCurrentUser(AccountInterface $current_user)

Injects the current user.

persist(LanguageInterface $language)

Notifies the plugin that the language code it returned has been accepted.

__construct(AdminContext $admin_context, UrlMatcherInterface $router, PathProcessorManager $path_processor_manager, StackedRouteMatchInterface $stacked_route_match)

Constructs a new LanguageNegotiationUserAdmin instance.

create(ContainerInterface $container, array $configuration, string $plugin_id, mixed $plugin_definition)

Creates an instance of the plugin.

string
getLangcode(Request $request = NULL)

Performs language negotiation.

bool
isAdminPath(Request $request)

Checks whether the given path is an administrative one.

Details

setLanguageManager(ConfigurableLanguageManagerInterface $language_manager)

Injects the language manager.

Parameters

ConfigurableLanguageManagerInterface $language_manager

The language manager to be used to retrieve the language list and the already negotiated languages.

setConfig(ConfigFactoryInterface $config)

Injects the configuration factory.

Parameters

ConfigFactoryInterface $config

The configuration factory.

setCurrentUser(AccountInterface $current_user)

Injects the current user.

Parameters

AccountInterface $current_user

The current active user.

persist(LanguageInterface $language)

Notifies the plugin that the language code it returned has been accepted.

Parameters

LanguageInterface $language

The accepted language.

__construct(AdminContext $admin_context, UrlMatcherInterface $router, PathProcessorManager $path_processor_manager, StackedRouteMatchInterface $stacked_route_match)

Constructs a new LanguageNegotiationUserAdmin instance.

Parameters

AdminContext $admin_context

The admin context.

UrlMatcherInterface $router

The router.

PathProcessorManager $path_processor_manager

The path processor manager.

StackedRouteMatchInterface $stacked_route_match

The stacked route match.

static ContainerFactoryPluginInterface create(ContainerInterface $container, array $configuration, string $plugin_id, mixed $plugin_definition)

Creates an instance of the plugin.

Parameters

ContainerInterface $container

The container to pull out services used in the plugin.

array $configuration

A configuration array containing information about the plugin instance.

string $plugin_id

The plugin ID for the plugin instance.

mixed $plugin_definition

The plugin implementation definition.

Return Value

ContainerFactoryPluginInterface

Returns an instance of this plugin.

string getLangcode(Request $request = NULL)

Performs language negotiation.

Parameters

Request $request

(optional) The current request. Defaults to NULL if it has not been initialized yet.

Return Value

string

A valid language code or FALSE if the negotiation was unsuccessful.

protected bool isAdminPath(Request $request)

Checks whether the given path is an administrative one.

Parameters

Request $request

The request object.

Return Value

bool

TRUE if the path is administrative, FALSE otherwise.