Skip to content
Snippets Groups Projects

Issue #2313309: Admin toolbar and contextual links should always be rendered in the admin language (if set)

Open Issue #2313309: Admin toolbar and contextual links should always be rendered in the admin language (if set)
Open Dieter Holvoet requested to merge issue/drupal-2313309:2313309-11.x into 11.x
Compare and
20 files
+ 467
57
Compare changes
  • Side-by-side
  • Inline
Files
20
<?php
namespace Drupal\Core\Cache\Context;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Session\AccountProxyInterface;
/**
* Defines an AdminLanguageCacheContext service, for "admin language" caching.
*
* Cache context ID: 'user.admin_language'.
*/
class AccountAdminLanguageCacheContext implements CacheContextInterface {
/**
* Constructs a new AccountAdminLanguageCacheContext service.
*
* @param \Drupal\Core\Session\AccountProxyInterface $currentUser
* The current user.
*/
public function __construct(protected AccountProxyInterface $currentUser) {}
/**
* {@inheritdoc}
*/
public static function getLabel(): string {
return t("Account's administration language");
}
/**
* {@inheritdoc}
*/
public function getContext(): string {
return $this->currentUser->getPreferredAdminLangcode();
}
/**
* {@inheritdoc}
*/
public function getCacheableMetadata(): CacheableMetadata {
return new CacheableMetadata();
}
}
Loading