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
|
|
@ -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();
|
||||
|
|
|
|||
Reference in a new issue