Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023
This commit is contained in:
parent
2720a9ec4b
commit
f3791f1da3
1898 changed files with 54300 additions and 11481 deletions
|
@ -194,15 +194,12 @@ class ContentLanguageSettings extends ConfigEntityBase implements ContentLanguag
|
|||
*/
|
||||
public function calculateDependencies() {
|
||||
parent::calculateDependencies();
|
||||
$bundle_entity_type_id = $this->entityManager()->getDefinition($this->target_entity_type_id)->getBundleEntityType();
|
||||
if ($bundle_entity_type_id != 'bundle') {
|
||||
// If the target entity type uses entities to manage its bundles then
|
||||
// depend on the bundle entity.
|
||||
if (!$bundle_entity = $this->entityManager()->getStorage($bundle_entity_type_id)->load($this->target_bundle)) {
|
||||
throw new \LogicException("Missing bundle entity, entity type $bundle_entity_type_id, entity id {$this->target_bundle}.");
|
||||
}
|
||||
$this->addDependency('config', $bundle_entity->getConfigDependencyName());
|
||||
}
|
||||
|
||||
// Create dependency on the bundle.
|
||||
$entity_type = \Drupal::entityManager()->getDefinition($this->target_entity_type_id);
|
||||
$bundle_config_dependency = $entity_type->getBundleConfigDependency($this->target_bundle);
|
||||
$this->addDependency($bundle_config_dependency['type'], $bundle_config_dependency['name']);
|
||||
|
||||
return $this->dependencies;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\language\Form;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Core\Entity\EntityForm;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
|
@ -106,7 +106,7 @@ abstract class LanguageFormBase extends EntityForm {
|
|||
'@url' => 'http://www.w3.org/International/articles/language-tags/',
|
||||
)));
|
||||
}
|
||||
if ($form_state->getValue('label') != SafeMarkup::checkPlain($form_state->getValue('label'))) {
|
||||
if ($form_state->getValue('label') != Html::escape($form_state->getValue('label'))) {
|
||||
$form_state->setErrorByName('label', $this->t('%field cannot contain any markup.', array('%field' => $form['label']['#title'])));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Drupal\language\Form;
|
||||
|
||||
use Drupal\Core\Block\BlockManagerInterface;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
|
@ -277,22 +276,22 @@ class NegotiationConfigureForm extends ConfigFormBase {
|
|||
|
||||
if (isset($types[$type])) {
|
||||
$table_form['#language_negotiation_info'][$method_id] = $method;
|
||||
$method_name = SafeMarkup::checkPlain($method['name']);
|
||||
$method_name = $method['name'];
|
||||
|
||||
$table_form['weight'][$method_id] = array(
|
||||
'#type' => 'weight',
|
||||
'#title' => $this->t('Weight for !title language detection method', array('!title' => Unicode::strtolower($method_name))),
|
||||
'#title' => $this->t('Weight for @title language detection method', array('@title' => Unicode::strtolower($method_name))),
|
||||
'#title_display' => 'invisible',
|
||||
'#default_value' => $weight,
|
||||
'#attributes' => array('class' => array("language-method-weight-$type")),
|
||||
'#delta' => 20,
|
||||
);
|
||||
|
||||
$table_form['title'][$method_id] = array('#markup' => $method_name);
|
||||
$table_form['title'][$method_id] = array('#plain_text' => $method_name);
|
||||
|
||||
$table_form['enabled'][$method_id] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Enable !title language detection method', array('!title' => Unicode::strtolower($method_name))),
|
||||
'#title' => $this->t('Enable @title language detection method', array('@title' => Unicode::strtolower($method_name))),
|
||||
'#title_display' => 'invisible',
|
||||
'#default_value' => $enabled,
|
||||
);
|
||||
|
|
|
@ -111,8 +111,8 @@ class NegotiationUrlForm extends ConfigFormBase {
|
|||
);
|
||||
|
||||
$languages = $this->languageManager->getLanguages();
|
||||
$prefixes = language_negotiation_url_prefixes();
|
||||
$domains = language_negotiation_url_domains();
|
||||
$prefixes = $config->get('url.prefixes');
|
||||
$domains = $config->get('url.domains');
|
||||
foreach ($languages as $langcode => $language) {
|
||||
$t_args = array('%language' => $language->getName(), '%langcode' => $language->getId());
|
||||
$form['prefix'][$langcode] = array(
|
||||
|
@ -211,12 +211,11 @@ class NegotiationUrlForm extends ConfigFormBase {
|
|||
// Save selected format (prefix or domain).
|
||||
$this->config('language.negotiation')
|
||||
->set('url.source', $form_state->getValue('language_negotiation_url_part'))
|
||||
// Save new domain and prefix values.
|
||||
->set('url.prefixes', $form_state->getValue('prefix'))
|
||||
->set('url.domains', $form_state->getValue('domain'))
|
||||
->save();
|
||||
|
||||
// Save new domain and prefix values.
|
||||
language_negotiation_url_prefixes_save($form_state->getValue('prefix'));
|
||||
language_negotiation_url_domains_save($form_state->getValue('domain'));
|
||||
|
||||
parent::submitForm($form, $form_state);
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ class LanguageListBuilder extends DraggableListBuilder {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildRow(EntityInterface $entity) {
|
||||
$row['label'] = $this->getLabel($entity);
|
||||
$row['label'] = $entity->label();
|
||||
$row['default'] = array(
|
||||
'#type' => 'radio',
|
||||
'#parents' => array('site_default_language'),
|
||||
|
|
|
@ -66,7 +66,7 @@ use Drupal\Core\Session\AccountInterface;
|
|||
* particular logic to return a language code. For instance, the URL method
|
||||
* searches for a valid path prefix or domain name in the current request URL.
|
||||
* If a language negotiation method does not return a valid language code, the
|
||||
* next method associated to the language type (based on method weight) is
|
||||
* next method associated with the language type (based on method weight) is
|
||||
* invoked.
|
||||
*
|
||||
* Modules can define additional language negotiation methods by simply provide
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\language\Tests\EntityTypeWithoutLanguageFormTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\language\Tests;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Tests entity type without language support.
|
||||
*
|
||||
* This is to ensure that an entity type without language support can not
|
||||
* enable the language select from the content language settings page.
|
||||
*
|
||||
* @group language
|
||||
*/
|
||||
class EntityTypeWithoutLanguageFormTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array(
|
||||
'language',
|
||||
'language_test',
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Create and login administrative user.
|
||||
$admin_user = $this->drupalCreateUser(array(
|
||||
'administer languages',
|
||||
));
|
||||
$this->drupalLogin($admin_user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests configuration options with an entity without language definition.
|
||||
*/
|
||||
public function testEmptyLangcode() {
|
||||
// Assert that we can not enable language select from
|
||||
// content language settings page.
|
||||
$this->drupalGet('admin/config/regional/content-language');
|
||||
$this->assertNoField('entity_types[no_language_entity_test]');
|
||||
}
|
||||
|
||||
}
|
|
@ -21,7 +21,7 @@ class LanguagePathMonolingualTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('language', 'path');
|
||||
public static $modules = ['block', 'language', 'path'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
@ -56,6 +56,7 @@ class LanguagePathMonolingualTest extends WebTestBase {
|
|||
// Set language detection to URL.
|
||||
$edit = array('language_interface[enabled][language-url]' => TRUE);
|
||||
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
|
||||
$this->drupalPlaceBlock('local_actions_block');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,7 @@ class LanguageTourTest extends TourTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('language', 'tour');
|
||||
public static $modules = ['block', 'language', 'tour'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -37,6 +37,7 @@ class LanguageTourTest extends TourTestBase {
|
|||
parent::setUp();
|
||||
$this->adminUser = $this->drupalCreateUser(array('administer languages', 'access tour'));
|
||||
$this->drupalLogin($this->adminUser);
|
||||
$this->drupalPlaceBlock('local_actions_block');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\language\Tests\Migrate\d7\MigrateLanguageNegotiationSettingsTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\language\Tests\Migrate\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
|
||||
|
||||
/**
|
||||
* Tests migration of language negotiation variables.
|
||||
*
|
||||
* @group language
|
||||
*/
|
||||
class MigrateLanguageNegotiationSettingsTest extends MigrateDrupal7TestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['language'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('d7_language_negotiation_settings');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of language negotiation variables to language.negotiation.yml.
|
||||
*/
|
||||
public function testLanguageNegotiation() {
|
||||
$config = $this->config('language.negotiation');
|
||||
$this->assertIdentical($config->get('session.parameter'), 'language');
|
||||
$this->assertIdentical($config->get('url.source'), 'domain');
|
||||
}
|
||||
|
||||
}
|
|
@ -8,12 +8,12 @@
|
|||
namespace Drupal\language\Tests\Views;
|
||||
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\views\Tests\ViewUnitTestBase;
|
||||
use Drupal\views\Tests\ViewKernelTestBase;
|
||||
|
||||
/**
|
||||
* Defines the base class for all Language handler tests.
|
||||
*/
|
||||
abstract class LanguageTestBase extends ViewUnitTestBase {
|
||||
abstract class LanguageTestBase extends ViewKernelTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
|
Reference in a new issue