aliasManager = $alias_manager; $this->cache = $cache; } /** * {@inheritdoc} */ public function setCacheKey($key) { $this->cacheKey = $key; } /** * {@inheritdoc} * * Cache an array of the system paths available on each page. We assume * that aliases will be needed for the majority of these paths during * subsequent requests, and load them in a single query during path alias * lookup. */ public function writeCache() { $path_lookups = $this->getPathLookups(); // Check if the system paths for this page were loaded from cache in this // request to avoid writing to cache on every request. if ($this->cacheNeedsWriting && !empty($path_lookups) && !empty($this->cacheKey)) { // Set the path cache to expire in 24 hours. $expire = REQUEST_TIME + (60 * 60 * 24); $this->cache->set($this->cacheKey, $path_lookups, $expire); } } /** * {@inheritdoc} */ public function getPathByAlias($alias, $langcode = NULL) { $path = $this->aliasManager->getPathByAlias($alias, $langcode); // We need to pass on the list of previously cached system paths for this // key to the alias manager for use in subsequent lookups. $cached = $this->cache->get($path); $cached_paths = array(); if ($cached) { $cached_paths = $cached->data; $this->cacheNeedsWriting = FALSE; } $this->preloadPathLookups($cached_paths); return $path; } /** * {@inheritdoc} */ public function getAliasByPath($path, $langcode = NULL) { return $this->aliasManager->getAliasByPath($path, $langcode); } /** * {@inheritdoc} */ public function getPathLookups() { return $this->aliasManager->getPathLookups(); } /** * {@inheritdoc} */ public function preloadPathLookups(array $path_list) { $this->aliasManager->preloadPathLookups($path_list); } /** * {@inheritdoc} */ public function cacheClear($source = NULL) { $this->cache->delete($this->cacheKey); $this->aliasManager->cacheClear($source); } }