Update to Drupal 8.2.0. For more information, see https://www.drupal.org/project/drupal/releases/8.2.0

This commit is contained in:
Pantheon Automation 2016-10-06 15:16:20 -07:00 committed by Greg Anderson
parent 2f563ab520
commit f1c8716f57
1732 changed files with 52334 additions and 11780 deletions

View file

@ -0,0 +1,25 @@
id: default_language
label: Default language
migration_tags:
- Drupal 6
- Drupal 7
source:
plugin: variable
variables:
- language_default
process:
default_langcode:
-
plugin: callback
callable: get_object_vars
source: language_default
-
plugin: extract
index:
- language
destination:
plugin: default_langcode
config_name: system.site
migration_dependencies:
required:
- language

View file

@ -91,7 +91,7 @@ class LanguageNegotiationContentEntity extends LanguageNegotiationMethodBase imp
* {@inheritdoc}
*/
public function getLangcode(Request $request = NULL) {
$langcode = $request->get(static::QUERY_PARAMETER);
$langcode = $request->query->get(static::QUERY_PARAMETER);
$language_enabled = array_key_exists($langcode, $this->languageManager->getLanguages());
return $language_enabled ? $langcode : NULL;

View file

@ -0,0 +1,36 @@
<?php
namespace Drupal\language\Plugin\migrate\destination;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\migrate\MigrateException;
use Drupal\migrate\Plugin\migrate\destination\Config;
use Drupal\migrate\Row;
/**
* Provides a destination plugin for the default langcode config.
*
* @MigrateDestination(
* id = "default_langcode"
* )
*/
class DefaultLangcode extends Config {
/**
* {@inheritdoc}
*/
public function import(Row $row, array $old_destination_id_values = array()) {
$destination = $row->getDestination();
$langcode = $destination['default_langcode'];
// Check if the language exists.
if (ConfigurableLanguage::load($langcode) === NULL) {
throw new MigrateException("The language '$langcode' does not exist on this site.");
}
$this->config->set('default_langcode', $destination['default_langcode']);
$this->config->save();
return [$this->config->getName()];
}
}

View file

@ -109,7 +109,7 @@ class LanguageConfigurationElementTest extends WebTestBase {
// Site's default.
$old_default = \Drupal::languageManager()->getDefaultLanguage();
// Ensure the language entity default value is correct.
$configurable_language = entity_load('configurable_language', $old_default->getId());
$configurable_language = ConfigurableLanguage::load($old_default->getId());
$this->assertTrue($configurable_language->isDefault(), 'The en language entity is flagged as the default language.');
$this->config('system.site')->set('default_langcode', 'cc')->save();
@ -121,9 +121,9 @@ class LanguageConfigurationElementTest extends WebTestBase {
$this->assertEqual($langcode, 'cc');
// Ensure the language entity default value is correct.
$configurable_language = entity_load('configurable_language', $old_default->getId());
$configurable_language = ConfigurableLanguage::load($old_default->getId());
$this->assertFalse($configurable_language->isDefault(), 'The en language entity is not flagged as the default language.');
$configurable_language = entity_load('configurable_language', 'cc');
$configurable_language = ConfigurableLanguage::load('cc');
// Check calling the
// \Drupal\language\ConfigurableLanguageInterface::isDefault() method
// directly.

View file

@ -204,8 +204,11 @@ class LanguageConfigurationTest extends WebTestBase {
protected function getHighestConfigurableLanguageWeight(){
$max_weight = 0;
$storage = $this->container->get('entity_type.manager')
->getStorage('configurable_language');
$storage->resetCache();
/* @var $languages \Drupal\Core\Language\LanguageInterface[] */
$languages = entity_load_multiple('configurable_language', NULL, TRUE);
$languages = $storage->loadMultiple();
foreach ($languages as $language) {
if (!$language->isLocked()) {
$max_weight = max($max_weight, $language->getWeight());

View file

@ -0,0 +1,56 @@
<?php
namespace Drupal\Tests\language\Kernel\Migrate;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\migrate\Plugin\MigrationInterface;
/**
* Tests the default language variable migration.
*/
trait MigrateDefaultLanguageTrait {
/**
* Helper method to test the migration.
*
* @param string $langcode
* The langcode of the default language.
* @param bool $existing
* Whether the default language exists on the destination.
*/
protected function doTestMigration($langcode, $existing = TRUE) {
// The default language of the test fixture is English. Change it to
// something else before migrating, to be sure that the source site
// default language is migrated.
$value = 'O:8:"stdClass":11:{s:8:"language";s:2:"' . $langcode . '";s:4:"name";s:6:"French";s:6:"native";s:6:"French";s:9:"direction";s:1:"0";s:7:"enabled";i:1;s:7:"plurals";s:1:"0";s:7:"formula";s:0:"";s:6:"domain";s:0:"";s:6:"prefix";s:0:"";s:6:"weight";s:1:"0";s:10:"javascript";s:0:"";}';
$this->sourceDatabase->update('variable')
->fields(array(
'value' => $value
))
->condition('name', 'language_default' )
->execute();
$this->startCollectingMessages();
$this->executeMigrations(['language', 'default_language']);
if ($existing) {
// If the default language exists, we should be able to load it and the
// default_langcode config should be set.
$default_language = ConfigurableLanguage::load($langcode);
$this->assertNotNull($default_language);
$this->assertIdentical($langcode, $this->config('system.site')->get('default_langcode'));
}
else {
// Otherwise, the migration log should contain an error message.
$messages = $this->migration->getIdMap()->getMessageIterator();
$count = 0;
foreach ($messages as $message) {
$count++;
$this->assertEqual($message->message, "The language '$langcode' does not exist on this site.");
$this->assertEqual($message->level, MigrationInterface::MESSAGE_ERROR);
}
$this->assertEqual($count, 1);
}
}
}

View file

@ -0,0 +1,36 @@
<?php
namespace Drupal\Tests\language\Kernel\Migrate\d6;
use Drupal\Tests\language\Kernel\Migrate\MigrateDefaultLanguageTrait;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Tests the default language variable migration.
*
* @group migrate_drupal_6
*/
class MigrateDefaultLanguageTest extends MigrateDrupal6TestBase {
use MigrateDefaultLanguageTrait;
/**
* {@inheritdoc}
*/
public static $modules = ['language'];
/**
* Tests language_default migration with an existing language.
*/
public function testMigrationWithExistingLanguage() {
$this->doTestMigration('fr');
}
/**
* Tests language_default migration with a non-existing language.
*/
public function testMigrationWithNonExistentLanguage() {
$this->doTestMigration('tv', FALSE);
}
}

View file

@ -0,0 +1,36 @@
<?php
namespace Drupal\Tests\language\Kernel\Migrate\d7;
use Drupal\Tests\language\Kernel\Migrate\MigrateDefaultLanguageTrait;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
/**
* Tests the default language variable migration.
*
* @group migrate_drupal_7
*/
class MigrateDefaultLanguageTest extends MigrateDrupal7TestBase {
use MigrateDefaultLanguageTrait;
/**
* {@inheritdoc}
*/
public static $modules = ['language'];
/**
* Tests language_default migration with a non-existing language.
*/
public function testMigrationWithExistingLanguage() {
$this->doTestMigration('is');
}
/**
* Tests language_default migration with a non-existing language.
*/
public function testMigrationWithNonExistentLanguage() {
$this->doTestMigration('tv', FALSE);
}
}

View file

@ -1,6 +1,6 @@
<?php
namespace Drupal\Tests\language\Unit {
namespace Drupal\Tests\language\Unit;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Language\LanguageInterface;
@ -252,13 +252,11 @@ class LanguageNegotiationUrlTest extends UnitTestCase {
}
}
// @todo Remove as part of https://www.drupal.org/node/2481833.
namespace {
if (!function_exists('base_path')) {
function base_path() {
return '/';
}
namespace Drupal\language\Plugin\LanguageNegotiation;
if (!function_exists('base_path')) {
function base_path() {
return '/';
}
}