Commit 719b36a4 authored by alexpott's avatar alexpott

Issue #2208631 by slashrsm: Rename \Drupal\Core\Path\Path to \Drupal\Core\Path\AliasStorage.

parent ef256397
...@@ -149,7 +149,7 @@ services: ...@@ -149,7 +149,7 @@ services:
arguments: [path_alias_whitelist, '@cache.default', '@lock', '@state', '@database'] arguments: [path_alias_whitelist, '@cache.default', '@lock', '@state', '@database']
path.alias_manager: path.alias_manager:
class: Drupal\Core\Path\AliasManager 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: http_client_simpletest_subscriber:
class: Drupal\Core\Http\Plugin\SimpletestHttpRequestSubscriber class: Drupal\Core\Http\Plugin\SimpletestHttpRequestSubscriber
http_default_client: http_default_client:
...@@ -353,8 +353,8 @@ services: ...@@ -353,8 +353,8 @@ services:
path.alias_manager.cached: path.alias_manager.cached:
class: Drupal\Core\CacheDecorator\AliasManagerCacheDecorator class: Drupal\Core\CacheDecorator\AliasManagerCacheDecorator
arguments: ['@path.alias_manager', '@cache.data'] arguments: ['@path.alias_manager', '@cache.data']
path.crud: path.alias_storage:
class: Drupal\Core\Path\Path class: Drupal\Core\Path\AliasStorage
arguments: ['@database', '@module_handler'] arguments: ['@database', '@module_handler']
# The argument to the hashing service defined in services.yml, to the # The argument to the hashing service defined in services.yml, to the
# constructor of PhpassHashedPassword is the log2 number of iterations for # constructor of PhpassHashedPassword is the log2 number of iterations for
......
...@@ -115,7 +115,7 @@ function path_load($conditions) { ...@@ -115,7 +115,7 @@ function path_load($conditions) {
elseif (!is_array($conditions)) { elseif (!is_array($conditions)) {
return FALSE; return FALSE;
} }
return \Drupal::service('path.crud')->load($conditions); return \Drupal::service('path.alias_storage')->load($conditions);
} }
/** /**
......
...@@ -13,11 +13,11 @@ ...@@ -13,11 +13,11 @@
class AliasManager implements AliasManagerInterface { 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. * Language manager for retrieving the default langcode when none is specified.
...@@ -74,15 +74,15 @@ class AliasManager implements AliasManagerInterface { ...@@ -74,15 +74,15 @@ class AliasManager implements AliasManagerInterface {
/** /**
* Constructs an AliasManager. * Constructs an AliasManager.
* *
* @param \Drupal\Core\Path\PathInterface $path * @param \Drupal\Core\Path\AliasStorageInterface $storage
* The Path CRUD service. * The alias storage service.
* @param \Drupal\Core\Path\AliasWhitelistInterface $whitelist * @param \Drupal\Core\Path\AliasWhitelistInterface $whitelist
* The whitelist implementation to use. * The whitelist implementation to use.
* @param \Drupal\Core\Language\LanguageManager $language_manager * @param \Drupal\Core\Language\LanguageManager $language_manager
* The language manager. * The language manager.
*/ */
public function __construct(PathInterface $path, AliasWhitelistInterface $whitelist, LanguageManager $language_manager) { public function __construct(AliasStorageInterface $storage, AliasWhitelistInterface $whitelist, LanguageManager $language_manager) {
$this->path = $path; $this->storage = $storage;
$this->languageManager = $language_manager; $this->languageManager = $language_manager;
$this->whitelist = $whitelist; $this->whitelist = $whitelist;
} }
...@@ -180,7 +180,7 @@ protected function lookupPathAlias($path, $langcode) { ...@@ -180,7 +180,7 @@ protected function lookupPathAlias($path, $langcode) {
// Load system paths from cache. // Load system paths from cache.
if (!empty($this->preloadedPathLookups)) { if (!empty($this->preloadedPathLookups)) {
// Now fetch the aliases corresponding to these system paths. // 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. // 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]))); $this->noAliases[$langcode] = array_flip(array_diff_key($this->preloadedPathLookups, array_keys($this->lookupMap[$langcode])));
} }
...@@ -197,7 +197,7 @@ protected function lookupPathAlias($path, $langcode) { ...@@ -197,7 +197,7 @@ protected function lookupPathAlias($path, $langcode) {
} }
// For system paths which were not cached, query aliases individually. // For system paths which were not cached, query aliases individually.
elseif (!isset($this->noAliases[$langcode][$path])) { 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 $this->lookupMap[$langcode][$path];
} }
return FALSE; return FALSE;
...@@ -222,7 +222,7 @@ protected function lookupPathSource($path, $langcode) { ...@@ -222,7 +222,7 @@ protected function lookupPathSource($path, $langcode) {
// Look for the value $path within the cached $map // Look for the value $path within the cached $map
$source = isset($this->lookupMap[$langcode]) ? array_search($path, $this->lookupMap[$langcode]) : FALSE; $source = isset($this->lookupMap[$langcode]) ? array_search($path, $this->lookupMap[$langcode]) : FALSE;
if (!$source) { if (!$source) {
if ($source = $this->path->lookupPathSource($path, $langcode)) { if ($source = $this->storage->lookupPathSource($path, $langcode)) {
$this->lookupMap[$langcode][$source] = $path; $this->lookupMap[$langcode][$source] = $path;
} }
else { else {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Path\Path. * Contains \Drupal\Core\Path\AliasStorage.
*/ */
namespace Drupal\Core\Path; namespace Drupal\Core\Path;
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
/** /**
* Provides a class for CRUD operations on path aliases. * Provides a class for CRUD operations on path aliases.
*/ */
class Path implements PathInterface { class AliasStorage implements AliasStorageInterface {
/** /**
* The database connection. * The database connection.
* *
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* @file * @file
* Contains \Drupal\Core\Path\PathInterface. * Contains \Drupal\Core\Path\AliasStorageInterface.
*/ */
namespace Drupal\Core\Path; namespace Drupal\Core\Path;
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
/** /**
* Provides a class for CRUD operations on path aliases. * Provides a class for CRUD operations on path aliases.
*/ */
interface PathInterface { interface AliasStorageInterface {
/** /**
* Saves a path alias to the database. * Saves a path alias to the database.
......
...@@ -83,7 +83,7 @@ public function submitForm(array &$form, array &$form_state) { ...@@ -83,7 +83,7 @@ public function submitForm(array &$form, array &$form_state) {
if (\Drupal::moduleHandler()->moduleExists('path')) { if (\Drupal::moduleHandler()->moduleExists('path')) {
$path = $this->entity->getSystemPath(); $path = $this->entity->getSystemPath();
$conditions = array('source' => $path, 'langcode' => $this->language->id); $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(); $form_state['redirect_route'] = $this->getCancelRoute();
......
...@@ -108,13 +108,13 @@ function testPathLanguageConfiguration() { ...@@ -108,13 +108,13 @@ function testPathLanguageConfiguration() {
'alias' => $custom_path, 'alias' => $custom_path,
'langcode' => Language::LANGCODE_NOT_SPECIFIED, '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'); $lookup_path = $this->container->get('path.alias_manager')->getPathAlias('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')->getPathAlias('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.crud')->delete($edit); $this->container->get('path.alias_storage')->delete($edit);
// Create language nodes to check priority of aliases. // Create language nodes to check priority of aliases.
$first_node = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1, 'langcode' => 'en')); $first_node = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1, 'langcode' => 'en'));
...@@ -126,7 +126,7 @@ function testPathLanguageConfiguration() { ...@@ -126,7 +126,7 @@ function testPathLanguageConfiguration() {
'alias' => $custom_path, 'alias' => $custom_path,
'langcode' => $first_node->language()->id, '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. // Assign a custom path alias to second node with Language::LANGCODE_NOT_SPECIFIED.
$edit = array( $edit = array(
...@@ -134,7 +134,7 @@ function testPathLanguageConfiguration() { ...@@ -134,7 +134,7 @@ function testPathLanguageConfiguration() {
'alias' => $custom_path, 'alias' => $custom_path,
'langcode' => $second_node->language()->id, '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. // Test that both node titles link to our path alias.
$this->drupalGet('<front>'); $this->drupalGet('<front>');
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
namespace Drupal\migrate\Plugin\migrate\destination; namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\Core\Path\PathInterface; use Drupal\Core\Path\AliasStorage;
use Drupal\migrate\Entity\MigrationInterface; use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Row; use Drupal\migrate\Row;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
...@@ -21,11 +21,11 @@ ...@@ -21,11 +21,11 @@
class UrlAlias extends DestinationBase implements ContainerFactoryPluginInterface { 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. * Constructs an entity destination plugin.
...@@ -38,12 +38,12 @@ class UrlAlias extends DestinationBase implements ContainerFactoryPluginInterfac ...@@ -38,12 +38,12 @@ class UrlAlias extends DestinationBase implements ContainerFactoryPluginInterfac
* The plugin implementation definition. * The plugin implementation definition.
* @param MigrationInterface $migration * @param MigrationInterface $migration
* The migration. * The migration.
* @param \Drupal\Core\Path\PathInterface $path * @param \Drupal\Core\Path\AliasStorage $alias_storage
* The path crud service. * 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); 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 ...@@ -55,7 +55,7 @@ public static function create(ContainerInterface $container, array $configuratio
$plugin_id, $plugin_id,
$plugin_definition, $plugin_definition,
$migration, $migration,
$container->get('path.crud') $container->get('path.alias_storage')
); );
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
namespace Drupal\path\Form; namespace Drupal\path\Form;
use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Path\PathInterface; use Drupal\Core\Path\AliasStorageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
...@@ -17,11 +17,11 @@ ...@@ -17,11 +17,11 @@
class DeleteForm extends ConfirmFormBase { 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. * The path alias being deleted.
...@@ -33,11 +33,11 @@ class DeleteForm extends ConfirmFormBase { ...@@ -33,11 +33,11 @@ class DeleteForm extends ConfirmFormBase {
/** /**
* Constructs a \Drupal\path\Form\DeleteForm object. * Constructs a \Drupal\path\Form\DeleteForm object.
* *
* @param \Drupal\Core\Path\PathInterface $path * @param \Drupal\Core\Path\AliasStorageInterface $alias_storage
* The path crud service. * The alias storage service.
*/ */
public function __construct(PathInterface $path) { public function __construct(AliasStorageInterface $alias_storage) {
$this->path = $path; $this->aliasStorage = $alias_storage;
} }
/** /**
...@@ -45,7 +45,7 @@ public function __construct(PathInterface $path) { ...@@ -45,7 +45,7 @@ public function __construct(PathInterface $path) {
*/ */
public static function create(ContainerInterface $container) { public static function create(ContainerInterface $container) {
return new static( return new static(
$container->get('path.crud') $container->get('path.alias_storage')
); );
} }
...@@ -73,7 +73,7 @@ public function getCancelRoute() { ...@@ -73,7 +73,7 @@ public function getCancelRoute() {
* Overrides \Drupal\Core\Form\ConfirmFormBase::buildForm(). * Overrides \Drupal\Core\Form\ConfirmFormBase::buildForm().
*/ */
public function buildForm(array $form, array &$form_state, $pid = NULL) { 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); $form = parent::buildForm($form, $form_state);
...@@ -86,7 +86,7 @@ public function buildForm(array $form, array &$form_state, $pid = NULL) { ...@@ -86,7 +86,7 @@ public function buildForm(array $form, array &$form_state, $pid = NULL) {
* Implements \Drupal\Core\Form\FormInterface::submitForm(). * Implements \Drupal\Core\Form\FormInterface::submitForm().
*/ */
public function submitForm(array &$form, array &$form_state) { 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'; $form_state['redirect'] = 'admin/config/search/path';
} }
......
...@@ -58,7 +58,7 @@ public function insert() { ...@@ -58,7 +58,7 @@ public function insert() {
// Ensure fields for programmatic executions. // Ensure fields for programmatic executions.
$langcode = $entity->language()->id; $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']; $this->pid = $path['pid'];
} }
} }
...@@ -70,7 +70,7 @@ public function insert() { ...@@ -70,7 +70,7 @@ public function insert() {
public function update() { public function update() {
// Delete old alias if user erased it. // Delete old alias if user erased it.
if ($this->pid && !$this->alias) { 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. // Only save a non-empty alias.
elseif ($this->alias) { elseif ($this->alias) {
...@@ -79,7 +79,7 @@ public function update() { ...@@ -79,7 +79,7 @@ public function update() {
// Ensure fields for programmatic executions. // Ensure fields for programmatic executions.
$langcode = $entity->language()->id; $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() { ...@@ -89,7 +89,7 @@ public function update() {
public function delete() { public function delete() {
// Delete all aliases associated with this entity. // Delete all aliases associated with this entity.
$entity = $this->getEntity(); $entity = $this->getEntity();
\Drupal::service('path.crud')->delete(array('source' => $entity->getSystemPath())); \Drupal::service('path.alias_storage')->delete(array('source' => $entity->getSystemPath()));
} }
} }
...@@ -268,7 +268,7 @@ function path_admin_form_submit($form, &$form_state) { ...@@ -268,7 +268,7 @@ function path_admin_form_submit($form, &$form_state) {
// languages. // languages.
$langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : Language::LANGCODE_NOT_SPECIFIED; $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.')); drupal_set_message(t('The alias has been saved.'));
$form_state['redirect'] = 'admin/config/search/path'; $form_state['redirect'] = 'admin/config/search/path';
......
...@@ -67,7 +67,7 @@ function path_form_node_form_alter(&$form, $form_state) { ...@@ -67,7 +67,7 @@ function path_form_node_form_alter(&$form, $form_state) {
if ($node->language()->id != Language::LANGCODE_NOT_SPECIFIED) { if ($node->language()->id != Language::LANGCODE_NOT_SPECIFIED) {
$conditions['langcode'] = $node->language()->id; $conditions['langcode'] = $node->language()->id;
} }
$path = \Drupal::service('path.crud')->load($conditions); $path = \Drupal::service('path.alias_storage')->load($conditions);
if ($path === FALSE) { if ($path === FALSE) {
$path = array(); $path = array();
} }
...@@ -153,7 +153,7 @@ function path_form_taxonomy_term_form_alter(&$form, $form_state) { ...@@ -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. // Make sure this does not show up on the delete confirmation form.
if (empty($form_state['confirm_delete'])) { if (empty($form_state['confirm_delete'])) {
$term = $form_state['controller']->getEntity(); $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) { if ($path === FALSE) {
$path = array(); $path = array();
} }
......
...@@ -38,7 +38,7 @@ public function testShortcutLinkAdd() { ...@@ -38,7 +38,7 @@ public function testShortcutLinkAdd() {
'source' => 'node/' . $this->node->id(), 'source' => 'node/' . $this->node->id(),
'alias' => $this->randomName(8), '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. // Create some paths to test.
$test_cases = array( $test_cases = array(
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
namespace Drupal\system\Tests\Path; namespace Drupal\system\Tests\Path;
use Drupal\Core\Cache\MemoryCounterBackend; use Drupal\Core\Cache\MemoryCounterBackend;
use Drupal\Core\Path\Path; use Drupal\Core\Path\AliasStorage;
use Drupal\Core\Database\Database; use Drupal\Core\Database\Database;
use Drupal\Core\Path\AliasManager; use Drupal\Core\Path\AliasManager;
use Drupal\Core\Path\AliasWhitelist; use Drupal\Core\Path\AliasWhitelist;
...@@ -32,13 +32,13 @@ function testCRUD() { ...@@ -32,13 +32,13 @@ function testCRUD() {
$this->fixtures->createTables($connection); $this->fixtures->createTables($connection);
//Create Path object. //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(); $aliases = $this->fixtures->sampleUrlAliases();
//Create a few aliases //Create a few aliases
foreach ($aliases as $idx => $alias) { 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'])); $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(); $rows = $result->fetchAll();
...@@ -52,13 +52,13 @@ function testCRUD() { ...@@ -52,13 +52,13 @@ function testCRUD() {
//Load a few aliases //Load a few aliases
foreach ($aliases as $alias) { foreach ($aliases as $alias) {
$pid = $alias['pid']; $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))); $this->assertEqual($loadedAlias, $alias, format_string('Loaded the expected path with pid %pid.', array('%pid' => $pid)));
} }
//Update a few aliases //Update a few aliases
foreach ($aliases as $alias) { 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'])); $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(); $pid = $result->fetchField();
...@@ -69,7 +69,7 @@ function testCRUD() { ...@@ -69,7 +69,7 @@ function testCRUD() {
//Delete a few aliases //Delete a few aliases
foreach ($aliases as $alias) { foreach ($aliases as $alias) {
$pid = $alias['pid']; $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)); $result = $connection->query('SELECT * FROM {url_alias} WHERE pid = :pid', array(':pid' => $pid));
$rows = $result->fetchAll(); $rows = $result->fetchAll();
...@@ -85,7 +85,7 @@ function testLookupPath() { ...@@ -85,7 +85,7 @@ function testLookupPath() {
//Create AliasManager and Path object. //Create AliasManager and Path object.
$aliasManager = $this->container->get('path.alias_manager.cached'); $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. // Test the situation where the source is the same for multiple aliases.
// Start with a language-neutral alias, which we will override. // Start with a language-neutral alias, which we will override.
...@@ -94,7 +94,7 @@ function testLookupPath() { ...@@ -94,7 +94,7 @@ function testLookupPath() {
'alias' => 'foo', '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->getPathAlias($path['source']), $path['alias'], 'Basic alias lookup works.');
$this->assertEqual($aliasManager->getSystemPath($path['alias']), $path['source'], 'Basic source lookup works.'); $this->assertEqual($aliasManager->getSystemPath($path['alias']), $path['source'], 'Basic source lookup works.');
...@@ -104,7 +104,7 @@ function testLookupPath() { ...@@ -104,7 +104,7 @@ function testLookupPath() {
'alias' => "users/Dries", 'alias' => "users/Dries",
'langcode' => 'en', '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. // Hook that clears cache is not executed with unit tests.
\Drupal::service('path.alias_manager.cached')->cacheClear(); \Drupal::service('path.alias_manager.cached')->cacheClear();
$this->assertEqual($aliasManager->getPathAlias($path['source']), $path['alias'], 'English alias overrides language-neutral alias.'); $this->assertEqual($aliasManager->getPathAlias($path['source']), $path['alias'], 'English alias overrides language-neutral alias.');
...@@ -115,7 +115,7 @@ function testLookupPath() { ...@@ -115,7 +115,7 @@ function testLookupPath() {
'source' => "user/1", 'source' => "user/1",
'alias' => 'bar', '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.'); $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. // Create a language-specific (xx-lolspeak) alias for the same path.
...@@ -124,7 +124,7 @@ function testLookupPath() { ...@@ -124,7 +124,7 @@ function testLookupPath() {
'alias' => 'LOL', 'alias' => 'LOL',
'langcode' => 'xx-lolspeak', '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.'); $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. // 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.'); $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() { ...@@ -136,7 +136,7 @@ function testLookupPath() {
'alias' => 'users/my-new-path', 'alias' => 'users/my-new-path',
'langcode' => 'en', '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. // Hook that clears cache is not executed with unit tests.
$aliasManager->cacheClear(); $aliasManager->cacheClear();
$this->assertEqual($aliasManager->getPathAlias($path['source']), $path['alias'], 'Recently created English alias returned.'); $this->assertEqual($aliasManager->getPathAlias($path['source']), $path['alias'], 'Recently created English alias returned.');
...@@ -144,14 +144,14 @@ function testLookupPath() { ...@@ -144,14 +144,14 @@ function testLookupPath() {
// Remove the English aliases, which should cause a fallback to the most // Remove the English aliases, which should cause a fallback to the most
// recently created language-neutral alias, 'bar'. // 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.