diff --git a/core/includes/mail.inc b/core/includes/mail.inc index e62297c..a76048b 100644 --- a/core/includes/mail.inc +++ b/core/includes/mail.inc @@ -27,9 +27,10 @@ * filled on the page, there are two additional choices if you are not * sending the email to a user on the site. You can either use the language * used to generate the page or the site default language. See - * language_default(). The former is good if sending email to the person - * filling the form, the later is good if you send email to an address - * previously set up (like contact addresses in a contact form). + * Drupal\Core\Language\LanguageManagerInterface::getDefaultLanguage(). The + * former is good if sending email to the person filling the form, the later + * is good if you send email to an address previously set up (like contact + * addresses in a contact form). * * Taking care of always using the proper language is even more important * when sending emails in a row to multiple users. Hook_mail() abstracts diff --git a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php index 6f246f7..8c66b5a 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php @@ -18,6 +18,7 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Language\LanguageInterface; +use Drupal\Core\Language\LanguageManagerInterface; use Drupal\field\Entity\FieldConfig; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -105,6 +106,13 @@ class ContentEntityDatabaseStorage extends ContentEntityStorageBase implements S protected $entityManager; /** + * The language manager. + * + * @var \Drupal\Core\Language\LanguageManagerInterface + */ + protected $languageManager; + + /** * The entity schema handler. * * @var \Drupal\Core\Entity\Schema\EntitySchemaHandlerInterface @@ -118,7 +126,8 @@ public static function createInstance(ContainerInterface $container, EntityTypeI return new static( $entity_type, $container->get('database'), - $container->get('entity.manager') + $container->get('entity.manager'), + $container->get('language_manager') ); } @@ -142,12 +151,15 @@ public function getFieldStorageDefinitions() { * The database connection to be used. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. + * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager + * The language manager. */ - public function __construct(EntityTypeInterface $entity_type, Connection $database, EntityManagerInterface $entity_manager) { + public function __construct(EntityTypeInterface $entity_type, Connection $database, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager) { parent::__construct($entity_type); $this->database = $database; $this->entityManager = $entity_manager; + $this->languageManager = $language_manager; // @todo Remove table names from the entity type definition in // https://drupal.org/node/2232465 @@ -960,7 +972,7 @@ protected function doLoadFieldItems($entities, $age) { } // Load field data. - $langcodes = array_keys(language_list(LanguageInterface::STATE_ALL)); + $langcodes = array_keys($this->languageManager->getLanguages(LanguageInterface::STATE_ALL)); foreach ($storage_definitions as $field_name => $storage_definition) { $table = $load_current ? static::_fieldTableName($storage_definition) : static::_fieldRevisionTableName($storage_definition); diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php index 3a0780f..071b094 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php @@ -43,7 +43,7 @@ class Language extends TypedData { */ public function getValue() { if (!isset($this->language) && $this->id) { - $this->language = language_load($this->id); + $this->language = \Drupal::languageManager()->getLanguage($this->id); } return $this->language; } diff --git a/core/modules/config_translation/src/ConfigNamesMapper.php b/core/modules/config_translation/src/ConfigNamesMapper.php index f5044b1..088b8dc 100644 --- a/core/modules/config_translation/src/ConfigNamesMapper.php +++ b/core/modules/config_translation/src/ConfigNamesMapper.php @@ -56,6 +56,13 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con protected $configMapperManager; /** + * The language manager. + * + * @var \Drupal\Core\Language\LanguageManagerInterface + */ + protected $languageManager; + + /** * The route provider. * * @var \Drupal\Core\Routing\RouteProviderInterface diff --git a/core/modules/config_translation/tests/src/ConfigEntityMapperTest.php b/core/modules/config_translation/tests/src/ConfigEntityMapperTest.php index 0c514a4..62d8d9c 100644 --- a/core/modules/config_translation/tests/src/ConfigEntityMapperTest.php +++ b/core/modules/config_translation/tests/src/ConfigEntityMapperTest.php @@ -33,6 +33,13 @@ class ConfigEntityMapperTest extends UnitTestCase { protected $entityManager; /** + * The language manager used for testing. + * + * @var \Drupal\Core\Language\LanguageManagerInterface $language_manager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $languageManager; + + /** * The entity instance used for testing. * * @var \Drupal\Core\Entity\EntityInterface|\PHPUnit_Framework_MockObject_MockObject @@ -59,6 +66,8 @@ public function setUp() { ->with('language.edit') ->will($this->returnValue(new Route('/admin/config/regional/language/edit/{language_entity}'))); + $this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface'); + $definition = array( 'class' => '\Drupal\config_translation\ConfigEntityMapper', 'base_route_name' => 'language.edit', @@ -83,7 +92,8 @@ public function setUp() { $this->getMock('Drupal\config_translation\ConfigMapperManagerInterface'), $this->routeProvider, $this->getStringTranslationStub(), - $this->entityManager + $this->entityManager, + $this->languageManager ); } diff --git a/core/modules/content_translation/src/Access/ContentTranslationManageAccessCheck.php b/core/modules/content_translation/src/Access/ContentTranslationManageAccessCheck.php index ae5bc3f..e77e5fb 100644 --- a/core/modules/content_translation/src/Access/ContentTranslationManageAccessCheck.php +++ b/core/modules/content_translation/src/Access/ContentTranslationManageAccessCheck.php @@ -80,7 +80,7 @@ public function access(Route $route, Request $request, AccountInterface $account case 'update': case 'delete': - $language = language_load($language) ?: \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT); + $language = \Drupal::languageManager()->getLanguage($language) ?: \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT); return isset($languages[$language->id]) && $language->id != $entity->getUntranslated()->language()->id && isset($translations[$language->id]) diff --git a/core/modules/content_translation/src/ContentTranslationHandler.php b/core/modules/content_translation/src/ContentTranslationHandler.php index 7510d2e..f75dd0b 100644 --- a/core/modules/content_translation/src/ContentTranslationHandler.php +++ b/core/modules/content_translation/src/ContentTranslationHandler.php @@ -99,7 +99,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac // Adjust page title to specify the current language being edited, if we // have at least one translation. - $languages = language_list(); + $languages = \Drupal::languageManager()->getLanguages(); if (isset($languages[$form_langcode]) && ($has_translations || $new_translation)) { $title = $this->entityFormTitle($entity); // When editing the original values display just the entity label. @@ -132,7 +132,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac '#submit' => array(array($this, 'entityFormSourceChange')), ), ); - foreach (language_list(LanguageInterface::STATE_CONFIGURABLE) as $language) { + foreach (\Drupal::languageManager()->getLanguages(LanguageInterface::STATE_CONFIGURABLE) as $language) { if (isset($translations[$language->id])) { $form['source_langcode']['source']['#options'][$language->id] = $language->name; } @@ -145,7 +145,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac $language_widget = isset($form['langcode']) && $form['langcode']['#type'] == 'language_select'; if ($language_widget && $has_translations) { $form['langcode']['#options'] = array(); - foreach (language_list(LanguageInterface::STATE_CONFIGURABLE) as $language) { + foreach (\Drupal::languageManager()->getLanguages(LanguageInterface::STATE_CONFIGURABLE) as $language) { if (empty($translations[$language->id]) || $language->id == $entity_langcode) { $form['langcode']['#options'][$language->id] = $language->name; } @@ -436,7 +436,7 @@ public function entityFormSourceChange($form, &$form_state) { $path = $entity->getSystemPath('drupal:content-translation-overview'); $form_state['redirect'] = $path . '/add/' . $source . '/' . $form_controller->getFormLangcode($form_state); - $languages = language_list(); + $languages = \Drupal::languageManager()->getLanguages(); drupal_set_message(t('Source language set to: %language', array('%language' => $languages[$source]->name))); } diff --git a/core/modules/content_translation/src/Controller/ContentTranslationController.php b/core/modules/content_translation/src/Controller/ContentTranslationController.php index 31a33d2..f5ed704 100644 --- a/core/modules/content_translation/src/Controller/ContentTranslationController.php +++ b/core/modules/content_translation/src/Controller/ContentTranslationController.php @@ -29,8 +29,8 @@ public function overview(Request $request) { public function add(Request $request, $source, $target) { $entity = $request->attributes->get($request->attributes->get('_entity_type_id')); module_load_include('pages.inc', 'content_translation'); - $source = language_load($source); - $target = language_load($target); + $source = \Drupal::languageManager()->getLanguage($source); + $target = \Drupal::languageManager()->getLanguage($target); return content_translation_add_page($entity, $source, $target); } @@ -40,7 +40,7 @@ public function add(Request $request, $source, $target) { public function edit(Request $request, $language) { $entity = $request->attributes->get($request->attributes->get('_entity_type_id')); module_load_include('pages.inc', 'content_translation'); - $language = language_load($language); + $language = \Drupal::languageManager()->getLanguage($language); return content_translation_edit_page($entity, $language); } diff --git a/core/modules/language/src/Plugin/views/field/LanguageField.php b/core/modules/language/src/Plugin/views/field/LanguageField.php index 3909fcd..9d9e27d 100644 --- a/core/modules/language/src/Plugin/views/field/LanguageField.php +++ b/core/modules/language/src/Plugin/views/field/LanguageField.php @@ -43,7 +43,7 @@ public function render(ResultRow $values) { // @todo: Drupal Core dropped native language until config translation is // ready, see http://drupal.org/node/1616594. $value = $this->getValue($values); - $language = language_load($value); + $language = \Drupal::languageManager()->getLanguage($value); return $language ? $language->name : ''; }