Update to Drupal 8.0.5. For more information, see https://www.drupal.org/node/2679347
This commit is contained in:
parent
2a9f1f148d
commit
fd3b12cf27
251 changed files with 5439 additions and 957 deletions
|
@ -17,6 +17,8 @@ process:
|
|||
source:
|
||||
- constants/slash
|
||||
- dst
|
||||
langcode: language
|
||||
langcode:
|
||||
plugin: d6_url_alias_language
|
||||
source: language
|
||||
destination:
|
||||
plugin: url_alias
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\path\Plugin\migrate\process\d6\UrlAliasLanguage.
|
||||
*/
|
||||
|
||||
namespace Drupal\path\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
|
||||
/**
|
||||
* Url alias language code process.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_url_alias_language"
|
||||
* )
|
||||
*/
|
||||
class UrlAliasLanguage extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
$langcode = ($value === '') ? LanguageInterface::LANGCODE_NOT_SPECIFIED : $value;
|
||||
return $langcode;
|
||||
}
|
||||
|
||||
}
|
|
@ -33,27 +33,44 @@ class MigrateUrlAliasTest extends MigrateDrupal6TestBase {
|
|||
$this->executeMigration('d6_url_alias');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert a path.
|
||||
*
|
||||
* @param string pid
|
||||
* The path id.
|
||||
* @param array $conditions
|
||||
* The path conditions.
|
||||
* @param array $path
|
||||
* The path.
|
||||
*/
|
||||
private function assertPath($pid, $conditions, $path) {
|
||||
$this->assertTrue($path, "Path alias for " . $conditions['source'] . " successfully loaded.");
|
||||
$this->assertIdentical($conditions['alias'], $path['alias']);
|
||||
$this->assertIdentical($conditions['langcode'], $path['langcode']);
|
||||
$this->assertIdentical($conditions['source'], $path['source']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the url alias migration.
|
||||
*/
|
||||
public function testUrlAlias() {
|
||||
$id_map = Migration::load('d6_url_alias')->getIdMap();
|
||||
// Test that the field exists.
|
||||
$conditions = array(
|
||||
'source' => '/node/1',
|
||||
'alias' => '/alias-one',
|
||||
'langcode' => 'en',
|
||||
'langcode' => 'af',
|
||||
);
|
||||
$path = \Drupal::service('path.alias_storage')->load($conditions);
|
||||
$this->assertNotNull($path, "Path alias for node/1 successfully loaded.");
|
||||
$this->assertPath('1', $conditions, $path);
|
||||
$this->assertIdentical($id_map->lookupDestinationID(array($path['pid'])), array('1'), "Test IdMap");
|
||||
|
||||
$conditions = array(
|
||||
'source' => '/node/2',
|
||||
'alias' => '/alias-two',
|
||||
'langcode' => 'en',
|
||||
);
|
||||
$path = \Drupal::service('path.alias_storage')->load($conditions);
|
||||
$this->assertNotNull($path, "Path alias for node/2 successfully loaded.");
|
||||
$this->assertPath('2', $conditions, $path);
|
||||
|
||||
// Test that we can re-import using the UrlAlias destination.
|
||||
Database::getConnection('default', 'migrate')
|
||||
|
@ -72,7 +89,16 @@ class MigrateUrlAliasTest extends MigrateDrupal6TestBase {
|
|||
$this->executeMigration($migration);
|
||||
|
||||
$path = \Drupal::service('path.alias_storage')->load(array('pid' => $path['pid']));
|
||||
$this->assertIdentical('/new-url-alias', $path['alias']);
|
||||
$conditions['alias'] = '/new-url-alias';
|
||||
$this->assertPath('2', $conditions, $path);
|
||||
|
||||
$conditions = array(
|
||||
'source' => '/node/3',
|
||||
'alias' => '/alias-three',
|
||||
'langcode' => 'und',
|
||||
);
|
||||
$path = \Drupal::service('path.alias_storage')->load($conditions);
|
||||
$this->assertPath('3', $conditions, $path);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue