Commit 1299c3af authored by alexpott's avatar alexpott

Issue #2233619 by slashrsm, Jalandhar: Merge lookup functions in AliasManager.

parent 85c8f324
...@@ -1058,7 +1058,7 @@ function l($text, $path, array $options = array()) { ...@@ -1058,7 +1058,7 @@ function l($text, $path, array $options = array()) {
// Add a "data-drupal-link-system-path" attribute to let the // Add a "data-drupal-link-system-path" attribute to let the
// drupal.active-link library know the path in a standardized manner. // drupal.active-link library know the path in a standardized manner.
if (!isset($variables['options']['attributes']['data-drupal-link-system-path'])) { if (!isset($variables['options']['attributes']['data-drupal-link-system-path'])) {
$variables['options']['attributes']['data-drupal-link-system-path'] = \Drupal::service('path.alias_manager.cached')->getSystemPath($path); $variables['options']['attributes']['data-drupal-link-system-path'] = \Drupal::service('path.alias_manager.cached')->getPathByAlias($path);
} }
} }
......
...@@ -1230,7 +1230,7 @@ function template_preprocess_links(&$variables) { ...@@ -1230,7 +1230,7 @@ function template_preprocess_links(&$variables) {
// Add a "data-drupal-link-system-path" attribute to let the // Add a "data-drupal-link-system-path" attribute to let the
// drupal.active-link library know the path in a standardized manner. // drupal.active-link library know the path in a standardized manner.
$li_attributes['data-drupal-link-system-path'] = \Drupal::service('path.alias_manager.cached')->getSystemPath($path); $li_attributes['data-drupal-link-system-path'] = \Drupal::service('path.alias_manager.cached')->getPathByAlias($path);
} }
$item['link'] = $link_element; $item['link'] = $link_element;
......
...@@ -83,25 +83,25 @@ public function writeCache() { ...@@ -83,25 +83,25 @@ public function writeCache() {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getSystemPath($path, $path_language = NULL) { public function getPathByAlias($alias, $langcode = NULL) {
$system_path = $this->aliasManager->getSystemPath($path, $path_language); $path = $this->aliasManager->getPathByAlias($alias, $langcode);
// We need to pass on the list of previously cached system paths for this // We need to pass on the list of previously cached system paths for this
// key to the alias manager for use in subsequent lookups. // key to the alias manager for use in subsequent lookups.
$cached = $this->cache->get($system_path); $cached = $this->cache->get($path);
$cached_paths = array(); $cached_paths = array();
if ($cached) { if ($cached) {
$cached_paths = $cached->data; $cached_paths = $cached->data;
$this->cacheNeedsWriting = FALSE; $this->cacheNeedsWriting = FALSE;
} }
$this->preloadPathLookups($cached_paths); $this->preloadPathLookups($cached_paths);
return $system_path; return $path;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getPathAlias($path, $path_language = NULL) { public function getAliasByPath($path, $langcode = NULL) {
return $this->aliasManager->getPathAlias($path, $path_language); return $this->aliasManager->getAliasByPath($path, $langcode);
} }
/** /**
......
...@@ -141,7 +141,7 @@ public function on403Html(FlattenException $exception, Request $request) { ...@@ -141,7 +141,7 @@ public function on403Html(FlattenException $exception, Request $request) {
watchdog('access denied', $system_path, NULL, WATCHDOG_WARNING); watchdog('access denied', $system_path, NULL, WATCHDOG_WARNING);
$system_config = $this->container->get('config.factory')->get('system.site'); $system_config = $this->container->get('config.factory')->get('system.site');
$path = $this->container->get('path.alias_manager')->getSystemPath($system_config->get('page.403')); $path = $this->container->get('path.alias_manager')->getPathByAlias($system_config->get('page.403'));
if ($path && $path != $system_path) { if ($path && $path != $system_path) {
if ($request->getMethod() === 'POST') { if ($request->getMethod() === 'POST') {
$subrequest = Request::create($request->getBaseUrl() . '/' . $path, 'POST', array('destination' => $system_path, '_exception_statuscode' => 403) + $request->request->all(), $request->cookies->all(), array(), $request->server->all()); $subrequest = Request::create($request->getBaseUrl() . '/' . $path, 'POST', array('destination' => $system_path, '_exception_statuscode' => 403) + $request->request->all(), $request->cookies->all(), array(), $request->server->all());
...@@ -197,7 +197,7 @@ public function on404Html(FlattenException $exception, Request $request) { ...@@ -197,7 +197,7 @@ public function on404Html(FlattenException $exception, Request $request) {
$system_path = $request->attributes->get('_system_path'); $system_path = $request->attributes->get('_system_path');
$path = $this->container->get('path.alias_manager')->getSystemPath(\Drupal::config('system.site')->get('page.404')); $path = $this->container->get('path.alias_manager')->getPathByAlias(\Drupal::config('system.site')->get('page.404'));
if ($path && $path != $system_path) { if ($path && $path != $system_path) {
// @todo Um, how do I specify an override URL again? Totally not clear. Do // @todo Um, how do I specify an override URL again? Totally not clear. Do
// that and sub-call the kernel rather than using meah(). // that and sub-call the kernel rather than using meah().
......
...@@ -34,11 +34,11 @@ class AliasManager implements AliasManagerInterface { ...@@ -34,11 +34,11 @@ class AliasManager implements AliasManagerInterface {
protected $lookupMap = array(); protected $lookupMap = array();
/** /**
* Holds an array of path alias for which no source was found. * Holds an array of aliases for which no path was found.
* *
* @var array * @var array
*/ */
protected $noSource = array(); protected $noPath = array();
/** /**
* Holds the array of whitelisted path aliases. * Holds the array of whitelisted path aliases.
...@@ -48,18 +48,18 @@ class AliasManager implements AliasManagerInterface { ...@@ -48,18 +48,18 @@ class AliasManager implements AliasManagerInterface {
protected $whitelist; protected $whitelist;
/** /**
* Holds an array of system paths that have no aliases. * Holds an array of paths that have no alias.
* *
* @var array * @var array
*/ */
protected $noAliases = array(); protected $noAlias = array();
/** /**
* Whether lookupPath() has not yet been called. * Whether preloaded path lookups has already been loaded.
* *
* @var boolean * @var array
*/ */
protected $firstLookup = TRUE; protected $langcodePreloaded = array();
/** /**
* Holds an array of previously looked up paths for the current request path. * Holds an array of previously looked up paths for the current request path.
...@@ -88,36 +88,87 @@ public function __construct(AliasStorageInterface $storage, AliasWhitelistInterf ...@@ -88,36 +88,87 @@ public function __construct(AliasStorageInterface $storage, AliasWhitelistInterf
} }
/** /**
* Implements \Drupal\Core\Path\AliasManagerInterface::getSystemPath(). * {@inheritdoc}
*/ */
public function getSystemPath($path, $path_language = NULL) { public function getPathByAlias($alias, $langcode = NULL) {
// If no language is explicitly specified we default to the current URL // If no language is explicitly specified we default to the current URL
// language. If we used a language different from the one conveyed by the // language. If we used a language different from the one conveyed by the
// requested URL, we might end up being unable to check if there is a path // requested URL, we might end up being unable to check if there is a path
// alias matching the URL path. // alias matching the URL path.
$path_language = $path_language ?: $this->languageManager->getCurrentLanguage(Language::TYPE_URL)->id; $langcode = $langcode ?: $this->languageManager->getCurrentLanguage(Language::TYPE_URL)->id;
// Lookup the path alias first.
if (!empty($path) && $source = $this->lookupPathSource($path, $path_language)) { // If we already know that there are no paths for this alias simply return.
$path = $source; if (empty($alias) || !empty($this->noPath[$langcode][$alias])) {
return $alias;
} }
return $path; // Look for the alias within the cached map.
if (isset($this->lookupMap[$langcode]) && ($path = array_search($alias, $this->lookupMap[$langcode]))) {
return $path;
}
// Look for path in storage.
if ($path = $this->storage->lookupPathSource($alias, $langcode)) {
$this->lookupMap[$langcode][$path] = $alias;
return $path;
}
// We can't record anything into $this->lookupMap because we didn't find any
// paths for this alias. Thus cache to $this->noPath.
$this->noPath[$langcode][$alias] = TRUE;
return $alias;
} }
/** /**
* Implements \Drupal\Core\Path\AliasManagerInterface::getPathAlias(). * {@inheritdoc}
*/ */
public function getPathAlias($path, $path_language = NULL) { public function getAliasByPath($path, $langcode = NULL) {
// If no language is explicitly specified we default to the current URL // If no language is explicitly specified we default to the current URL
// language. If we used a language different from the one conveyed by the // language. If we used a language different from the one conveyed by the
// requested URL, we might end up being unable to check if there is a path // requested URL, we might end up being unable to check if there is a path
// alias matching the URL path. // alias matching the URL path.
$path_language = $path_language ?: $this->languageManager->getCurrentLanguage(Language::TYPE_URL)->id; $langcode = $langcode ?: $this->languageManager->getCurrentLanguage(Language::TYPE_URL)->id;
$result = $path;
if (!empty($path) && $alias = $this->lookupPathAlias($path, $path_language)) { // Check the path whitelist, if the top-level part before the first /
$result = $alias; // is not in the list, then there is no need to do anything further,
// it is not in the database.
if (empty($path) || !$this->whitelist->get(strtok($path, '/'))) {
return $path;
} }
return $result;
// During the first call to this method per language, load the expected
// paths for the page from cache.
if (empty($this->langcodePreloaded[$langcode])) {
$this->langcodePreloaded[$langcode] = TRUE;
$this->lookupMap[$langcode] = array();
// Load paths from cache.
if (!empty($this->preloadedPathLookups)) {
$this->lookupMap[$langcode] = $this->storage->preloadPathAlias($this->preloadedPathLookups, $langcode);
// Keep a record of paths with no alias to avoid querying twice.
$this->noAlias[$langcode] = array_flip(array_diff_key($this->preloadedPathLookups, array_keys($this->lookupMap[$langcode])));
}
}
// If we already know that there are no aliases for this path simply return.
if (!empty($this->noAlias[$langcode][$path])) {
return $path;
}
// If the alias has already been loaded, return it from static cache.
if (isset($this->lookupMap[$langcode][$path])) {
return $this->lookupMap[$langcode][$path];
}
// Try to load alias from storage.
if ($alias = $this->storage->lookupPathAlias($path, $langcode)) {
$this->lookupMap[$langcode][$path] = $alias;
return $alias;
}
// We can't record anything into $this->lookupMap because we didn't find any
// aliases for this path. Thus cache to $this->noAlias.
$this->noAlias[$langcode][$path] = TRUE;
return $path;
} }
/** /**
...@@ -132,9 +183,9 @@ public function cacheClear($source = NULL) { ...@@ -132,9 +183,9 @@ public function cacheClear($source = NULL) {
else { else {
$this->lookupMap = array(); $this->lookupMap = array();
} }
$this->noSource = array(); $this->noPath = array();
$this->no_aliases = array(); $this->noAlias = array();
$this->firstCall = TRUE; $this->langcodePreloaded = array();
$this->preloadedPathLookups = array(); $this->preloadedPathLookups = array();
$this->pathAliasWhitelistRebuild($source); $this->pathAliasWhitelistRebuild($source);
} }
...@@ -157,86 +208,6 @@ public function preloadPathLookups(array $path_list) { ...@@ -157,86 +208,6 @@ public function preloadPathLookups(array $path_list) {
$this->preloadedPathLookups = $path_list; $this->preloadedPathLookups = $path_list;
} }
/**
* Given a Drupal system URL return one of its aliases if such a one exists.
* Otherwise, return FALSE.
*
* @param $path
* The path to investigate for corresponding aliases.
* @param $langcode
* Optional language code to search the path with. Defaults to the page language.
* If there's no path defined for that language it will search paths without
* language.
*
* @return
* An aliased path, or FALSE if no path was found.
*/
protected function lookupPathAlias($path, $langcode) {
// During the first call to this method per language, load the expected
// system paths for the page from cache.
if (!empty($this->firstLookup)) {
$this->firstLookup = FALSE;
$this->lookupMap[$langcode] = array();
// Load system paths from cache.
if (!empty($this->preloadedPathLookups)) {
// Now fetch the aliases corresponding to these system paths.
$this->lookupMap[$langcode] = $this->storage->preloadPathAlias($this->preloadedPathLookups, $langcode);
// Keep a record of paths with no alias to avoid querying twice.
$this->noAliases[$langcode] = array_flip(array_diff_key($this->preloadedPathLookups, array_keys($this->lookupMap[$langcode])));
}
}
// If the alias has already been loaded, return it.
if (isset($this->lookupMap[$langcode][$path])) {
return $this->lookupMap[$langcode][$path];
}
// Check the path whitelist, if the top-level part before the first /
// is not in the list, then there is no need to do anything further,
// it is not in the database.
elseif (!$this->whitelist->get(strtok($path, '/'))) {
return FALSE;
}
// For system paths which were not cached, query aliases individually.
elseif (!isset($this->noAliases[$langcode][$path])) {
$this->lookupMap[$langcode][$path] = $this->storage->lookupPathAlias($path, $langcode);
return $this->lookupMap[$langcode][$path];
}
return FALSE;
}
/**
* Given an alias, return its Drupal system URL if one exists. Otherwise,
* return FALSE.
*
* @param $path
* The path to investigate for corresponding system URLs.
* @param $langcode
* Optional language code to search the path with. Defaults to the page language.
* If there's no path defined for that language it will search paths without
* language.
*
* @return
* A Drupal system path, or FALSE if no path was found.
*/
protected function lookupPathSource($path, $langcode) {
if ($this->whitelist && !isset($this->noSource[$langcode][$path])) {
// Look for the value $path within the cached $map
$source = isset($this->lookupMap[$langcode]) ? array_search($path, $this->lookupMap[$langcode]) : FALSE;
if (!$source) {
if ($source = $this->storage->lookupPathSource($path, $langcode)) {
$this->lookupMap[$langcode][$source] = $path;
}
else {
// We can't record anything into $map because we do not have a valid
// index and there is no need because we have not learned anything
// about any Drupal path. Thus cache to $no_source.
$this->noSource[$langcode][$path] = TRUE;
}
}
return $source;
}
return FALSE;
}
/** /**
* Rebuild the path alias white list. * Rebuild the path alias white list.
* *
......
...@@ -10,33 +10,30 @@ ...@@ -10,33 +10,30 @@
interface AliasManagerInterface { interface AliasManagerInterface {
/** /**
* Given a path alias, return the internal path it represents. * Given the alias, return the path it represents.
* *
* @param $path * @param string $alias
* A Drupal path alias. * An alias.
* @param $path_language * @param string $langcode
* An optional language code to look up the path in. * An optional language code to look up the path in.
* *
* @return * @return string
* The internal path represented by the alias, or the original alias if no * The path represented by alias, or the alias if no path was found.
* internal path was found.
*/ */
public function getSystemPath($path, $path_language = NULL); public function getPathByAlias($alias, $langcode = NULL);
/** /**
* Given an internal Drupal path, return the alias set by the administrator. * Given a path, return the alias.
* *
* @param $path * @param string $path
* An internal Drupal path. * A path.
* * @param string $langcode
* @param $path_language
* An optional language code to look up the path in. * An optional language code to look up the path in.
* *
* @return * @return string
* An aliased path if one was found, or the original path if no alias was * An alias that represents the path, or path if no alias was found.
* found.
*/ */
public function getPathAlias($path, $path_language = NULL); public function getAliasByPath($path, $langcode = NULL);
/** /**
* Returns an array of system paths that have been looked up. * Returns an array of system paths that have been looked up.
......
...@@ -36,7 +36,7 @@ public function __construct(AliasManagerInterface $alias_manager) { ...@@ -36,7 +36,7 @@ public function __construct(AliasManagerInterface $alias_manager) {
* Implements Drupal\Core\PathProcessor\InboundPathProcessorInterface::processInbound(). * Implements Drupal\Core\PathProcessor\InboundPathProcessorInterface::processInbound().
*/ */
public function processInbound($path, Request $request) { public function processInbound($path, Request $request) {
$path = $this->aliasManager->getSystemPath($path); $path = $this->aliasManager->getPathByAlias($path);
return $path; return $path;
} }
...@@ -46,7 +46,7 @@ public function processInbound($path, Request $request) { ...@@ -46,7 +46,7 @@ public function processInbound($path, Request $request) {
public function processOutbound($path, &$options = array(), Request $request = NULL) { public function processOutbound($path, &$options = array(), Request $request = NULL) {
if (empty($options['alias'])) { if (empty($options['alias'])) {
$langcode = isset($options['language']) ? $options['language']->id : NULL; $langcode = isset($options['language']) ? $options['language']->id : NULL;
$path = $this->aliasManager->getPathAlias($path, $langcode); $path = $this->aliasManager->getAliasByPath($path, $langcode);
} }
return $path; return $path;
} }
......
...@@ -98,7 +98,7 @@ protected function checkAccess(EntityInterface $entity, $operation, $langcode, A ...@@ -98,7 +98,7 @@ protected function checkAccess(EntityInterface $entity, $operation, $langcode, A
if ($visibility['path']['visibility'] < BLOCK_VISIBILITY_PHP) { if ($visibility['path']['visibility'] < BLOCK_VISIBILITY_PHP) {
// Compare the lowercase path alias (if any) and internal path. // Compare the lowercase path alias (if any) and internal path.
$path = current_path(); $path = current_path();
$path_alias = Unicode::strtolower($this->aliasManager->getPathAlias($path)); $path_alias = Unicode::strtolower($this->aliasManager->getAliasByPath($path));
$page_match = drupal_match_path($path_alias, $pages) || (($path != $path_alias) && drupal_match_path($path, $pages)); $page_match = drupal_match_path($path_alias, $pages) || (($path != $path_alias) && drupal_match_path($path, $pages));
// When $block->visibility has a value of 0 // When $block->visibility has a value of 0
// (BLOCK_VISIBILITY_NOTLISTED), the block is displayed on all pages // (BLOCK_VISIBILITY_NOTLISTED), the block is displayed on all pages
......
...@@ -210,7 +210,7 @@ public function massageFormValues(array $values, array $form, array &$form_state ...@@ -210,7 +210,7 @@ public function massageFormValues(array $values, array $form, array &$form_state
// If internal links are supported, look up whether the given value is // If internal links are supported, look up whether the given value is
// a path alias and store the system path instead. // a path alias and store the system path instead.
if ($this->supportsInternalLinks() && !UrlHelper::isExternal($value['url'])) { if ($this->supportsInternalLinks() && !UrlHelper::isExternal($value['url'])) {
$parsed_url['path'] = \Drupal::service('path.alias_manager.cached')->getSystemPath($parsed_url['path']); $parsed_url['path'] = \Drupal::service('path.alias_manager.cached')->getPathByAlias($parsed_url['path']);
} }
$url = Url::createFromPath($parsed_url['path']); $url = Url::createFromPath($parsed_url['path']);
......
...@@ -109,10 +109,10 @@ function testPathLanguageConfiguration() { ...@@ -109,10 +109,10 @@ function testPathLanguageConfiguration() {
'langcode' => Language::LANGCODE_NOT_SPECIFIED, 'langcode' => Language::LANGCODE_NOT_SPECIFIED,
); );
$this->container->get('path.alias_storage')->save($edit['source'], $edit['alias'], $edit['langcode']); $this->container->get('path.alias_storage')->save($edit['source'], $edit['alias'], $edit['langcode']);
$lookup_path = $this->container->get('path.alias_manager')->getPathAlias('node/' . $node->id(), 'en'); $lookup_path = $this->container->get('path.alias_manager')->getAliasByPath('node/' . $node->id(), 'en');
$this->assertEqual($english_path, $lookup_path, 'English language alias has priority.'); $this->assertEqual($english_path, $lookup_path, 'English language alias has priority.');
// Same check for language 'xx'. // Same check for language 'xx'.
$lookup_path = $this->container->get('path.alias_manager')->getPathAlias('node/' . $node->id(), $prefix); $lookup_path = $this->container->get('path.alias_manager')->getAliasByPath('node/' . $node->id(), $prefix);
$this->assertEqual($custom_language_path, $lookup_path, 'Custom language alias has priority.'); $this->assertEqual($custom_language_path, $lookup_path, 'Custom language alias has priority.');
$this->container->get('path.alias_storage')->delete($edit); $this->container->get('path.alias_storage')->delete($edit);
......
...@@ -204,7 +204,7 @@ protected function actions(array $form, array &$form_state) { ...@@ -204,7 +204,7 @@ protected function actions(array $form, array &$form_state) {
public function validate(array $form, array &$form_state) { public function validate(array $form, array &$form_state) {
$menu_link = $this->buildEntity($form, $form_state); $menu_link = $this->buildEntity($form, $form_state);
$normal_path = $this->pathAliasManager->getSystemPath($menu_link->link_path); $normal_path = $this->pathAliasManager->getPathByAlias($menu_link->link_path);
if ($menu_link->link_path != $normal_path) { if ($menu_link->link_path != $normal_path) {
drupal_set_message(t('The menu system stores system paths only, but will use the URL alias for display. %link_path has been stored as %normal_path', array('%link_path' => $menu_link->link_path, '%normal_path' => $normal_path))); drupal_set_message(t('The menu system stores system paths only, but will use the URL alias for display. %link_path has been stored as %normal_path', array('%link_path' => $menu_link->link_path, '%normal_path' => $normal_path)));
$menu_link->link_path = $normal_path; $menu_link->link_path = $normal_path;
......
...@@ -110,7 +110,7 @@ public function adminOverview($keys) { ...@@ -110,7 +110,7 @@ public function adminOverview($keys) {
// If the system path maps to a different URL alias, highlight this table // If the system path maps to a different URL alias, highlight this table
// row to let the user know of old aliases. // row to let the user know of old aliases.
if ($data->alias != $this->aliasManager->getPathAlias($data->source, $data->langcode)) { if ($data->alias != $this->aliasManager->getAliasByPath($data->source, $data->langcode)) {
$row['class'] = array('warning'); $row['class'] = array('warning');
} }
......
...@@ -137,7 +137,7 @@ public function buildForm(array $form, array &$form_state, $pid = NULL) { ...@@ -137,7 +137,7 @@ public function buildForm(array $form, array &$form_state, $pid = NULL) {
*/ */
public function validateForm(array &$form, array &$form_state) { public function validateForm(array &$form, array &$form_state) {
$source = &$form_state['values']['source']; $source = &$form_state['values']['source'];
$source = $this->aliasManager->getSystemPath($source); $source = $this->aliasManager->getPathByAlias($source);
$alias = $form_state['values']['alias']; $alias = $form_state['values']['alias'];
// Language is only set if language.module is enabled, otherwise save for all // Language is only set if language.module is enabled, otherwise save for all
// languages. // languages.
...@@ -160,7 +160,7 @@ public function submitForm(array &$form, array &$form_state) { ...@@ -160,7 +160,7 @@ public function submitForm(array &$form, array &$form_state) {
$pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0; $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0;
$source = &$form_state['values']['source']; $source = &$form_state['values']['source'];
$source = $this->aliasManager->getSystemPath($source); $source = $this->aliasManager->getPathByAlias($source);
$alias = $form_state['values']['alias']; $alias = $form_state['values']['alias'];
// Language is only set if language.module is enabled, otherwise save for all // Language is only set if language.module is enabled, otherwise save for all
// languages. // languages.
......
...@@ -177,17 +177,17 @@ function testAliasTranslation() { ...@@ -177,17 +177,17 @@ function testAliasTranslation() {
// The alias manager has an internal path lookup cache. Check to see that // The alias manager has an internal path lookup cache. Check to see that
// it has the appropriate contents at this point. // it has the appropriate contents at this point.
$this->container->get('path.alias_manager')->cacheClear(); $this->container->get('path.alias_manager')->cacheClear();
$french_node_path = $this->container->get('path.alias_manager')->getSystemPath($french_alias, 'fr'); $french_node_path = $this->container->get('path.alias_manager')->getPathByAlias($french_alias, 'fr');
$this->assertEqual($french_node_path, 'node/' . $french_node->id(), 'Normal path works.'); $this->assertEqual($french_node_path, 'node/' . $french_node->id(), 'Normal path works.');
// Second call should return the same path. // Second call should return the same path.
$french_node_path = $this->container->get('path.alias_manager')->getSystemPath($french_alias, 'fr'); $french_node_path = $this->container->get('path.alias_manager')->getPathByAlias($french_alias, 'fr');
$this->assertEqual($french_node_path, 'node/' . $french_node->id(), 'Normal path is the same.'); $this->assertEqual($french_node_path, 'node/' . $french_node->id(), 'Normal path is the same.');
// Confirm that the alias works. // Confirm that the alias works.
$french_node_alias = $this->container->get('path.alias_manager')->getPathAlias('node/' . $french_node->id(), 'fr'); $french_node_alias = $this->container->get('path.alias_manager')->getAliasByPath('node/' . $french_node->id(), 'fr');
$this->assertEqual($french_node_alias, $french_alias, 'Alias works.'); $this->assertEqual($french_node_alias, $french_alias, 'Alias works.');
// Second call should return the same alias. // Second call should return the same alias.
$french_node_alias = $this->container->get('path.alias_manager')->getPathAlias('node/' . $french_node->id(), 'fr'); $french_node_alias = $this->container->get('path.alias_manager')->getAliasByPath('node/' . $french_node->id(), 'fr');
$this->assertEqual($french_node_alias, $french_alias, 'Alias is the same.'); $this->assertEqual($french_node_alias, $french_alias, 'Alias is the same.');
} }
} }
...@@ -273,7 +273,7 @@ function shortcut_set_title_exists($title) { ...@@ -273,7 +273,7 @@ function shortcut_set_title_exists($title) {
*/ */
function shortcut_valid_link($path) { function shortcut_valid_link($path) {
// Do not use URL aliases. // Do not use URL aliases.
$normal_path = \Drupal::service('path.alias_manager')->getSystemPath($path); $normal_path = \Drupal::service('path.alias_manager')->getPathByAlias($path);
if ($path != $normal_path) { if ($path != $normal_path) {
$path = $normal_path; $path = $normal_path;
} }
......
...@@ -40,7 +40,7 @@ public function getValue() { ...@@ -40,7 +40,7 @@ public function getValue() {
*/ */
public function setValue($value, $notify = TRUE) { public function setValue($value, $notify = TRUE) {
// Normalize the path in case it is an alias. // Normalize the path in case it is an alias.
$value = \Drupal::service('path.alias_manager')->getSystemPath($value); $value = \Drupal::service('path.alias_manager')->getPathByAlias($value);
if (empty($value)) { if (empty($value)) {
$value = '<front>'; $value = '<front>';
} }
......
...@@ -62,7 +62,7 @@ public function testShortcutLinkAdd() { ...@@ -62,7 +62,7 @@ public function testShortcutLinkAdd() {
$this->assertResponse(200); $this->assertResponse(200);
$saved_set = shortcut_set_load($set->id()); $saved_set = shortcut_set_load($set->id());
$paths = $this->getShortcutInformation($saved_set, 'path'); $paths = $this->getShortcutInformation($saved_set, 'path');
$this->assertTrue(in_array($this->container->get('path.alias_manager')->getSystemPath($test['path']), $paths), 'Shortcut created: ' . $test['path']); $this->assertTrue(in_array($this->container->get('path.alias_manager')->getPathByAlias($test['path']), $paths), 'Shortcut created: ' . $test['path']);
$this->assertLink($title, 0, 'Shortcut link found on the page.'); $this->assertLink($title, 0, 'Shortcut link found on the page.');
} }
} }
......
...@@ -169,7 +169,7 @@ function statistics_get($nid) { ...@@ -169,7 +169,7 @@ function statistics_get($nid) {
* A string as a link, truncated to the width, linked to the given $path. * A string as a link, truncated to the width, linked to the given $path.
*/ */
function _statistics_link($path, $width = 35) { function _statistics_link($path, $width = 35) {
$title = \Drupal::service('path.alias_manager')->getPathAlias($path); $title = \Drupal::service('path.alias_manager')->getAliasByPath($path);
$title = truncate_utf8($title, $width, FALSE, TRUE); $title = truncate_utf8($title, $width, FALSE, TRUE);
return l($title, $path); return l($title, $path);
} }
......
...@@ -94,7 +94,7 @@ public function buildForm(array $form, array &$form_state) { ...@@ -94,7 +94,7 @@ public function buildForm(array $form, array &$form_state) {
'#title' => t('Front page'), '#title' => t('Front page'),
'#open' => TRUE, '#open' => TRUE,
); );
$front_page = $site_config->get('page.front') != 'user' ? $this->aliasManager->getPathAlias($site_config->get('page.front')) : ''; $front_page = $site_config->get('page.front') != 'user' ? $this->aliasManager->getAliasByPath($site_config->get('page.front')) : '';
$form['front_page']['site_frontpage'] = array( $form['front_page']['site_frontpage'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Default front page'), '#title' => t('Default front page'),
...@@ -139,7 +139,7 @@ public function validateForm(array &$form, array &$form_state) { ...@@ -139,7 +139,7 @@ public function validateForm(array &$form, array &$form_state) {
} }
else { else {
// Get the normal path of the front page.