diff --git a/core/core.services.yml b/core/core.services.yml index ddbda5d9a86e567c315231f1d461e8bebcac7884..0b8be53656c7d6fc14710e23b57dfe954bd91c97 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -149,7 +149,7 @@ services: arguments: [path_alias_whitelist, '@cache.default', '@lock', '@state', '@database'] path.alias_manager: class: Drupal\Core\Path\AliasManager - arguments: ['@path.crud', '@path.alias_whitelist', '@language_manager'] + arguments: ['@path.alias_storage', '@path.alias_whitelist', '@language_manager'] http_client_simpletest_subscriber: class: Drupal\Core\Http\Plugin\SimpletestHttpRequestSubscriber http_default_client: @@ -353,8 +353,8 @@ services: path.alias_manager.cached: class: Drupal\Core\CacheDecorator\AliasManagerCacheDecorator arguments: ['@path.alias_manager', '@cache.data'] - path.crud: - class: Drupal\Core\Path\Path + path.alias_storage: + class: Drupal\Core\Path\AliasStorage arguments: ['@database', '@module_handler'] # The argument to the hashing service defined in services.yml, to the # constructor of PhpassHashedPassword is the log2 number of iterations for diff --git a/core/includes/path.inc b/core/includes/path.inc index ca88a979844e8b2d8dcb7ca7c4a4946fbc5e7ef2..f60292b67f54e39e2c2c4b0b26085baefa592b83 100644 --- a/core/includes/path.inc +++ b/core/includes/path.inc @@ -115,7 +115,7 @@ function path_load($conditions) { elseif (!is_array($conditions)) { return FALSE; } - return \Drupal::service('path.crud')->load($conditions); + return \Drupal::service('path.alias_storage')->load($conditions); } /** diff --git a/core/lib/Drupal/Core/Path/AliasManager.php b/core/lib/Drupal/Core/Path/AliasManager.php index 0b4af2dd566e24c2a581955746238a4f1e028ae5..84dbb02f2fd1340ed169bf1e099b4007728e4330 100644 --- a/core/lib/Drupal/Core/Path/AliasManager.php +++ b/core/lib/Drupal/Core/Path/AliasManager.php @@ -13,11 +13,11 @@ class AliasManager implements AliasManagerInterface { /** - * The Path CRUD service. + * The alias storage service. * - * @var \Drupal\Core\Path\PathInterface + * @var \Drupal\Core\Path\AliasStorageInterface */ - protected $path; + protected $storage; /** * Language manager for retrieving the default langcode when none is specified. @@ -74,15 +74,15 @@ class AliasManager implements AliasManagerInterface { /** * Constructs an AliasManager. * - * @param \Drupal\Core\Path\PathInterface $path - * The Path CRUD service. + * @param \Drupal\Core\Path\AliasStorageInterface $storage + * The alias storage service. * @param \Drupal\Core\Path\AliasWhitelistInterface $whitelist * The whitelist implementation to use. * @param \Drupal\Core\Language\LanguageManager $language_manager * The language manager. */ - public function __construct(PathInterface $path, AliasWhitelistInterface $whitelist, LanguageManager $language_manager) { - $this->path = $path; + public function __construct(AliasStorageInterface $storage, AliasWhitelistInterface $whitelist, LanguageManager $language_manager) { + $this->storage = $storage; $this->languageManager = $language_manager; $this->whitelist = $whitelist; } @@ -180,7 +180,7 @@ protected function lookupPathAlias($path, $langcode) { // Load system paths from cache. if (!empty($this->preloadedPathLookups)) { // Now fetch the aliases corresponding to these system paths. - $this->lookupMap[$langcode] = $this->path->preloadPathAlias($this->preloadedPathLookups, $langcode); + $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]))); } @@ -197,7 +197,7 @@ protected function lookupPathAlias($path, $langcode) { } // For system paths which were not cached, query aliases individually. elseif (!isset($this->noAliases[$langcode][$path])) { - $this->lookupMap[$langcode][$path] = $this->path->lookupPathAlias($path, $langcode); + $this->lookupMap[$langcode][$path] = $this->storage->lookupPathAlias($path, $langcode); return $this->lookupMap[$langcode][$path]; } return FALSE; @@ -222,7 +222,7 @@ protected function lookupPathSource($path, $langcode) { // 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->path->lookupPathSource($path, $langcode)) { + if ($source = $this->storage->lookupPathSource($path, $langcode)) { $this->lookupMap[$langcode][$source] = $path; } else { diff --git a/core/lib/Drupal/Core/Path/Path.php b/core/lib/Drupal/Core/Path/AliasStorage.php similarity index 98% rename from core/lib/Drupal/Core/Path/Path.php rename to core/lib/Drupal/Core/Path/AliasStorage.php index 1d7c684c0d0faccae55c812038d42ab2b4f3791d..2062ebceed47012d2dd2ea35e979aa0833c82051 100644 --- a/core/lib/Drupal/Core/Path/Path.php +++ b/core/lib/Drupal/Core/Path/AliasStorage.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\Core\Path\Path. + * Contains \Drupal\Core\Path\AliasStorage. */ namespace Drupal\Core\Path; @@ -14,8 +14,7 @@ /** * Provides a class for CRUD operations on path aliases. */ -class Path implements PathInterface { - +class AliasStorage implements AliasStorageInterface { /** * The database connection. * diff --git a/core/lib/Drupal/Core/Path/PathInterface.php b/core/lib/Drupal/Core/Path/AliasStorageInterface.php similarity index 97% rename from core/lib/Drupal/Core/Path/PathInterface.php rename to core/lib/Drupal/Core/Path/AliasStorageInterface.php index 8d6cfefd553d14c6ba046ebfaf2992110a3affba..68c7cdde5d2d8fb0448426f4a23bc02509791484 100644 --- a/core/lib/Drupal/Core/Path/PathInterface.php +++ b/core/lib/Drupal/Core/Path/AliasStorageInterface.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\Core\Path\PathInterface. + * Contains \Drupal\Core\Path\AliasStorageInterface. */ namespace Drupal\Core\Path; @@ -12,7 +12,7 @@ /** * Provides a class for CRUD operations on path aliases. */ -interface PathInterface { +interface AliasStorageInterface { /** * Saves a path alias to the database. diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationDeleteForm.php b/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationDeleteForm.php index 0b780e35029a5fd01880361e3407e84d04cafb1e..07acc16dc34d093d104409ad881d15c865019328 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationDeleteForm.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationDeleteForm.php @@ -83,7 +83,7 @@ public function submitForm(array &$form, array &$form_state) { if (\Drupal::moduleHandler()->moduleExists('path')) { $path = $this->entity->getSystemPath(); $conditions = array('source' => $path, 'langcode' => $this->language->id); - \Drupal::service('path.crud')->delete($conditions); + \Drupal::service('path.alias_storage')->delete($conditions); } $form_state['redirect_route'] = $this->getCancelRoute(); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php index 4466a91a7d6d031f64e1d7bf0d6d6ac8bfdf80fc..aacf2e441eef4c2c51ea99b2a4a1cf1bde395287 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php @@ -108,13 +108,13 @@ function testPathLanguageConfiguration() { 'alias' => $custom_path, 'langcode' => Language::LANGCODE_NOT_SPECIFIED, ); - $this->container->get('path.crud')->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'); $this->assertEqual($english_path, $lookup_path, 'English language alias has priority.'); // Same check for language 'xx'. $lookup_path = $this->container->get('path.alias_manager')->getPathAlias('node/' . $node->id(), $prefix); $this->assertEqual($custom_language_path, $lookup_path, 'Custom language alias has priority.'); - $this->container->get('path.crud')->delete($edit); + $this->container->get('path.alias_storage')->delete($edit); // Create language nodes to check priority of aliases. $first_node = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1, 'langcode' => 'en')); @@ -126,7 +126,7 @@ function testPathLanguageConfiguration() { 'alias' => $custom_path, 'langcode' => $first_node->language()->id, ); - $this->container->get('path.crud')->save($edit['source'], $edit['alias'], $edit['langcode']); + $this->container->get('path.alias_storage')->save($edit['source'], $edit['alias'], $edit['langcode']); // Assign a custom path alias to second node with Language::LANGCODE_NOT_SPECIFIED. $edit = array( @@ -134,7 +134,7 @@ function testPathLanguageConfiguration() { 'alias' => $custom_path, 'langcode' => $second_node->language()->id, ); - $this->container->get('path.crud')->save($edit['source'], $edit['alias'], $edit['langcode']); + $this->container->get('path.alias_storage')->save($edit['source'], $edit['alias'], $edit['langcode']); // Test that both node titles link to our path alias. $this->drupalGet(''); diff --git a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/UrlAlias.php b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/UrlAlias.php index 71cf11295a69faa6f5c6c240a4841474b7bae8a3..dafbb767e20e3d48efc861426de3343cd5520b5d 100644 --- a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/UrlAlias.php +++ b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/UrlAlias.php @@ -7,7 +7,7 @@ namespace Drupal\migrate\Plugin\migrate\destination; -use Drupal\Core\Path\PathInterface; +use Drupal\Core\Path\AliasStorage; use Drupal\migrate\Entity\MigrationInterface; use Drupal\migrate\Row; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -21,11 +21,11 @@ class UrlAlias extends DestinationBase implements ContainerFactoryPluginInterface { /** - * The path crud service. + * The alias storage service. * - * @var \Drupal\Core\Path\PathInterface $path + * @var \Drupal\Core\Path\AliasStorage $aliasStorage */ - protected $path; + protected $aliasStorage; /** * Constructs an entity destination plugin. @@ -38,12 +38,12 @@ class UrlAlias extends DestinationBase implements ContainerFactoryPluginInterfac * The plugin implementation definition. * @param MigrationInterface $migration * The migration. - * @param \Drupal\Core\Path\PathInterface $path + * @param \Drupal\Core\Path\AliasStorage $alias_storage * The path crud service. */ - public function __construct(array $configuration, $plugin_id, array $plugin_definition, MigrationInterface $migration, PathInterface $path) { + public function __construct(array $configuration, $plugin_id, array $plugin_definition, MigrationInterface $migration, AliasStorage $alias_storage) { parent::__construct($configuration, $plugin_id, $plugin_definition, $migration); - $this->path = $path; + $this->aliasStorage = $alias_storage; } /** @@ -55,7 +55,7 @@ public static function create(ContainerInterface $container, array $configuratio $plugin_id, $plugin_definition, $migration, - $container->get('path.crud') + $container->get('path.alias_storage') ); } diff --git a/core/modules/path/lib/Drupal/path/Form/DeleteForm.php b/core/modules/path/lib/Drupal/path/Form/DeleteForm.php index c6d3e6d3f3405b03adfb537de11b3acf4bd95568..e7b33073d7556cb5c0a465d36b00ac482dcee43b 100644 --- a/core/modules/path/lib/Drupal/path/Form/DeleteForm.php +++ b/core/modules/path/lib/Drupal/path/Form/DeleteForm.php @@ -8,7 +8,7 @@ namespace Drupal\path\Form; use Drupal\Core\Form\ConfirmFormBase; -use Drupal\Core\Path\PathInterface; +use Drupal\Core\Path\AliasStorageInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -17,11 +17,11 @@ class DeleteForm extends ConfirmFormBase { /** - * The path crud service. + * The alias storage service. * - * @var PathInterface $path + * @var AliasStorageInterface $path */ - protected $path; + protected $aliasStorage; /** * The path alias being deleted. @@ -33,11 +33,11 @@ class DeleteForm extends ConfirmFormBase { /** * Constructs a \Drupal\path\Form\DeleteForm object. * - * @param \Drupal\Core\Path\PathInterface $path - * The path crud service. + * @param \Drupal\Core\Path\AliasStorageInterface $alias_storage + * The alias storage service. */ - public function __construct(PathInterface $path) { - $this->path = $path; + public function __construct(AliasStorageInterface $alias_storage) { + $this->aliasStorage = $alias_storage; } /** @@ -45,7 +45,7 @@ public function __construct(PathInterface $path) { */ public static function create(ContainerInterface $container) { return new static( - $container->get('path.crud') + $container->get('path.alias_storage') ); } @@ -73,7 +73,7 @@ public function getCancelRoute() { * Overrides \Drupal\Core\Form\ConfirmFormBase::buildForm(). */ public function buildForm(array $form, array &$form_state, $pid = NULL) { - $this->pathAlias = $this->path->load(array('pid' => $pid)); + $this->pathAlias = $this->aliasStorage->load(array('pid' => $pid)); $form = parent::buildForm($form, $form_state); @@ -86,7 +86,7 @@ public function buildForm(array $form, array &$form_state, $pid = NULL) { * Implements \Drupal\Core\Form\FormInterface::submitForm(). */ public function submitForm(array &$form, array &$form_state) { - $this->path->delete(array('pid' => $this->pathAlias['pid'])); + $this->aliasStorage->delete(array('pid' => $this->pathAlias['pid'])); $form_state['redirect'] = 'admin/config/search/path'; } diff --git a/core/modules/path/lib/Drupal/path/Plugin/Field/FieldType/PathItem.php b/core/modules/path/lib/Drupal/path/Plugin/Field/FieldType/PathItem.php index 9e8c3fdaeea7345149c21ad557bad1cc89ea03f5..e43efb24508a6003027d9f87d92b06135ca206e3 100644 --- a/core/modules/path/lib/Drupal/path/Plugin/Field/FieldType/PathItem.php +++ b/core/modules/path/lib/Drupal/path/Plugin/Field/FieldType/PathItem.php @@ -58,7 +58,7 @@ public function insert() { // Ensure fields for programmatic executions. $langcode = $entity->language()->id; - if ($path = \Drupal::service('path.crud')->save($entity->getSystemPath(), $this->alias, $langcode)) { + if ($path = \Drupal::service('path.alias_storage')->save($entity->getSystemPath(), $this->alias, $langcode)) { $this->pid = $path['pid']; } } @@ -70,7 +70,7 @@ public function insert() { public function update() { // Delete old alias if user erased it. if ($this->pid && !$this->alias) { - \Drupal::service('path.crud')->delete(array('pid' => $this->pid)); + \Drupal::service('path.alias_storage')->delete(array('pid' => $this->pid)); } // Only save a non-empty alias. elseif ($this->alias) { @@ -79,7 +79,7 @@ public function update() { // Ensure fields for programmatic executions. $langcode = $entity->language()->id; - \Drupal::service('path.crud')->save($entity->getSystemPath(), $this->alias, $langcode, $this->pid); + \Drupal::service('path.alias_storage')->save($entity->getSystemPath(), $this->alias, $langcode, $this->pid); } } @@ -89,7 +89,7 @@ public function update() { public function delete() { // Delete all aliases associated with this entity. $entity = $this->getEntity(); - \Drupal::service('path.crud')->delete(array('source' => $entity->getSystemPath())); + \Drupal::service('path.alias_storage')->delete(array('source' => $entity->getSystemPath())); } } diff --git a/core/modules/path/path.admin.inc b/core/modules/path/path.admin.inc index d26d236fe9b51b760f9271ab626972697267b6b8..68697bfc731b2409be461b9f2630ee311a343484 100644 --- a/core/modules/path/path.admin.inc +++ b/core/modules/path/path.admin.inc @@ -268,7 +268,7 @@ function path_admin_form_submit($form, &$form_state) { // languages. $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : Language::LANGCODE_NOT_SPECIFIED; - \Drupal::service('path.crud')->save($source, $alias, $langcode, $pid); + \Drupal::service('path.alias_storage')->save($source, $alias, $langcode, $pid); drupal_set_message(t('The alias has been saved.')); $form_state['redirect'] = 'admin/config/search/path'; diff --git a/core/modules/path/path.module b/core/modules/path/path.module index 8880073eacea2d1f79aa4f3327376b232b27547e..262075fd0c141393e2f153e77c4477105f3b700b 100644 --- a/core/modules/path/path.module +++ b/core/modules/path/path.module @@ -67,7 +67,7 @@ function path_form_node_form_alter(&$form, $form_state) { if ($node->language()->id != Language::LANGCODE_NOT_SPECIFIED) { $conditions['langcode'] = $node->language()->id; } - $path = \Drupal::service('path.crud')->load($conditions); + $path = \Drupal::service('path.alias_storage')->load($conditions); if ($path === FALSE) { $path = array(); } @@ -153,7 +153,7 @@ function path_form_taxonomy_term_form_alter(&$form, $form_state) { // Make sure this does not show up on the delete confirmation form. if (empty($form_state['confirm_delete'])) { $term = $form_state['controller']->getEntity(); - $path = ($term->id() ? \Drupal::service('path.crud')->load(array('source' => 'taxonomy/term/' . $term->id())) : array()); + $path = ($term->id() ? \Drupal::service('path.alias_storage')->load(array('source' => 'taxonomy/term/' . $term->id())) : array()); if ($path === FALSE) { $path = array(); } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php index 0729f984757e4d804a73e62f3684c3ebab9cedb2..d1bd39c77a319e7fd1175b71cec42ac5499f8a10 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php @@ -38,7 +38,7 @@ public function testShortcutLinkAdd() { 'source' => 'node/' . $this->node->id(), 'alias' => $this->randomName(8), ); - $this->container->get('path.crud')->save($path['source'], $path['alias']); + $this->container->get('path.alias_storage')->save($path['source'], $path['alias']); // Create some paths to test. $test_cases = array( diff --git a/core/modules/system/lib/Drupal/system/Tests/Path/AliasTest.php b/core/modules/system/lib/Drupal/system/Tests/Path/AliasTest.php index 8e62722ebd08d984e8efc6885b715d416f885475..5a39c048b086fd37b8ce4a2e6124c7a8b1d2f09f 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Path/AliasTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Path/AliasTest.php @@ -8,7 +8,7 @@ namespace Drupal\system\Tests\Path; use Drupal\Core\Cache\MemoryCounterBackend; -use Drupal\Core\Path\Path; +use Drupal\Core\Path\AliasStorage; use Drupal\Core\Database\Database; use Drupal\Core\Path\AliasManager; use Drupal\Core\Path\AliasWhitelist; @@ -32,13 +32,13 @@ function testCRUD() { $this->fixtures->createTables($connection); //Create Path object. - $path = new Path($connection, $this->container->get('module_handler')); + $aliasStorage = new AliasStorage($connection, $this->container->get('module_handler')); $aliases = $this->fixtures->sampleUrlAliases(); //Create a few aliases foreach ($aliases as $idx => $alias) { - $path->save($alias['source'], $alias['alias'], $alias['langcode']); + $aliasStorage->save($alias['source'], $alias['alias'], $alias['langcode']); $result = $connection->query('SELECT * FROM {url_alias} WHERE source = :source AND alias= :alias AND langcode = :langcode', array(':source' => $alias['source'], ':alias' => $alias['alias'], ':langcode' => $alias['langcode'])); $rows = $result->fetchAll(); @@ -52,13 +52,13 @@ function testCRUD() { //Load a few aliases foreach ($aliases as $alias) { $pid = $alias['pid']; - $loadedAlias = $path->load(array('pid' => $pid)); + $loadedAlias = $aliasStorage->load(array('pid' => $pid)); $this->assertEqual($loadedAlias, $alias, format_string('Loaded the expected path with pid %pid.', array('%pid' => $pid))); } //Update a few aliases foreach ($aliases as $alias) { - $path->save($alias['source'], $alias['alias'] . '_updated', $alias['langcode'], $alias['pid']); + $aliasStorage->save($alias['source'], $alias['alias'] . '_updated', $alias['langcode'], $alias['pid']); $result = $connection->query('SELECT pid FROM {url_alias} WHERE source = :source AND alias= :alias AND langcode = :langcode', array(':source' => $alias['source'], ':alias' => $alias['alias'] . '_updated', ':langcode' => $alias['langcode'])); $pid = $result->fetchField(); @@ -69,7 +69,7 @@ function testCRUD() { //Delete a few aliases foreach ($aliases as $alias) { $pid = $alias['pid']; - $path->delete(array('pid' => $pid)); + $aliasStorage->delete(array('pid' => $pid)); $result = $connection->query('SELECT * FROM {url_alias} WHERE pid = :pid', array(':pid' => $pid)); $rows = $result->fetchAll(); @@ -85,7 +85,7 @@ function testLookupPath() { //Create AliasManager and Path object. $aliasManager = $this->container->get('path.alias_manager.cached'); - $pathObject = new Path($connection, $this->container->get('module_handler')); + $aliasStorage = new AliasStorage($connection, $this->container->get('module_handler')); // Test the situation where the source is the same for multiple aliases. // Start with a language-neutral alias, which we will override. @@ -94,7 +94,7 @@ function testLookupPath() { 'alias' => 'foo', ); - $pathObject->save($path['source'], $path['alias']); + $aliasStorage->save($path['source'], $path['alias']); $this->assertEqual($aliasManager->getPathAlias($path['source']), $path['alias'], 'Basic alias lookup works.'); $this->assertEqual($aliasManager->getSystemPath($path['alias']), $path['source'], 'Basic source lookup works.'); @@ -104,7 +104,7 @@ function testLookupPath() { 'alias' => "users/Dries", 'langcode' => 'en', ); - $pathObject->save($path['source'], $path['alias'], $path['langcode']); + $aliasStorage->save($path['source'], $path['alias'], $path['langcode']); // Hook that clears cache is not executed with unit tests. \Drupal::service('path.alias_manager.cached')->cacheClear(); $this->assertEqual($aliasManager->getPathAlias($path['source']), $path['alias'], 'English alias overrides language-neutral alias.'); @@ -115,7 +115,7 @@ function testLookupPath() { 'source' => "user/1", 'alias' => 'bar', ); - $pathObject->save($path['source'], $path['alias']); + $aliasStorage->save($path['source'], $path['alias']); $this->assertEqual($aliasManager->getPathAlias($path['source']), "users/Dries", 'English alias still returned after entering a language-neutral alias.'); // Create a language-specific (xx-lolspeak) alias for the same path. @@ -124,7 +124,7 @@ function testLookupPath() { 'alias' => 'LOL', 'langcode' => 'xx-lolspeak', ); - $pathObject->save($path['source'], $path['alias'], $path['langcode']); + $aliasStorage->save($path['source'], $path['alias'], $path['langcode']); $this->assertEqual($aliasManager->getPathAlias($path['source']), "users/Dries", 'English alias still returned after entering a LOLspeak alias.'); // The LOLspeak alias should be returned if we really want LOLspeak. $this->assertEqual($aliasManager->getPathAlias($path['source'], 'xx-lolspeak'), 'LOL', 'LOLspeak alias returned if we specify xx-lolspeak to the alias manager.'); @@ -136,7 +136,7 @@ function testLookupPath() { 'alias' => 'users/my-new-path', 'langcode' => 'en', ); - $pathObject->save($path['source'], $path['alias'], $path['langcode']); + $aliasStorage->save($path['source'], $path['alias'], $path['langcode']); // Hook that clears cache is not executed with unit tests. $aliasManager->cacheClear(); $this->assertEqual($aliasManager->getPathAlias($path['source']), $path['alias'], 'Recently created English alias returned.'); @@ -144,14 +144,14 @@ function testLookupPath() { // Remove the English aliases, which should cause a fallback to the most // recently created language-neutral alias, 'bar'. - $pathObject->delete(array('langcode' => 'en')); + $aliasStorage->delete(array('langcode' => 'en')); // Hook that clears cache is not executed with unit tests. $aliasManager->cacheClear(); $this->assertEqual($aliasManager->getPathAlias($path['source']), 'bar', 'Path lookup falls back to recently created language-neutral alias.'); // Test the situation where the alias and language are the same, but // the source differs. The newer alias record should be returned. - $pathObject->save('user/2', 'bar'); + $aliasStorage->save('user/2', 'bar'); // Hook that clears cache is not executed with unit tests. $aliasManager->cacheClear(); $this->assertEqual($aliasManager->getSystemPath('bar'), 'user/2', 'Newer alias record is returned when comparing two Language::LANGCODE_NOT_SPECIFIED paths with the same alias.'); @@ -169,8 +169,8 @@ function testWhitelist() { // Create AliasManager and Path object. $whitelist = new AliasWhitelist('path_alias_whitelist', $memoryCounterBackend, $this->container->get('lock'), $this->container->get('state'), $connection); - $path = new Path($connection, $this->container->get('module_handler')); - $aliasManager = new AliasManager($path, $whitelist, $this->container->get('language_manager')); + $aliasStorage = new AliasStorage($connection, $this->container->get('module_handler')); + $aliasManager = new AliasManager($aliasStorage, $whitelist, $this->container->get('language_manager')); // No alias for user and admin yet, so should be NULL. $this->assertNull($whitelist->get('user')); @@ -181,21 +181,21 @@ function testWhitelist() { $this->assertNull($whitelist->get($this->randomName())); // Add an alias for user/1, user should get whitelisted now. - $path->save('user/1', $this->randomName()); + $aliasStorage->save('user/1', $this->randomName()); $aliasManager->cacheClear(); $this->assertTrue($whitelist->get('user')); $this->assertNull($whitelist->get('admin')); $this->assertNull($whitelist->get($this->randomName())); // Add an alias for admin, both should get whitelisted now. - $path->save('admin/something', $this->randomName()); + $aliasStorage->save('admin/something', $this->randomName()); $aliasManager->cacheClear(); $this->assertTrue($whitelist->get('user')); $this->assertTrue($whitelist->get('admin')); $this->assertNull($whitelist->get($this->randomName())); // Remove the user alias again, whitelist entry should be removed. - $path->delete(array('source' => 'user/1')); + $aliasStorage->delete(array('source' => 'user/1')); $aliasManager->cacheClear(); $this->assertNull($whitelist->get('user')); $this->assertTrue($whitelist->get('admin')); diff --git a/core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php b/core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php index 35a4ef74a3c3113ecbfdf5182867d3e3da1c1d71..5772e0aff03c81ab0c67fcc83a55bf3f792c5fe4 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php @@ -46,7 +46,7 @@ function testUrlAlter() { // Test that a path always uses its alias. $path = array('source' => "user/$uid/test1", 'alias' => 'alias/test1'); - $this->container->get('path.crud')->save($path['source'], $path['alias']); + $this->container->get('path.alias_storage')->save($path['source'], $path['alias']); $this->rebuildContainer(); $this->assertUrlInboundAlter('alias/test1', "user/$uid/test1"); $this->assertUrlOutboundAlter("user/$uid/test1", 'alias/test1'); diff --git a/core/scripts/generate-d7-content.sh b/core/scripts/generate-d7-content.sh index 30c61a2bfb1c93dbf1099ec34fc493f74c555584..b00ab2769b763186c8bc3ee5a1c164b140fd3b39 100644 --- a/core/scripts/generate-d7-content.sh +++ b/core/scripts/generate-d7-content.sh @@ -252,7 +252,7 @@ 'alias' => "content/poll/$i/results", 'source' => "node/$node->nid/results", ); - \Drupal::service('path.crud')->save($path['source'], $path['alias']); + \Drupal::service('path.alias_storage')->save($path['source'], $path['alias']); // Add some votes $node = node_load($node->nid);