Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
|
@ -1,12 +1,11 @@
|
|||
id: d6_url_alias
|
||||
label: Drupal 6 URL aliases
|
||||
label: URL aliases
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_url_alias
|
||||
constants:
|
||||
slash: '/'
|
||||
|
||||
process:
|
||||
source:
|
||||
plugin: concat
|
||||
|
|
22
core/modules/path/migration_templates/d7_url_alias.yml
Normal file
22
core/modules/path/migration_templates/d7_url_alias.yml
Normal file
|
@ -0,0 +1,22 @@
|
|||
id: d7_url_alias
|
||||
label: URL aliases
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: d7_url_alias
|
||||
constants:
|
||||
slash: '/'
|
||||
process:
|
||||
source:
|
||||
plugin: concat
|
||||
source:
|
||||
- constants/slash
|
||||
- source
|
||||
alias:
|
||||
plugin: concat
|
||||
source:
|
||||
- constants/slash
|
||||
- alias
|
||||
langcode: language
|
||||
destination:
|
||||
plugin: url_alias
|
|
@ -17,7 +17,7 @@
|
|||
Drupal.behaviors.pathDetailsSummaries = {
|
||||
attach: function (context) {
|
||||
$(context).find('.path-form').drupalSetSummary(function (context) {
|
||||
var path = $('.form-item-path-0-alias input').val();
|
||||
var path = $('.js-form-item-path-0-alias input').val();
|
||||
|
||||
return path ?
|
||||
Drupal.t('Alias: @alias', {'@alias': path}) :
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
path.admin_overview:
|
||||
title: 'URL aliases'
|
||||
description: 'Change your site''s URL paths by aliasing them.'
|
||||
description: 'Add custom URLs to existing paths.'
|
||||
route_name: path.admin_overview
|
||||
parent: system.admin_config_search
|
||||
weight: -5
|
||||
|
|
|
@ -20,13 +20,13 @@ function path_help($route_name, RouteMatchInterface $route_match) {
|
|||
case 'help.page.path':
|
||||
$output = '';
|
||||
$output .= '<h3>' . t('About') . '</h3>';
|
||||
$output .= '<p>' . t('The Path module allows you to specify an alias, or custom URL, for any existing internal system path. Aliases should not be confused with URL redirects, which allow you to forward a changed or inactive URL to a new URL. In addition to making URLs more readable, aliases also help search engines index content more effectively. Multiple aliases may be used for a single internal system path. To automate the aliasing of paths, you can install the contributed module <a href="!pathauto">Pathauto</a>. For more information, see the <a href="!path">online documentation for the Path module</a>.', array('!path' => 'https://www.drupal.org/documentation/modules/path', '!pathauto' => 'https://www.drupal.org/project/pathauto')) . '</p>';
|
||||
$output .= '<p>' . t('The Path module allows you to specify an alias, or custom URL, for any existing internal system path. Aliases should not be confused with URL redirects, which allow you to forward a changed or inactive URL to a new URL. In addition to making URLs more readable, aliases also help search engines index content more effectively. Multiple aliases may be used for a single internal system path. To automate the aliasing of paths, you can install the contributed module <a href=":pathauto">Pathauto</a>. For more information, see the <a href=":path">online documentation for the Path module</a>.', array(':path' => 'https://www.drupal.org/documentation/modules/path', ':pathauto' => 'https://www.drupal.org/project/pathauto')) . '</p>';
|
||||
$output .= '<h3>' . t('Uses') . '</h3>';
|
||||
$output .= '<dl>';
|
||||
$output .= '<dt>' . t('Creating aliases') . '</dt>';
|
||||
$output .= '<dd>' . t('If you create or edit a taxonomy term you can add an alias (for example <em>music/jazz</em>) in the field "URL alias". When creating or editing content you can add an alias (for example <em>about-us/team</em>) under the section "URL path settings" in the field "URL alias". Aliases for any other path can be added through the page <a href="!aliases">URL aliases</a>. To add aliases a user needs the permission <a href="!permissions">Create and edit URL aliases</a>.', array('!aliases' => \Drupal::url('path.admin_overview'), '!permissions' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-path')))) . '</dd>';
|
||||
$output .= '<dd>' . t('If you create or edit a taxonomy term you can add an alias (for example <em>music/jazz</em>) in the field "URL alias". When creating or editing content you can add an alias (for example <em>about-us/team</em>) under the section "URL path settings" in the field "URL alias". Aliases for any other path can be added through the page <a href=":aliases">URL aliases</a>. To add aliases a user needs the permission <a href=":permissions">Create and edit URL aliases</a>.', array(':aliases' => \Drupal::url('path.admin_overview'), ':permissions' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-path')))) . '</dd>';
|
||||
$output .= '<dt>' . t('Managing aliases') . '</dt>';
|
||||
$output .= '<dd>' . t('The Path module provides a way to search and view a <a href="!aliases">list of all aliases</a> that are in use on your website. Aliases can be added, edited and deleted through this list.', array('!aliases' => \Drupal::url('path.admin_overview'))) . '</dd>';
|
||||
$output .= '<dd>' . t('The Path module provides a way to search and view a <a href=":aliases">list of all aliases</a> that are in use on your website. Aliases can be added, edited and deleted through this list.', array(':aliases' => \Drupal::url('path.admin_overview'))) . '</dd>';
|
||||
$output .= '</dl>';
|
||||
return $output;
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ class PathController extends ControllerBase {
|
|||
'#type' => 'table',
|
||||
'#header' => $header,
|
||||
'#rows' => $rows,
|
||||
'#empty' => $this->t('No URL aliases available. <a href="@link">Add URL alias</a>.', array('@link' => $this->url('path.admin_add'))),
|
||||
'#empty' => $this->t('No URL aliases available. <a href=":link">Add URL alias</a>.', array(':link' => $this->url('path.admin_add'))),
|
||||
);
|
||||
$build['path_pager'] = array('#type' => 'pager');
|
||||
|
||||
|
|
42
core/modules/path/src/Plugin/migrate/source/UrlAliasBase.php
Normal file
42
core/modules/path/src/Plugin/migrate/source/UrlAliasBase.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\path\Plugin\migrate\source\UrlAliasBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\path\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Base class for the url_alias source plugins.
|
||||
*/
|
||||
abstract class UrlAliasBase extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->select('url_alias', 'ua')->fields('ua');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'pid' => $this->t('The numeric identifier of the path alias.'),
|
||||
'language' => $this->t('The language code of the url alias.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['pid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -7,46 +7,26 @@
|
|||
|
||||
namespace Drupal\path\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
use Drupal\path\Plugin\migrate\source\UrlAliasBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 url aliases source from database.
|
||||
* URL aliases source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_url_alias"
|
||||
* id = "d6_url_alias",
|
||||
* source_provider = "path"
|
||||
* )
|
||||
*/
|
||||
class UrlAlias extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('url_alias', 'ua')
|
||||
->fields('ua', array('pid', 'src', 'dst', 'language'));
|
||||
$query->orderBy('pid');
|
||||
|
||||
return $query;
|
||||
}
|
||||
class UrlAlias extends UrlAliasBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'pid' => $this->t('The numeric identifier of the path alias.'),
|
||||
'src' => $this->t('The internal path.'),
|
||||
'dst' => $this->t('The user set path alias.'),
|
||||
'language' => $this->t('The language code of the url alias.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['pid']['type'] = 'integer';
|
||||
return $ids;
|
||||
$fields = parent::fields();
|
||||
$fields['src'] = $this->t('The internal system path.');
|
||||
$fields['dst'] = $this->t('The path alias.');
|
||||
return $fields;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
32
core/modules/path/src/Plugin/migrate/source/d7/UrlAlias.php
Normal file
32
core/modules/path/src/Plugin/migrate/source/d7/UrlAlias.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\path\Plugin\migrate\source\d7\UrlAlias.
|
||||
*/
|
||||
|
||||
namespace Drupal\path\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\path\Plugin\migrate\source\UrlAliasBase;
|
||||
|
||||
/**
|
||||
* URL aliases source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_url_alias",
|
||||
* source_provider = "path"
|
||||
* )
|
||||
*/
|
||||
class UrlAlias extends UrlAliasBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
$fields = parent::fields();
|
||||
$fields['source'] = $this->t('The internal system path.');
|
||||
$fields['alias'] = $this->t('The path alias.');
|
||||
return $fields;
|
||||
}
|
||||
|
||||
}
|
|
@ -7,22 +7,20 @@
|
|||
|
||||
namespace Drupal\path\Tests\Migrate\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutable;
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate\Plugin\MigrateIdMapInterface;
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Url alias migration.
|
||||
* URL alias migration.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateUrlAliasTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('path');
|
||||
|
||||
|
@ -39,7 +37,7 @@ class MigrateUrlAliasTest extends MigrateDrupal6TestBase {
|
|||
* Test the url alias migration.
|
||||
*/
|
||||
public function testUrlAlias() {
|
||||
$migration = entity_load('migration', 'd6_url_alias');
|
||||
$id_map = Migration::load('d6_url_alias')->getIdMap();
|
||||
// Test that the field exists.
|
||||
$conditions = array(
|
||||
'source' => '/node/1',
|
||||
|
@ -48,7 +46,7 @@ class MigrateUrlAliasTest extends MigrateDrupal6TestBase {
|
|||
);
|
||||
$path = \Drupal::service('path.alias_storage')->load($conditions);
|
||||
$this->assertNotNull($path, "Path alias for node/1 successfully loaded.");
|
||||
$this->assertIdentical($migration->getIdMap()->lookupDestinationID(array($path['pid'])), array('1'), "Test IdMap");
|
||||
$this->assertIdentical($id_map->lookupDestinationID(array($path['pid'])), array('1'), "Test IdMap");
|
||||
$conditions = array(
|
||||
'source' => '/node/2',
|
||||
'alias' => '/alias-two',
|
||||
|
@ -64,12 +62,14 @@ class MigrateUrlAliasTest extends MigrateDrupal6TestBase {
|
|||
->condition('src', 'node/2')
|
||||
->execute();
|
||||
|
||||
db_update($migration->getIdMap()->mapTableName())
|
||||
\Drupal::database()
|
||||
->update($id_map->mapTableName())
|
||||
->fields(array('source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE))
|
||||
->execute();
|
||||
$migration = entity_load_unchanged('migration', 'd6_url_alias');
|
||||
$executable = new MigrateExecutable($migration, $this);
|
||||
$executable->import();
|
||||
$migration = \Drupal::entityManager()
|
||||
->getStorage('migration')
|
||||
->loadUnchanged('d6_url_alias');
|
||||
$this->executeMigration($migration);
|
||||
|
||||
$path = \Drupal::service('path.alias_storage')->load(array('pid' => $path['pid']));
|
||||
$this->assertIdentical('/new-url-alias', $path['alias']);
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\path\Tests\Migrate\d7\MigrateUrlAliasTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\path\Tests\Migrate\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
|
||||
|
||||
/**
|
||||
* Tests URL alias migration.
|
||||
*
|
||||
* @group path
|
||||
*/
|
||||
class MigrateUrlAliasTest extends MigrateDrupal7TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['path'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installSchema('system', ['url_alias']);
|
||||
$this->executeMigration('d7_url_alias');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the URL alias migration.
|
||||
*/
|
||||
public function testUrlAlias() {
|
||||
$path = \Drupal::service('path.alias_storage')->load([
|
||||
'source' => '/taxonomy/term/4',
|
||||
'alias' => '/term33',
|
||||
'langcode' => 'und',
|
||||
]);
|
||||
$this->assertIdentical('/taxonomy/term/4', $path['source']);
|
||||
$this->assertIdentical('/term33', $path['alias']);
|
||||
$this->assertIdentical('und', $path['langcode']);
|
||||
}
|
||||
|
||||
}
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
namespace Drupal\path\Tests;
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
|
||||
/**
|
||||
* Add, edit, delete, and change alias and verify its consistency in the
|
||||
* database.
|
||||
|
@ -57,6 +59,8 @@ class PathAliasTest extends PathTestBase {
|
|||
|
||||
// Visit the alias for the node and confirm a cache entry is created.
|
||||
\Drupal::cache('data')->deleteAll();
|
||||
// @todo Remove this once https://www.drupal.org/node/2480077 lands.
|
||||
Cache::invalidateTags(['rendered']);
|
||||
$this->drupalGet(trim($edit['alias'], '/'));
|
||||
$this->assertTrue(\Drupal::cache('data')->get('preload-paths:' . $edit['source']), 'Cache entry was created.');
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class PathLanguageTest extends PathTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('path', 'locale', 'content_translation');
|
||||
public static $modules = array('path', 'locale', 'locale_test', 'content_translation');
|
||||
|
||||
/**
|
||||
* An user with permissions to administer content types.
|
||||
|
|
|
@ -19,7 +19,7 @@ class PathLanguageUiTest extends PathTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('path', 'locale');
|
||||
public static $modules = array('path', 'locale', 'locale_test');
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\path\Unit\Migrate\UrlAliasTestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\path\Unit\Migrate;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Base class for url_alias source tests.
|
||||
*/
|
||||
abstract class UrlAliasTestBase extends MigrateSqlSourceTestCase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['url_alias'] = $this->expectedResults;
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -7,14 +7,14 @@
|
|||
|
||||
namespace Drupal\Tests\path\Unit\Migrate\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
use Drupal\Tests\path\Unit\Migrate\UrlAliasTestBase;
|
||||
|
||||
/**
|
||||
* Tests the D6 url alias migrations.
|
||||
* Tests the d6_url_alias source plugin.
|
||||
*
|
||||
* @group path
|
||||
*/
|
||||
class UrlAliasTest extends MigrateSqlSourceTestCase {
|
||||
class UrlAliasTest extends UrlAliasTestBase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\path\Plugin\migrate\source\d6\UrlAlias';
|
||||
|
||||
|
@ -41,14 +41,4 @@ class UrlAliasTest extends MigrateSqlSourceTestCase {
|
|||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
foreach ($this->expectedResults as $row) {
|
||||
$this->databaseContents['url_alias'][] = $row;
|
||||
}
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
43
core/modules/path/tests/src/Unit/Migrate/d7/UrlAliasTest.php
Normal file
43
core/modules/path/tests/src/Unit/Migrate/d7/UrlAliasTest.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\path\Unit\Migrate\d7\UrlAliasTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\path\Unit\Migrate\d7;
|
||||
|
||||
use Drupal\Tests\path\Unit\Migrate\UrlAliasTestBase;
|
||||
|
||||
/**
|
||||
* Tests the d7_url_alias source plugin.
|
||||
*
|
||||
* @group path
|
||||
*/
|
||||
class UrlAliasTest extends UrlAliasTestBase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\path\Plugin\migrate\source\d7\UrlAlias';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'd7_url_alias',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'pid' => 1,
|
||||
'source' => 'node/1',
|
||||
'alias' => 'test-article',
|
||||
'language' => 'en',
|
||||
),
|
||||
array(
|
||||
'pid' => 2,
|
||||
'source' => 'node/2',
|
||||
'alias' => 'another-alias',
|
||||
'language' => 'en',
|
||||
),
|
||||
);
|
||||
|
||||
}
|
Reference in a new issue