diff --git a/core/modules/ckeditor/src/Tests/CKEditorPluginManagerTest.php b/core/modules/ckeditor/src/Tests/CKEditorPluginManagerTest.php index d373e1a..94489ce 100644 --- a/core/modules/ckeditor/src/Tests/CKEditorPluginManagerTest.php +++ b/core/modules/ckeditor/src/Tests/CKEditorPluginManagerTest.php @@ -34,9 +34,6 @@ class CKEditorPluginManagerTest extends DrupalUnitTestBase { protected function setUp() { parent::setUp(); - // Install the Filter module. - $this->installSchema('system', 'url_alias'); - // Create text format, associate CKEditor. $filtered_html_format = entity_create('filter_format', array( 'format' => 'filtered_html', diff --git a/core/modules/ckeditor/src/Tests/CKEditorTest.php b/core/modules/ckeditor/src/Tests/CKEditorTest.php index 7041583..b4631b6 100644 --- a/core/modules/ckeditor/src/Tests/CKEditorTest.php +++ b/core/modules/ckeditor/src/Tests/CKEditorTest.php @@ -42,9 +42,6 @@ class CKEditorTest extends DrupalUnitTestBase { protected function setUp() { parent::setUp(); - // Install the Filter module. - $this->installSchema('system', 'url_alias'); - // Create text format, associate CKEditor. $filtered_html_format = entity_create('filter_format', array( 'format' => 'filtered_html', diff --git a/core/modules/editor/src/Tests/EditorManagerTest.php b/core/modules/editor/src/Tests/EditorManagerTest.php index b251f48..9420df9 100644 --- a/core/modules/editor/src/Tests/EditorManagerTest.php +++ b/core/modules/editor/src/Tests/EditorManagerTest.php @@ -34,9 +34,6 @@ class EditorManagerTest extends DrupalUnitTestBase { protected function setUp() { parent::setUp(); - // Install the Filter module. - $this->installSchema('system', 'url_alias'); - // Add text formats. $filtered_html_format = entity_create('filter_format', array( 'format' => 'filtered_html', diff --git a/core/modules/editor/src/Tests/QuickEditIntegrationTest.php b/core/modules/editor/src/Tests/QuickEditIntegrationTest.php index ee43da0..78623a9 100644 --- a/core/modules/editor/src/Tests/QuickEditIntegrationTest.php +++ b/core/modules/editor/src/Tests/QuickEditIntegrationTest.php @@ -67,9 +67,6 @@ class QuickEditIntegrationTest extends QuickEditTestBase { protected function setUp() { parent::setUp(); - // Install the Filter module. - $this->installSchema('system', 'url_alias'); - // Create a field. $this->field_name = 'field_textarea'; $this->createFieldWithStorage( diff --git a/core/modules/filter/src/Tests/FilterDefaultConfigTest.php b/core/modules/filter/src/Tests/FilterDefaultConfigTest.php index 79a1160..04e0894 100644 --- a/core/modules/filter/src/Tests/FilterDefaultConfigTest.php +++ b/core/modules/filter/src/Tests/FilterDefaultConfigTest.php @@ -20,11 +20,7 @@ class FilterDefaultConfigTest extends DrupalUnitTestBase { protected function setUp() { parent::setUp(); - - // Drupal\filter\FilterPermissions::permissions() calls into url() to output - // a link in the description. - $this->installSchema('system', 'url_alias'); - + $this->installEntitySchema('user'); // Install filter_test module, which ships with custom default format. diff --git a/core/modules/hal/src/Tests/NormalizerTestBase.php b/core/modules/hal/src/Tests/NormalizerTestBase.php index c03167a..09e7ba9 100644 --- a/core/modules/hal/src/Tests/NormalizerTestBase.php +++ b/core/modules/hal/src/Tests/NormalizerTestBase.php @@ -61,7 +61,7 @@ */ protected function setUp() { parent::setUp(); - $this->installSchema('system', array('url_alias', 'router')); + $this->installSchema('system', 'router'); $this->installEntitySchema('user'); $this->installEntitySchema('entity_test'); $this->installConfig(array('field', 'language')); diff --git a/core/modules/locale/src/Tests/LocalePathTest.php b/core/modules/locale/src/Tests/LocalePathTest.php index ae4b9db..675ea0c 100644 --- a/core/modules/locale/src/Tests/LocalePathTest.php +++ b/core/modules/locale/src/Tests/LocalePathTest.php @@ -73,7 +73,7 @@ public function testPathLanguageConfiguration() { $path = 'admin/config/search/path/add'; $english_path = $this->randomMachineName(8); $edit = array( - 'source' => 'node/' . $node->id(), + 'path' => 'node/' . $node->id(), 'alias' => $english_path, 'langcode' => 'en', ); @@ -82,7 +82,7 @@ public function testPathLanguageConfiguration() { // Create a path alias in new custom language. $custom_language_path = $this->randomMachineName(8); $edit = array( - 'source' => 'node/' . $node->id(), + 'path' => 'node/' . $node->id(), 'alias' => $custom_language_path, 'langcode' => $langcode, ); @@ -100,39 +100,49 @@ public function testPathLanguageConfiguration() { $custom_path = $this->randomMachineName(8); // Check priority of language for alias by source path. + /** @var $alias_storage \Drupal\Core\Path\AliasStorageInterface */ + $alias_storage = $this->container->get('entity.manager')->getStorage('alias'); $edit = array( - 'source' => 'node/' . $node->id(), + 'path' => 'node/' . $node->id(), 'alias' => $custom_path, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, ); - $this->container->get('path.alias_storage')->save($edit['source'], $edit['alias'], $edit['langcode']); + $alias = $alias_storage->create( + array( + 'path' => $edit['path'], + 'alias' => $edit['alias'], + 'langcode' => $edit['langcode'], + ) + ); $lookup_path = $this->container->get('path.alias_manager')->getAliasByPath('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')->getAliasByPath('node/' . $node->id(), $prefix); $this->assertEqual($custom_language_path, $lookup_path, 'Custom language alias has priority.'); - $this->container->get('path.alias_storage')->delete($edit); + $alias->delete(); // Create language nodes to check priority of aliases. $first_node = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1, 'langcode' => 'en')); $second_node = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED)); // Assign a custom path alias to the first node with the English language. - $edit = array( - 'source' => 'node/' . $first_node->id(), - 'alias' => $custom_path, - 'langcode' => $first_node->language()->id, - ); - $this->container->get('path.alias_storage')->save($edit['source'], $edit['alias'], $edit['langcode']); + $alias_storage->create( + array( + 'path' => 'node/' . $first_node->id(), + 'alias' => $custom_path, + 'langcode' => $first_node->language()->id, + ) + )->save(); // Assign a custom path alias to second node with // LanguageInterface::LANGCODE_NOT_SPECIFIED. - $edit = array( - 'source' => 'node/' . $second_node->id(), - 'alias' => $custom_path, - 'langcode' => $second_node->language()->id, - ); - $this->container->get('path.alias_storage')->save($edit['source'], $edit['alias'], $edit['langcode']); + $alias_storage->create( + array( + 'path' => 'node/' . $second_node->id(), + 'alias' => $custom_path, + 'langcode' => $second_node->language()->id, + ) + )->save(); // Test that both node titles link to our path alias. $this->drupalGet('admin/content'); diff --git a/core/modules/path/src/Controller/PathController.php b/core/modules/path/src/Controller/PathController.php index 4acfb41..7b404a2 100644 --- a/core/modules/path/src/Controller/PathController.php +++ b/core/modules/path/src/Controller/PathController.php @@ -64,12 +64,12 @@ public function adminOverview($keys) { $destination = drupal_get_destination(); foreach ($this->entityManager()->getStorage('alias')->getAliasesForAdminListing($header, $keys) as $data) { $row = array(); - $row['data']['alias'] = l(truncate_utf8($data->alias, 50, FALSE, TRUE), $data->source, array( + $row['data']['alias'] = l(truncate_utf8($data->alias, 50, FALSE, TRUE), $data->path, array( 'attributes' => array('title' => $data->alias), )); - $row['data']['source'] = l(truncate_utf8($data->source, 50, FALSE, TRUE), $data->source, array( + $row['data']['source'] = l(truncate_utf8($data->path, 50, FALSE, TRUE), $data->path, array( 'alias' => TRUE, - 'attributes' => array('title' => $data->source), + 'attributes' => array('title' => $data->path), )); if ($multilanguage) { $row['data']['language_name'] = $this->languageManager()->getLanguageName($data->langcode); @@ -80,7 +80,7 @@ public function adminOverview($keys) { 'title' => $this->t('Edit'), 'route_name' => 'path.admin_edit', 'route_parameters' => array( - 'pid' => $data->pid, + 'pid' => $data->aid, ), 'query' => $destination, ); @@ -88,7 +88,7 @@ public function adminOverview($keys) { 'title' => $this->t('Delete'), 'route_name' => 'path.delete', 'route_parameters' => array( - 'pid' => $data->pid, + 'pid' => $data->aid, ), 'query' => $destination, ); @@ -101,7 +101,7 @@ public function adminOverview($keys) { // If the system path maps to a different URL alias, highlight this table // row to let the user know of old aliases. - if ($data->alias != $this->aliasManager->getAliasByPath($data->source, $data->langcode)) { + if ($data->alias != $this->aliasManager->getAliasByPath($data->path, $data->langcode)) { $row['class'] = array('warning'); } diff --git a/core/modules/path/src/Form/AddForm.php b/core/modules/path/src/Form/AddForm.php index aab238b..0787347 100644 --- a/core/modules/path/src/Form/AddForm.php +++ b/core/modules/path/src/Form/AddForm.php @@ -24,13 +24,12 @@ public function getFormId() { /** * {@inheritdoc} */ - protected function buildPath($pid) { - return array( - 'source' => '', + protected function buildPath($aid) { + return $this->entityManager->getStorage('alias')->create(array( + 'path' => '', 'alias' => '', 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, - 'pid' => NULL, - ); + )); } } diff --git a/core/modules/path/src/Form/EditForm.php b/core/modules/path/src/Form/EditForm.php index 95d5e20..f4d647e 100644 --- a/core/modules/path/src/Form/EditForm.php +++ b/core/modules/path/src/Form/EditForm.php @@ -26,20 +26,20 @@ public function getFormId() { /** * {@inheritdoc} */ - protected function buildPath($pid) { - return $this->aliasStorage->load(array('pid' => $pid)); + protected function buildPath($aid) { + return $this->entityManager->getStorage('alias')->load($aid); } /** * {@inheritdoc} */ - public function buildForm(array $form, FormStateInterface $form_state, $pid = NULL) { - $form = parent::buildForm($form, $form_state, $pid); + public function buildForm(array $form, FormStateInterface $form_state, $aid = NULL) { + $form = parent::buildForm($form, $form_state, $aid); - $form['#title'] = String::checkPlain($this->path['alias']); - $form['pid'] = array( + $form['#title'] = String::checkPlain($this->alias->get('alias')); + $form['aid'] = array( '#type' => 'hidden', - '#value' => $this->path['pid'], + '#value' => $this->alias->id(), ); $form['actions']['delete'] = array( '#type' => 'submit', @@ -54,7 +54,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $pid = NU */ public function deleteSubmit(array &$form, FormStateInterface $form_state) { $url = new Url('path.delete', array( - 'pid' => $form_state->getValue('pid'), + 'aid' => $form_state->getValue('aid'), )); if ($this->getRequest()->query->has('destination')) { diff --git a/core/modules/path/src/Form/PathFormBase.php b/core/modules/path/src/Form/PathFormBase.php index 45c8e96..4f0836a 100644 --- a/core/modules/path/src/Form/PathFormBase.php +++ b/core/modules/path/src/Form/PathFormBase.php @@ -22,11 +22,11 @@ abstract class PathFormBase extends FormBase { /** - * An array containing the path ID, source, alias, and language code. + * Path alias object * - * @var array + * @var \Drupal\Core\Path\AliasInterface */ - protected $path; + protected $alias; /** * The entity manager service. @@ -77,22 +77,22 @@ public static function create(ContainerInterface $container) { } /** - * Builds the path used by the form. + * Builds the alias object used by the form. * - * @param int|null $pid - * Either the unique path ID, or NULL if a new one is being created. + * @param int|null $aid + * Either the unique alias ID, or NULL if a new one is being created. */ - abstract protected function buildPath($pid); + abstract protected function buildPath($aid); /** * {@inheritdoc} */ - public function buildForm(array $form, FormStateInterface $form_state, $pid = NULL) { - $this->path = $this->buildPath($pid); - $form['source'] = array( + public function buildForm(array $form, FormStateInterface $form_state, $aid = NULL) { + $this->alias = $this->buildPath($aid); + $form['path'] = array( '#type' => 'textfield', '#title' => $this->t('Existing system path'), - '#default_value' => $this->path['source'], + '#default_value' => $this->alias->get('path')->value, '#maxlength' => 255, '#size' => 45, '#description' => $this->t('Specify the existing path you wish to alias. For example: node/28, forum/1, taxonomy/term/1.'), @@ -102,7 +102,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $pid = NU $form['alias'] = array( '#type' => 'textfield', '#title' => $this->t('Path alias'), - '#default_value' => $this->path['alias'], + '#default_value' => $this->alias->get('alias')->value, '#maxlength' => 255, '#size' => 45, '#description' => $this->t('Specify an alternative path by which this data can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'), @@ -124,7 +124,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $pid = NU '#options' => $language_options, '#empty_value' => LanguageInterface::LANGCODE_NOT_SPECIFIED, '#empty_option' => $this->t('- None -'), - '#default_value' => $this->path['langcode'], + '#default_value' => $this->alias->get('langcode')->value, '#weight' => -10, '#description' => $this->t('A path alias set for a specific language will always be used when displaying this page in that language, and takes precedence over path aliases set as - None -.'), ); @@ -132,7 +132,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $pid = NU else { $form['langcode'] = array( '#type' => 'value', - '#value' => $this->path['langcode'] + '#value' => $this->alias->get('langcode')->value ); } @@ -149,18 +149,18 @@ public function buildForm(array $form, FormStateInterface $form_state, $pid = NU * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { - $source = &$form_state->getValue('source'); - $source = $this->aliasManager->getPathByAlias($source); + $path = &$form_state->getValue('path'); + $path = $this->aliasManager->getPathByAlias($path); $alias = $form_state->getValue('alias'); // Language is only set if language.module is enabled, otherwise save for all // languages. $langcode = $form_state->getValue('langcode', LanguageInterface::LANGCODE_NOT_SPECIFIED); - if ($this->entityManager->getStorage('alias')->aliasExists($alias, $langcode, $source)) { + if ($this->entityManager->getStorage('alias')->aliasExists($alias, $langcode, $path)) { $form_state->setErrorByName('alias', t('The alias %alias is already in use in this language.', array('%alias' => $alias))); } - if (!$this->pathValidator->isValid($source)) { - $form_state->setErrorByName('source', t("The path '@link_path' is either invalid or you do not have access to it.", array('@link_path' => $source))); + if (!$this->pathValidator->isValid($path)) { + $form_state->setErrorByName('path', t("The path '@link_path' is either invalid or you do not have access to it.", array('@link_path' => $source))); } } @@ -172,8 +172,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $form_state->cleanValues(); $aid = $form_state->getValue('aid', 0); - $source = &$form_state->getValue('source'); - $source = $this->aliasManager->getPathByAlias($source); + $path = &$form_state->getValue('path'); + $path = $this->aliasManager->getPathByAlias($path); $alias = $form_state->getValue('alias'); // Language is only set if language.module is enabled, otherwise save for all // languages. @@ -183,7 +183,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $alias = $this->entityManager->getStorage('alias')->create( array( 'alias' => $alias, - 'path' => $source, + 'path' => $path, 'langcode' => $langcode, ) ); @@ -191,7 +191,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { } else { $alias = $this->entityManager->getStorage('alias')->load($aid); - $alias->path = $source; + $alias->path = $path; $alias->alias = $alias; $alias->langcode = $langcode; $alias->save(); diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 54deb65..717680b 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -1292,22 +1292,22 @@ function system_block_view_system_help_block_alter(array &$build, BlockPluginInt } /** - * Implements hook_path_update(). + * Implements hook_ENTITY_TYPE_update(). */ -function system_path_update() { +function system_alias_update() { \Drupal::service('path.alias_manager')->cacheClear(); } /** - * Implements hook_path_insert(). + * Implements hook_ENTITY_TYPE_insert(). */ -function system_path_insert() { +function system_alias_insert() { \Drupal::service('path.alias_manager')->cacheClear(); } /** - * Implements hook_path_delete(). + * Implements hook_ENTITY_TYPE_delete(). */ -function system_path_delete($path) { +function system_alias_delete() { \Drupal::service('path.alias_manager')->cacheClear(); } diff --git a/core/modules/system/tests/modules/path_test/path_test.module b/core/modules/system/tests/modules/path_test/path_test.module index df03931..ea72f3c 100644 --- a/core/modules/system/tests/modules/path_test/path_test.module +++ b/core/modules/system/tests/modules/path_test/path_test.module @@ -13,10 +13,10 @@ function path_test_reset() { } /** - * Implements hook_path_update(). + * Implements hook_ENTITY_TYPE_update(). */ -function path_test_path_update($path) { +function path_test_alias_update($alias) { $results = \Drupal::state()->get('path_test.results') ?: array(); - $results['hook_path_update'] = $path; + $results['hook_path_update'] = $alias; \Drupal::state()->set('path_test.results', $results); }