/** * Constructs a LocaleLookup object. * * @param string $langcode * The language code. * @param string $context * The string context. * @param \Drupal\locale\StringStorageInterface $string_storage * The string storage. * @param \Drupal\Core\Cache\CacheBackendInterface $cache * The cache backend. * @param \Drupal\Core\Lock\LockBackendInterface $lock * The lock backend. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. */ public function __construct($langcode, $context, StringStorageInterface $string_storage, CacheBackendInterface $cache, LockBackendInterface $lock, ConfigFactoryInterface $config_factory, LanguageManagerInterface $language_manager) { $this->langcode = $langcode; $this->context = (string) $context; $this->stringStorage = $string_storage; $this->configFactory = $config_factory; $this->languageManager = $language_manager; // Add the current user's role IDs to the cache key, this ensures that, for // example, strings for admin menu items and settings forms are not cached // for anonymous users. $user = \Drupal::currentUser(); $rids = $user ? implode(':', array_keys($user->getRoles())) : '0'; parent::__construct("locale:{$langcode}:{$context}:{$rids}", $cache, $lock, array('locale' => TRUE)); }
/** * Constructs a \Drupal\Core\Menu\MenuActiveTrail object. * * @param \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager * The menu link plugin manager. * @param \Drupal\Core\Routing\RouteMatchInterface $route_match * A route match object for finding the active link. * @param \Drupal\Core\Cache\CacheBackendInterface $cache * The cache backend. * @param \Drupal\Core\Lock\LockBackendInterface $lock * The lock backend. */ public function __construct(MenuLinkManagerInterface $menu_link_manager, RouteMatchInterface $route_match, CacheBackendInterface $cache, LockBackendInterface $lock) { parent::__construct(NULL, $cache, $lock); $this->menuLinkManager = $menu_link_manager; $this->routeMatch = $route_match; }
/** * Constructs a CacheCollector object. * * @param string $cid * The cid for the array being cached. * @param \Drupal\Core\Cache\CacheBackendInterface $cache * The cache backend. * @param \Drupal\Core\Lock\LockBackendInterface $lock * The lock backend. * @param \Drupal\Core\Asset\LibraryDiscoveryParser $discovery_parser * The library discovery parser. */ public function __construct(CacheBackendInterface $cache, LockBackendInterface $lock, LibraryDiscoveryParser $discovery_parser, ThemeManagerInterface $theme_manager) { $this->themeManager = $theme_manager; parent::__construct(NULL, $cache, $lock, ['library_info']); $this->discoveryParser = $discovery_parser; }
/** * {@inheritdoc} */ public function clear() { parent::clear(); $this->loadMenuPathRoots(); }
/** * {@inheritdoc} */ public function reset() { parent::reset(); $this->cid = NULL; }
/** * {@inheritdoc} */ public function set($key, $value) { parent::set($key, $value); $this->persist($key); }
/** * Constructs a CacheCollector object. * * @param string $cid * The cid for the array being cached. * @param \Drupal\Core\Cache\CacheBackendInterface $cache * The cache backend. * @param \Drupal\Core\Lock\LockBackendInterface $lock * The lock backend. * @param \Drupal\Core\Asset\LibraryDiscoveryParser $discovery_parser * The library discovery parser. */ public function __construct(CacheBackendInterface $cache, LockBackendInterface $lock, LibraryDiscoveryParser $discovery_parser) { parent::__construct($this->cacheKey, $cache, $lock, array($this->cacheKey => array(TRUE))); $this->discoveryParser = $discovery_parser; }