Commit 8a0fa31c authored by alexpott's avatar alexpott

Issue #2271005 by martin107, YesCT, alimac, mrjmd: Rename Language module's...

Issue #2271005 by martin107, YesCT, alimac, mrjmd: Rename Language module's LanguageInterface to ConfigurableLanguageInterface and Language to ConfigurableLanguage.
parent 8fe81428
......@@ -109,9 +109,10 @@ public function isSyncing();
* entity change is part of an uninstall process, and skip executing your code
* if that is the case.
*
* For example, \Drupal\language\Entity\Language::preDelete() prevents the API
* from deleting the default language. However during an uninstall of the
* language module it is expected that the default language should be deleted.
* For example, \Drupal\language\Entity\ConfigurableLanguage::preDelete()
* prevents the API from deleting the default language. However during an
* uninstall of the language module it is expected that the default language
* should be deleted.
*
* @return bool
*/
......
......@@ -7,7 +7,7 @@
use Drupal\block\BlockInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\language\Entity\Language;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\system\Entity\Menu;
/**
......@@ -328,11 +328,11 @@ function block_menu_delete(Menu $menu) {
}
/**
* Implements hook_ENTITY_TYPE_delete() for 'language_entity'.
* Implements hook_ENTITY_TYPE_delete() for 'configurable_language'.
*
* Delete the potential block visibility settings of the deleted language.
*/
function block_language_entity_delete(Language $language) {
function block_configurable_language_delete(ConfigurableLanguage $language) {
// Remove the block visibility settings for the deleted language.
foreach (entity_load_multiple('block') as $block) {
/** @var $block \Drupal\block\BlockInterface */
......
......@@ -106,7 +106,7 @@ public function testMapperListPage() {
public function testHiddenEntities() {
// Hidden languages are only available to translate through the
// configuration translation listings.
$this->drupalGet('admin/config/regional/config-translation/language_entity');
$this->drupalGet('admin/config/regional/config-translation/configurable_language');
$this->assertText('Not applicable');
$this->assertLinkByHref('admin/config/regional/language/edit/zxx/translate');
$this->assertText('Not specified');
......
......@@ -56,16 +56,16 @@ public function setUp() {
$this->routeProvider
->expects($this->any())
->method('getRouteByName')
->with('entity.language_entity.edit_form')
->will($this->returnValue(new Route('/admin/config/regional/language/edit/{language_entity}')));
->with('entity.configurable_language.edit_form')
->will($this->returnValue(new Route('/admin/config/regional/language/edit/{configurable_language}')));
$definition = array(
'class' => '\Drupal\config_translation\ConfigEntityMapper',
'base_route_name' => 'entity.language_entity.edit_form',
'base_route_name' => 'entity.configurable_language.edit_form',
'title' => '!label language',
'names' => array(),
'entity_type' => 'language_entity',
'route_name' => 'config_translation.item.overview.entity.language_entity.edit_form',
'entity_type' => 'configurable_language',
'route_name' => 'config_translation.item.overview.entity.configurable_language.edit_form',
);
$typed_config_manager = $this->getMock('Drupal\Core\Config\TypedConfigManagerInterface');
......@@ -75,7 +75,7 @@ public function setUp() {
->getMock();
$this->configEntityMapper = new ConfigEntityMapper(
'language_entity',
'configurable_language',
$definition,
$this->getConfigFactoryStub(),
$typed_config_manager,
......@@ -101,7 +101,7 @@ public function testSetEntity() {
$this->entityManager
->expects($this->once())
->method('getDefinition')
->with('language_entity')
->with('configurable_language')
->will($this->returnValue($entity_type));
$result = $this->configEntityMapper->setEntity($this->entity);
......@@ -120,7 +120,7 @@ public function testGetOverviewRouteParameters() {
$this->entityManager
->expects($this->once())
->method('getDefinition')
->with('language_entity')
->with('configurable_language')
->will($this->returnValue($entity_type));
$this->configEntityMapper->setEntity($this->entity);
......@@ -132,7 +132,7 @@ public function testGetOverviewRouteParameters() {
$result = $this->configEntityMapper->getOverviewRouteParameters();
$this->assertSame(array('language_entity' => 'entity_id'), $result);
$this->assertSame(array('configurable_language' => 'entity_id'), $result);
}
/**
......@@ -140,7 +140,7 @@ public function testGetOverviewRouteParameters() {
*/
public function testGetType() {
$result = $this->configEntityMapper->getType();
$this->assertSame('language_entity', $result);
$this->assertSame('configurable_language', $result);
}
/**
......@@ -154,7 +154,7 @@ public function testGetTypeName() {
$this->entityManager
->expects($this->once())
->method('getDefinition')
->with('language_entity')
->with('configurable_language')
->will($this->returnValue($entity_type));
$result = $this->configEntityMapper->getTypeName();
......@@ -172,7 +172,7 @@ public function testGetTypeLabel() {
$this->entityManager
->expects($this->once())
->method('getDefinition')
->with('language_entity')
->with('configurable_language')
->will($this->returnValue($entity_type));
$result = $this->configEntityMapper->getTypeLabel();
......@@ -188,7 +188,7 @@ public function testGetOperations() {
$expected = array(
'list' => array(
'title' => 'List',
'href' => 'admin/config/regional/config-translation/language_entity',
'href' => 'admin/config/regional/config-translation/configurable_language',
)
);
......
......@@ -7,7 +7,7 @@ language.negotiation:
route_name: language.negotiation
base_route: language.admin_overview
entity.language_entity.edit_form:
entity.configurable_language.edit_form:
title: 'Edit'
route_name: entity.language_entity.edit_form
base_route: entity.language_entity.edit_form
route_name: entity.configurable_language.edit_form
base_route: entity.configurable_language.edit_form
......@@ -11,7 +11,7 @@
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\language\ConfigurableLanguageManager;
use Drupal\language\ConfigurableLanguageManagerInterface;
use Drupal\language\Entity\Language as LanguageEntity;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUI;
use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl;
use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrlFallback;
......@@ -414,21 +414,21 @@ function language_get_default_langcode($entity_type, $bundle) {
* configuration properties.
*/
function language_save($language) {
$language_entity = entity_load('language_entity', $language->id);
if (!$language_entity) {
$language_entity = entity_create('language_entity', array(
$configurable_language = entity_load('configurable_language', $language->id);
if (!$configurable_language) {
$configurable_language = entity_create('configurable_language', array(
'id' => $language->id,
));
}
$language->is_new = $language_entity->isNew();
$language->is_new = $configurable_language->isNew();
// Assign language properties to language entity.
$language_entity->label = isset($language->name) ? $language->name : '';
$language_entity->direction = isset($language->direction) ? $language->direction : '0';
$language_entity->locked = !empty($language->locked);
$language_entity->weight = isset($language->weight) ? $language->weight : 0;
$language_entity->setDefault(!empty($language->default));
$language_entity->save();
$configurable_language->label = isset($language->name) ? $language->name : '';
$configurable_language->direction = isset($language->direction) ? $language->direction : '0';
$configurable_language->locked = !empty($language->locked);
$configurable_language->weight = isset($language->weight) ? $language->weight : 0;
$configurable_language->setDefault(!empty($language->default));
$configurable_language->save();
$t_args = array('%language' => $language->name, '%langcode' => $language->id);
if ($language->is_new) {
// Install any available language configuration overrides for the language.
......@@ -457,7 +457,7 @@ function language_delete($langcode) {
$language = $languages[$langcode];
// Remove the language.
entity_delete_multiple('language_entity', array($language->id));
entity_delete_multiple('configurable_language', array($language->id));
$language_manager = \Drupal::languageManager();
$language_manager->reset();
......@@ -581,9 +581,9 @@ function language_modules_uninstalled($modules) {
}
/**
* Implements hook_ENTITY_TYPE_insert() for 'language_entity'.
* Implements hook_ENTITY_TYPE_insert() for 'configurable_language'.
*/
function language_language_entity_insert(LanguageEntity $language) {
function language_configurable_language_insert(ConfigurableLanguage $language) {
if (!empty($language->locked)) {
return;
}
......@@ -595,9 +595,9 @@ function language_language_entity_insert(LanguageEntity $language) {
}
/**
* Implements hook_ENTITY_TYPE_delete() for 'language_entity'.
* Implements hook_ENTITY_TYPE_delete() for 'configurable_language'.
*/
function language_language_entity_delete(LanguageEntity $language) {
function language_configurable_language_delete(ConfigurableLanguage $language) {
// Remove language from language prefix list.
$prefixes = language_negotiation_url_prefixes();
unset($prefixes[$language->id()]);
......
......@@ -25,34 +25,34 @@ language.negotiation_selected:
language.add:
path: '/admin/config/regional/language/add'
defaults:
_entity_form: 'language_entity.add'
_entity_form: 'configurable_language.add'
_title: 'Add language'
requirements:
_entity_create_access: 'language_entity'
_entity_create_access: 'configurable_language'
entity.language_entity.edit_form:
path: '/admin/config/regional/language/edit/{language_entity}'
entity.configurable_language.edit_form:
path: '/admin/config/regional/language/edit/{configurable_language}'
defaults:
_entity_form: 'language_entity.edit'
_entity_form: 'configurable_language.edit'
_title: 'Edit language'
requirements:
_entity_access: 'language_entity.update'
_entity_access: 'configurable_language.update'
language.admin_overview:
path: '/admin/config/regional/language'
defaults:
_entity_list: 'language_entity'
_entity_list: 'configurable_language'
_title: 'Languages'
requirements:
_permission: 'administer languages'
entity.language_entity.delete_form:
path: '/admin/config/regional/language/delete/{language_entity}'
entity.configurable_language.delete_form:
path: '/admin/config/regional/language/delete/{configurable_language}'
defaults:
_entity_form: 'language_entity.delete'
_entity_form: 'configurable_language.delete'
_title: 'Delete language'
requirements:
_entity_access: 'language_entity.delete'
_entity_access: 'configurable_language.delete'
language.negotiation:
path: '/admin/config/regional/language/detection'
......
......@@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\language\LanguageInterface.
* Contains \Drupal\language\ConfigurableLanguageInterface.
*/
namespace Drupal\language;
......@@ -12,6 +12,6 @@
/**
* Provides an interface defining a language entity.
*/
interface LanguageInterface extends ConfigEntityInterface {
interface ConfigurableLanguageInterface extends ConfigEntityInterface {
}
......@@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\language\Entity\Language.
* Contains \Drupal\language\Entity\ConfigurableLanguage.
*/
namespace Drupal\language\Entity;
......@@ -12,13 +12,13 @@
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\language\ConfigurableLanguageManagerInterface;
use Drupal\language\Exception\DeleteDefaultLanguageException;
use Drupal\language\LanguageInterface;
use Drupal\language\ConfigurableLanguageInterface;
/**
* Defines the Language entity.
* Defines the ConfigurableLanguage entity.
*
* @ConfigEntityType(
* id = "language_entity",
* id = "configurable_language",
* label = @Translation("Language"),
* controllers = {
* "list_builder" = "Drupal\language\LanguageListBuilder",
......@@ -37,12 +37,12 @@
* "weight" = "weight"
* },
* links = {
* "delete-form" = "entity.language_entity.delete_form",
* "edit-form" = "entity.language_entity.edit_form"
* "delete-form" = "entity.configurable_language.delete_form",
* "edit-form" = "entity.configurable_language.edit_form"
* }
* )
*/
class Language extends ConfigEntityBase implements LanguageInterface {
class ConfigurableLanguage extends ConfigEntityBase implements ConfigurableLanguageInterface {
/**
* The language ID (machine name).
......@@ -87,9 +87,9 @@ class Language extends ConfigEntityBase implements LanguageInterface {
* container using the language.default service in when the entity is saved.
* The value is set correctly when a language entity is created or loaded.
*
* @see \Drupal\language\Entity\Language::postSave()
* @see \Drupal\language\Entity\Language::isDefault()
* @see \Drupal\language\Entity\Language::setDefault()
* @see \Drupal\language\Entity\ConfigurableLanguage::postSave()
* @see \Drupal\language\Entity\ConfigurableLanguage::isDefault()
* @see \Drupal\language\Entity\ConfigurableLanguage::setDefault()
*
* @var bool
*/
......@@ -101,8 +101,8 @@ class Language extends ConfigEntityBase implements LanguageInterface {
* This property is not saved to the language entity, but is needed for
* detecting when to rebuild the services.
*
* @see \Drupal\language\Entity\Language::preSave()
* @see \Drupal\language\Entity\Language::postSave()
* @see \Drupal\language\Entity\ConfigurableLanguage::preSave()
* @see \Drupal\language\Entity\ConfigurableLanguage::postSave()
*
* @var bool
*/
......@@ -137,7 +137,7 @@ public function preSave(EntityStorageInterface $storage) {
parent::preSave($storage);
// Store whether or not the site is already multilingual so that we can
// rebuild services if necessary during
// \Drupal\language\Entity\Language::postSave().
// \Drupal\language\Entity\ConfigurableLanguage::postSave().
$this->preSaveMultilingual = \Drupal::languageManager()->isMultilingual();
// Languages are picked from a predefined list which is given in English.
// For the uncommon case of custom languages the label should be given in
......@@ -179,7 +179,7 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) {
}
/**
* Converts the Language entity to a Language value object.
* Converts the ConfigurableLanguage entity to a Core Language value object.
*
* @todo fix return type hint after https://drupal.org/node/2246665 and
* https://drupal.org/node/2246679.
......
......@@ -14,7 +14,7 @@
/**
* Defines a class to build a listing of language entities.
*
* @see \Drupal\language\Entity\Language
* @see \Drupal\language\Entity\ConfigurableLanguage
*/
class LanguageListBuilder extends DraggableListBuilder {
......
......@@ -83,8 +83,8 @@ public function testDefaultLangcode() {
// Site's default.
$old_default = \Drupal::languageManager()->getDefaultLanguage();
// Ensure the language entity default value is correct.
$language_entity = entity_load('language_entity', $old_default->getId());
$this->assertTrue($language_entity->get('default'), 'The en language entity is flagged as the default language.');
$configurable_language = entity_load('configurable_language', $old_default->getId());
$this->assertTrue($configurable_language->get('default'), 'The en language entity is flagged as the default language.');
$old_default->default = FALSE;
language_save($old_default);
$new_default = \Drupal::languageManager()->getLanguage('cc');
......@@ -95,12 +95,13 @@ public function testDefaultLangcode() {
$this->assertEqual($langcode, 'cc');
// Ensure the language entity default value is correct.
$language_entity = entity_load('language_entity', $old_default->getId());
$this->assertFalse($language_entity->get('default'), 'The en language entity is not flagged as the default language.');
$language_entity = entity_load('language_entity', 'cc');
// Check calling the Drupal\language\Entity\Language::isDefault() method
$configurable_language = entity_load('configurable_language', $old_default->getId());
$this->assertFalse($configurable_language->get('default'), 'The en language entity is not flagged as the default language.');
$configurable_language = entity_load('configurable_language', 'cc');
// Check calling the
// \Drupal\language\Entity\ConfigurableLanguage::isDefault() method
// directly.
$this->assertTrue($language_entity->isDefault(), 'The cc language entity is flagged as the default language.');
$this->assertTrue($configurable_language->isDefault(), 'The cc language entity is flagged as the default language.');
// Check the default value of a language field when authors preferred option
// is selected.
......
......@@ -168,7 +168,7 @@ protected function checkConfigurableLanguageWeight($state = 'by default') {
protected function getHighestConfigurableLanguageWeight(){
$max_weight = 0;
$languages = entity_load_multiple('language_entity', NULL, TRUE);
$languages = entity_load_multiple('configurable_language', NULL, TRUE);
foreach ($languages as $language) {
if (!$language->locked && $language->weight > $max_weight) {
$max_weight = $language->weight;
......
......@@ -46,8 +46,8 @@ public function getLanguageAdminOverviewRoutes() {
* Tests language edit local tasks existence.
*/
public function testLanguageEditLocalTasks() {
$this->assertLocalTasks('entity.language_entity.edit_form', array(
0 => array('entity.language_entity.edit_form'),
$this->assertLocalTasks('entity.configurable_language.edit_form', array(
0 => array('entity.configurable_language.edit_form'),
));
}
......
......@@ -19,7 +19,7 @@
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\StringTranslation\TranslationWrapper;
use Drupal\Core\Language\LanguageInterface;
use Drupal\language\Entity\Language as LanguageEntity;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Component\Utility\Crypt;
/**
......@@ -223,9 +223,9 @@ function locale_stream_wrappers() {
}
/**
* Implements hook_ENTITY_TYPE_insert() for 'language_entity'.
* Implements hook_ENTITY_TYPE_insert() for 'configurable_language'.
*/
function locale_language_entity_insert(LanguageEntity $language) {
function locale_configurable_language_insert(ConfigurableLanguage $language) {
// @todo move these two cache clears out. See http://drupal.org/node/1293252
// Changing the language settings impacts the interface: clear render cache.
\Drupal::cache('render')->deleteAll();
......@@ -234,9 +234,9 @@ function locale_language_entity_insert(LanguageEntity $language) {
}
/**
* Implements hook_ENTITY_TYPE_update() for 'language_entity'.
* Implements hook_ENTITY_TYPE_update() for 'configurable_language'.
*/
function locale_language_entity_update(LanguageEntity $language) {
function locale_configurable_language_update(ConfigurableLanguage $language) {
// @todo move these two cache clears out. See http://drupal.org/node/1293252
// Changing the language settings impacts the interface: clear render cache.
\Drupal::cache('render')->deleteAll();
......@@ -245,9 +245,9 @@ function locale_language_entity_update(LanguageEntity $language) {
}
/**
* Implements hook_ENTITY_TYPE_delete() for 'language_entity'.
* Implements hook_ENTITY_TYPE_delete() for 'configurable_language'.
*/
function locale_language_entity_delete(LanguageEntity $language) {
function locale_configurable_language_delete(ConfigurableLanguage $language) {
// Remove translations.
\Drupal::service('locale.storage')->deleteTranslations(array('language' => $language->id()));
......
......@@ -28,7 +28,7 @@
use Drupal\Core\Entity\Display\EntityFormDisplayInterface;
use Drupal\Core\Template\Attribute;
use Drupal\file\Entity\File;
use Drupal\language\Entity\Language as LanguageEntity;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\block\Entity\Block;
use Drupal\Core\Session\AccountInterface;
......@@ -1601,9 +1601,9 @@ function node_modules_uninstalled($modules) {
}
/**
* Implements hook_ENTITY_TYPE_delete() for 'language_entity'.
* Implements hook_ENTITY_TYPE_delete() for 'configurable_language'.
*/
function node_language_entity_delete(LanguageEntity $language) {
function node_configurable_language_delete(ConfigurableLanguage $language) {
// On nodes with this language, unset the language.
\Drupal::entityManager()->getStorage('node')->clearRevisionsLanguage($language);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment