diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 07091c0..da51cb4 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -186,90 +186,6 @@ const DRUPAL_KILOBYTE = 1024; /** - * Special system language code (only applicable to UI language). - * - * Refers to the language used in Drupal and module/theme source code. Drupal - * uses the built-in text for English by default, but if configured to allow - * translation/customization of English, we need to differentiate between the - * built-in language and the English translation. - */ -const LANGUAGE_SYSTEM = 'system'; - -/** - * The language code used when no language is explicitly assigned (yet). - * - * Should be used when language information is not available or cannot be - * determined. This special language code is useful when we know the data - * might have linguistic information, but we don't know the language. - * - * See http://www.w3.org/International/questions/qa-no-language#undetermined. - */ -const LANGUAGE_NOT_SPECIFIED = 'und'; - -/** - * The language code used when the marked object has no linguistic content. - * - * Should be used when we explicitly know that the data referred has no - * linguistic content. - * - * See http://www.w3.org/International/questions/qa-no-language#nonlinguistic. - */ -const LANGUAGE_NOT_APPLICABLE = 'zxx'; - -/** - * Language code referring to the default language of data, e.g. of an entity. - * - * @todo: Change value to differ from LANGUAGE_NOT_SPECIFIED once field API - * leverages the property API. - */ -const LANGUAGE_DEFAULT = 'und'; - -/** - * The language state when referring to configurable languages. - */ -const LANGUAGE_CONFIGURABLE = 1; - -/** - * The language state when referring to locked languages. - */ -const LANGUAGE_LOCKED = 2; - -/** - * The language state used when referring to all languages. - */ -const LANGUAGE_ALL = 3; - -/** - * The language state used when referring to the site's default language. - */ -const LANGUAGE_SITE_DEFAULT = 4; - -/** - * The type of language used to define the content language. - */ -const LANGUAGE_TYPE_CONTENT = 'language_content'; - -/** - * The type of language used to select the user interface. - */ -const LANGUAGE_TYPE_INTERFACE = 'language_interface'; - -/** - * The type of language used for URLs. - */ -const LANGUAGE_TYPE_URL = 'language_url'; - -/** - * Language written left to right. Possible value of $language->direction. - */ -const LANGUAGE_LTR = 0; - -/** - * Language written right to left. Possible value of $language->direction. - */ -const LANGUAGE_RTL = 1; - -/** * Indicates an error during check for PHP unicode support. */ const UNICODE_ERROR = -1; @@ -1485,7 +1401,7 @@ function t($string, array $args = array(), array $options = array()) { // Merge in default. if (empty($options['langcode'])) { - $options['langcode'] = language(LANGUAGE_TYPE_INTERFACE)->langcode; + $options['langcode'] = language(Language::LANGUAGE_TYPE_INTERFACE)->langcode; } if (empty($options['context'])) { $options['context'] = ''; @@ -1503,7 +1419,7 @@ function t($string, array $args = array(), array $options = array()) { $string = $custom_strings[$options['langcode']][$options['context']][$string]; } // Translate with locale module if enabled. - elseif ($options['langcode'] != LANGUAGE_SYSTEM && ($options['langcode'] != 'en' || variable_get('locale_translate_english', FALSE)) && function_exists('locale')) { + elseif ($options['langcode'] != Language::LANGUAGE_SYSTEM && ($options['langcode'] != 'en' || variable_get('locale_translate_english', FALSE)) && function_exists('locale')) { $string = locale($string, $options['context'], $options['langcode']); } if (empty($args)) { @@ -2653,9 +2569,9 @@ function language_types_get_all() { */ function language_types_get_default() { return array( - LANGUAGE_TYPE_INTERFACE => TRUE, - LANGUAGE_TYPE_CONTENT => FALSE, - LANGUAGE_TYPE_URL => FALSE, + Language::LANGUAGE_TYPE_INTERFACE => TRUE, + Language::LANGUAGE_TYPE_CONTENT => FALSE, + Language::LANGUAGE_TYPE_URL => FALSE, ); } @@ -2677,13 +2593,13 @@ function language_multilingual() { * * @param $flags * (optional) Specifies the state of the languages that have to be returned. - * It can be: LANGUAGE_CONFIGURABLE, LANGUAGE_LOCKED, LANGUAGE_ALL. + * It can be: Language::LANGUAGE_CONFIGURABLE, Language::LANGUAGE_LOCKED, Language::LANGUAGE_ALL. * * @return array * An associative array of languages, keyed by the language code, ordered by * weight ascending and name ascending. */ -function language_list($flags = LANGUAGE_CONFIGURABLE) { +function language_list($flags = Language::LANGUAGE_CONFIGURABLE) { $languages = &drupal_static(__FUNCTION__); @@ -2719,7 +2635,7 @@ function language_list($flags = LANGUAGE_CONFIGURABLE) { $filtered_languages = array(); // Add the site's default language if flagged as allowed value. - if ($flags & LANGUAGE_SITE_DEFAULT) { + if ($flags & Language::LANGUAGE_SITE_DEFAULT) { $default = isset($default) ? $default : language_default(); // Rename the default language. $default->name = t("Site's default language (@lang_name)", array('@lang_name' => $default->name)); @@ -2727,7 +2643,7 @@ function language_list($flags = LANGUAGE_CONFIGURABLE) { } foreach ($languages as $langcode => $language) { - if (($language->locked && !($flags & LANGUAGE_LOCKED)) || (!$language->locked && !($flags & LANGUAGE_CONFIGURABLE))) { + if (($language->locked && !($flags & Language::LANGUAGE_LOCKED)) || (!$language->locked && !($flags & Language::LANGUAGE_CONFIGURABLE))) { continue; } $filtered_languages[$langcode] = $language; @@ -2754,13 +2670,13 @@ function language_default_locked_languages($weight = 0) { ); $languages = array(); - $languages[LANGUAGE_NOT_SPECIFIED] = new Language(array( - 'langcode' => LANGUAGE_NOT_SPECIFIED, + $languages[Language::LANGUAGE_NOT_SPECIFIED] = new Language(array( + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, 'name' => t('Not specified'), 'weight' => ++$weight, ) + $locked_language); - $languages[LANGUAGE_NOT_APPLICABLE] = new Language(array( - 'langcode' => LANGUAGE_NOT_APPLICABLE, + $languages[Language::LANGUAGE_NOT_APPLICABLE] = new Language(array( + 'langcode' => Language::LANGUAGE_NOT_APPLICABLE, 'name' => t('Not applicable'), 'weight' => ++$weight, ) + $locked_language); @@ -2777,7 +2693,7 @@ function language_default_locked_languages($weight = 0) { * A fully-populated language object or FALSE. */ function language_load($langcode) { - $languages = language_list(LANGUAGE_ALL); + $languages = language_list(Language::LANGUAGE_ALL); return isset($languages[$langcode]) ? $languages[$langcode] : FALSE; } @@ -2791,7 +2707,7 @@ function language_load($langcode) { * The printed name of the language. */ function language_name($langcode) { - if ($langcode == LANGUAGE_NOT_SPECIFIED) { + if ($langcode == Language::LANGUAGE_NOT_SPECIFIED) { return t('None'); } diff --git a/core/includes/common.inc b/core/includes/common.inc index b13c3bc..4a0fd54 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -1,5 +1,6 @@ langcode; + $langcode = $langcode ? $langcode : language(Language::LANGUAGE_TYPE_CONTENT)->langcode; $output = "\n"; $output .= ' ' . check_plain($title) . "\n"; @@ -1869,7 +1870,7 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL } if (empty($langcode)) { - $langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode; + $langcode = language(Language::LANGUAGE_TYPE_INTERFACE)->langcode; } // Create a DrupalDateTime object from the timestamp and timezone. @@ -1993,7 +1994,7 @@ function _format_date_callback(array $matches = NULL, $new_langcode = NULL) { * - 'language': An optional language object. If the path being linked to is * internal to the site, $options['language'] is used to look up the alias * for the URL. If $options['language'] is omitted, the language will be - * obtained from language(LANGUAGE_TYPE_URL). + * obtained from language(Language::LANGUAGE_TYPE_URL). * - 'https': Whether this URL should point to a secure location. If not * defined, the current scheme is used, so the user stays on HTTP or HTTPS * respectively. TRUE enforces HTTPS and FALSE enforces HTTP, but HTTPS can @@ -2216,7 +2217,7 @@ function l($text, $path, array $options = array()) { // same request with different query parameters may yield a different page // (e.g., pagers). $is_active = ($path == current_path() || ($path == '' && drupal_is_front_page())); - $is_active = $is_active && (empty($options['language']) || $options['language']->langcode == language(LANGUAGE_TYPE_URL)->langcode); + $is_active = $is_active && (empty($options['language']) || $options['language']->langcode == language(Language::LANGUAGE_TYPE_URL)->langcode); $is_active = $is_active && (drupal_container()->get('request')->query->all() == $options['query']); if ($is_active) { $options['attributes']['class'][] = 'active'; diff --git a/core/includes/language.inc b/core/includes/language.inc index 74d5752..503d973 100644 --- a/core/includes/language.inc +++ b/core/includes/language.inc @@ -7,6 +7,8 @@ * @see http://drupal.org/node/1497272 */ +use Drupal\Core\Language\Language; + /** * No language negotiation. The default language is used. */ @@ -46,7 +48,7 @@ * configurable: * @code * function mymodule_language_types_info_alter(&$language_types) { - * unset($language_types[LANGUAGE_TYPE_CONTENT]['fixed']); + * unset($language_types[Language::LANGUAGE_TYPE_CONTENT]['fixed']); * } * @endcode * @@ -528,18 +530,18 @@ function language_url_split_prefix($path, $languages) { * Returns the possible fallback languages ordered by language weight. * * @param - * (optional) The language type. Defaults to LANGUAGE_TYPE_CONTENT. + * (optional) The language type. Defaults to Language::LANGUAGE_TYPE_CONTENT. * * @return * An array of language codes. */ -function language_fallback_get_candidates($type = LANGUAGE_TYPE_CONTENT) { +function language_fallback_get_candidates($type = Language::LANGUAGE_TYPE_CONTENT) { $fallback_candidates = &drupal_static(__FUNCTION__); if (!isset($fallback_candidates)) { - // Get languages ordered by weight, add LANGUAGE_NOT_SPECIFIED at the end. + // Get languages ordered by weight, add Language::LANGUAGE_NOT_SPECIFIED at the end. $fallback_candidates = array_keys(language_list()); - $fallback_candidates[] = LANGUAGE_NOT_SPECIFIED; + $fallback_candidates[] = Language::LANGUAGE_NOT_SPECIFIED; // Let other modules hook in and add/change candidates. drupal_alter('language_fallback_candidates', $fallback_candidates); diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 6492b10..575546b 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -6,6 +6,7 @@ */ use Drupal\Core\Cache\CacheBackendInterface; +use Drupal\Core\Language\Language; use Drupal\Core\Template\Attribute; /** @@ -1075,7 +1076,7 @@ function menu_tree_output($tree) { */ function menu_tree_all_data($menu_name, $link = NULL, $max_depth = NULL) { $tree = &drupal_static(__FUNCTION__, array()); - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); // Use $mlid as a flag for whether the data being loaded is for the whole tree. $mlid = isset($link['mlid']) ? $link['mlid'] : 0; @@ -1186,7 +1187,7 @@ function menu_tree_get_path($menu_name) { function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail = FALSE) { $tree = &drupal_static(__FUNCTION__, array()); - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); // Check if the active trail has been overridden for this menu tree. $active_path = menu_tree_get_path($menu_name); @@ -1342,7 +1343,7 @@ function menu_build_tree($menu_name, array $parameters = array()) { function _menu_build_tree($menu_name, array $parameters = array()) { // Static cache of already built menu trees. $trees = &drupal_static(__FUNCTION__, array()); - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); // Build the cache id; sort parents to prevent duplicate storage and remove // default parameter values. diff --git a/core/includes/standard.inc b/core/includes/standard.inc index 63f3d70..208c675 100644 --- a/core/includes/standard.inc +++ b/core/includes/standard.inc @@ -5,6 +5,8 @@ * Provides a list of countries and languages based on web standards. */ +use Drupal\Core\Language\Language; + /** * Get an array of all country code => country name pairs. * @@ -303,7 +305,7 @@ function standard_language_list() { return array( 'af' => array('Afrikaans', 'Afrikaans'), 'am' => array('Amharic', 'አማርኛ'), - 'ar' => array('Arabic', /* Left-to-right marker "‭" */ 'العربية', LANGUAGE_RTL), + 'ar' => array('Arabic', /* Left-to-right marker "‭" */ 'العربية', Language::LANGUAGE_RTL), 'ast' => array('Asturian', 'Asturianu'), 'az' => array('Azerbaijani', 'Azərbaycanca'), 'be' => array('Belarusian', 'Беларуская'), @@ -324,7 +326,7 @@ function standard_language_list() { 'es' => array('Spanish', 'Español'), 'et' => array('Estonian', 'Eesti'), 'eu' => array('Basque', 'Euskera'), - 'fa' => array('Persian, Farsi', /* Left-to-right marker "‭" */ 'فارسی', LANGUAGE_RTL), + 'fa' => array('Persian, Farsi', /* Left-to-right marker "‭" */ 'فارسی', Language::LANGUAGE_RTL), 'fi' => array('Finnish', 'Suomi'), 'fil' => array('Filipino', 'Filipino'), 'fo' => array('Faeroese', 'Føroyskt'), @@ -334,7 +336,7 @@ function standard_language_list() { 'gl' => array('Galician', 'Galego'), 'gsw-berne' => array('Swiss German', 'Schwyzerdütsch'), 'gu' => array('Gujarati', 'ગુજરાતી'), - 'he' => array('Hebrew', /* Left-to-right marker "‭" */ 'עברית', LANGUAGE_RTL), + 'he' => array('Hebrew', /* Left-to-right marker "‭" */ 'עברית', Language::LANGUAGE_RTL), 'hi' => array('Hindi', 'हिन्दी'), 'hr' => array('Croatian', 'Hrvatski'), 'ht' => array('Haitian Creole', 'Kreyòl ayisyen'), @@ -394,7 +396,7 @@ function standard_language_list() { 'tyv' => array('Tuvan', 'Тыва дыл'), 'ug' => array('Uyghur', 'Уйғур'), 'uk' => array('Ukrainian', 'Українська'), - 'ur' => array('Urdu', /* Left-to-right marker "‭" */ 'اردو', LANGUAGE_RTL), + 'ur' => array('Urdu', /* Left-to-right marker "‭" */ 'اردو', Language::LANGUAGE_RTL), 'vi' => array('Vietnamese', 'Tiếng Việt'), 'xx-lolspeak' => array('Lolspeak', 'Lolspeak'), 'zh-hans' => array('Chinese, Simplified', '简体中文'), diff --git a/core/includes/theme.inc b/core/includes/theme.inc index da8b328..43f9ee2 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -9,6 +9,7 @@ */ use Drupal\Core\Cache\CacheBackendInterface; +use Drupal\Core\Language\Language; use Drupal\Core\Template\Attribute; use Drupal\Core\Utility\ThemeRegistry; @@ -1684,7 +1685,7 @@ function theme_link($variables) { * http://www.w3.org/TR/WCAG-TECHS/H42.html for more information. */ function theme_links($variables) { - $language_url = language(LANGUAGE_TYPE_URL); + $language_url = language(Language::LANGUAGE_TYPE_URL); $links = $variables['links']; $attributes = $variables['attributes']; diff --git a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php index 6d60656..5da8a68 100644 --- a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php +++ b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Datetime; use Drupal\Component\Datetime\DateTimePlus; +use Drupal\Core\Language\Language; /** * Extends DateTimePlus(). @@ -59,7 +60,7 @@ class DrupalDateTime extends DateTimePlus { public function __construct($time = 'now', $timezone = NULL, $format = NULL, $settings = array()) { // We can set the langcode and country using Drupal values. - $settings['langcode'] = !empty($settings['langcode']) ? $settings['langcode'] : language(LANGUAGE_TYPE_INTERFACE)->langcode; + $settings['langcode'] = !empty($settings['langcode']) ? $settings['langcode'] : language(Language::LANGUAGE_TYPE_INTERFACE)->langcode; $settings['country'] = !empty($settings['country']) ? $settings['country'] : config('system.date')->get('country.default'); // Instantiate the parent class. diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php index 10a7a77..aa35244 100644 --- a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php +++ b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Entity; +use Drupal\Core\Language\Language; use PDO; use Drupal\Core\Entity\EntityInterface; @@ -154,7 +155,7 @@ protected function mapFromStorageRecords(array $records, $load_revision = FALSE) $entity->setCompatibilityMode(TRUE); foreach ($record as $name => $value) { - $entity->{$name}[LANGUAGE_DEFAULT][0]['value'] = $value; + $entity->{$name}[Language::LANGUAGE_DEFAULT][0]['value'] = $value; } $records[$id] = $entity; } diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 1b511e1..0ce9cc4 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -26,7 +26,7 @@ class Entity implements IteratorAggregate, EntityInterface { * * @var string */ - public $langcode = LANGUAGE_NOT_SPECIFIED; + public $langcode = Language::LANGUAGE_NOT_SPECIFIED; /** * The entity type. @@ -253,7 +253,7 @@ public function getIterator() { */ public function access($operation = 'view', \Drupal\user\Plugin\Core\Entity\User $account = NULL) { $method = $operation . 'Access'; - return entity_access_controller($this->entityType)->$method($this, LANGUAGE_DEFAULT, $account); + return entity_access_controller($this->entityType)->$method($this, Language::LANGUAGE_DEFAULT, $account); } /** @@ -262,7 +262,7 @@ public function access($operation = 'view', \Drupal\user\Plugin\Core\Entity\User public function language() { // @todo: Replace by EntityNG implementation once all entity types have been // converted to use the entity field API. - return !empty($this->langcode) ? language_load($this->langcode) : new Language(array('langcode' => LANGUAGE_NOT_SPECIFIED)); + return !empty($this->langcode) ? language_load($this->langcode) : new Language(array('langcode' => Language::LANGUAGE_NOT_SPECIFIED)); } /** diff --git a/core/lib/Drupal/Core/Entity/EntityAccessController.php b/core/lib/Drupal/Core/Entity/EntityAccessController.php index 2f13110..7c5f5b8 100644 --- a/core/lib/Drupal/Core/Entity/EntityAccessController.php +++ b/core/lib/Drupal/Core/Entity/EntityAccessController.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Entity; +use Drupal\Core\Language\Language; use Drupal\user\Plugin\Core\Entity\User; /** @@ -20,28 +21,28 @@ class EntityAccessController implements EntityAccessControllerInterface { /** * Implements EntityAccessControllerInterface::viewAccess(). */ - public function viewAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAULT, User $account = NULL) { + public function viewAccess(EntityInterface $entity, $langcode = Language::LANGUAGE_DEFAULT, User $account = NULL) { return FALSE; } /** * Implements EntityAccessControllerInterface::createAccess(). */ - public function createAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAULT, User $account = NULL) { + public function createAccess(EntityInterface $entity, $langcode = Language::LANGUAGE_DEFAULT, User $account = NULL) { return FALSE; } /** * Implements EntityAccessControllerInterface::updateAccess(). */ - public function updateAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAULT, User $account = NULL) { + public function updateAccess(EntityInterface $entity, $langcode = Language::LANGUAGE_DEFAULT, User $account = NULL) { return FALSE; } /** * Implements EntityAccessControllerInterface::deleteAccess(). */ - public function deleteAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAULT, User $account = NULL) { + public function deleteAccess(EntityInterface $entity, $langcode = Language::LANGUAGE_DEFAULT, User $account = NULL) { return FALSE; } diff --git a/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php b/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php index 5bbc996..b256eb3 100644 --- a/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Entity; // @todo Don't depend on module level code. +use Drupal\Core\Language\Language; use Drupal\user\Plugin\Core\Entity\User; /** @@ -22,7 +23,7 @@ * The entity for which to check 'view' access. * @param string $langcode * (optional) The language code for which to check access. Defaults to - * LANGUAGE_DEFAULT. + * Language::LANGUAGE_DEFAULT. * @param \Drupal\user\Plugin\Core\Entity\User $account * (optional) The user for which to check access, or NULL to check access * for the current user. Defaults to NULL. @@ -30,7 +31,7 @@ * @return bool * TRUE if access was granted, FALSE otherwise. */ - public function viewAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAULT, User $account = NULL); + public function viewAccess(EntityInterface $entity, $langcode = Language::LANGUAGE_DEFAULT, User $account = NULL); /** * Checks 'create' access for a given entity or entity translation. @@ -39,7 +40,7 @@ public function viewAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAULT * The entity for which to check 'create' access. * @param string $langcode * (optional) The language code for which to check access. Defaults to - * LANGUAGE_DEFAULT. + * Language::LANGUAGE_DEFAULT. * @param \Drupal\user\Plugin\Core\Entity\User $account * (optional) The user for which to check access, or NULL to check access * for the current user. Defaults to NULL. @@ -47,7 +48,7 @@ public function viewAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAULT * @return bool * TRUE if access was granted, FALSE otherwise. */ - public function createAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAULT, User $account = NULL); + public function createAccess(EntityInterface $entity, $langcode = Language::LANGUAGE_DEFAULT, User $account = NULL); /** * Checks 'update' access for a given entity or entity translation. @@ -56,7 +57,7 @@ public function createAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAU * The entity to check 'update' access. * @param string $langcode * (optional) The language code for which to check access. Defaults to - * LANGUAGE_DEFAULT. + * Language::LANGUAGE_DEFAULT. * @param \Drupal\user\Plugin\Core\Entity\User $account * (optional) The user for which to check access, or NULL to check access * for the current user. Defaults to NULL. @@ -64,7 +65,7 @@ public function createAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAU * @return bool * TRUE if access was granted, FALSE otherwise. */ - public function updateAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAULT, User $account = NULL); + public function updateAccess(EntityInterface $entity, $langcode = Language::LANGUAGE_DEFAULT, User $account = NULL); /** * Checks 'delete' access for a given entity or entity translation. @@ -73,7 +74,7 @@ public function updateAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAU * The entity for which to check 'delete' access. * @param string $langcode * (optional) The language code for which to check access. Defaults to - * LANGUAGE_DEFAULT. + * Language::LANGUAGE_DEFAULT. * @param \Drupal\user\Plugin\Core\Entity\User $account * (optional) The user for which to check access, or NULL to check access * for the current user. Defaults to NULL. @@ -81,5 +82,5 @@ public function updateAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAU * @return bool * TRUE if access was granted, FALSE otherwise. */ - public function deleteAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAULT, User $account = NULL); + public function deleteAccess(EntityInterface $entity, $langcode = Language::LANGUAGE_DEFAULT, User $account = NULL); } diff --git a/core/lib/Drupal/Core/Entity/EntityFormController.php b/core/lib/Drupal/Core/Entity/EntityFormController.php index 4e0fc6a..6df7f7a 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormController.php +++ b/core/lib/Drupal/Core/Entity/EntityFormController.php @@ -7,6 +7,8 @@ namespace Drupal\Core\Entity; +use Drupal\Core\Language\Language; + /** * Base class for entity form controllers. */ @@ -231,7 +233,7 @@ public function getFormLangcode(array $form_state) { // If no form langcode was provided we default to the current content // language and inspect existing translations to find a valid fallback, // if any. - $langcode = language(LANGUAGE_TYPE_CONTENT)->langcode; + $langcode = language(Language::LANGUAGE_TYPE_CONTENT)->langcode; $fallback = language_multilingual() ? language_fallback_get_candidates() : array(); while (!empty($langcode) && !isset($translations[$langcode])) { $langcode = array_shift($fallback); diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 1fcf266..07d98e2 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -10,6 +10,7 @@ use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\Factory\DefaultFactory; use Drupal\Component\Plugin\Discovery\ProcessDecorator; +use Drupal\Core\Language\Language; use Drupal\Core\Plugin\Discovery\AlterDecorator; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery; use Drupal\Core\Plugin\Discovery\InfoHookDecorator; @@ -237,7 +238,7 @@ public function __construct() { // Entity type plugins includes translated strings, so each language is // cached separately. - $this->cacheKey .= ':' . language(LANGUAGE_TYPE_INTERFACE)->langcode; + $this->cacheKey .= ':' . language(Language::LANGUAGE_TYPE_INTERFACE)->langcode; } /** diff --git a/core/lib/Drupal/Core/Entity/EntityNG.php b/core/lib/Drupal/Core/Entity/EntityNG.php index c486aa8..71abee8 100644 --- a/core/lib/Drupal/Core/Entity/EntityNG.php +++ b/core/lib/Drupal/Core/Entity/EntityNG.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Entity; +use Drupal\Core\Language\Language; use Drupal\Core\TypedData\ContextAwareInterface; use Drupal\Core\TypedData\TypedDataInterface; use Drupal\Component\Uuid\Uuid; @@ -29,7 +30,7 @@ class EntityNG extends Entity { * The plain data values of the contained fields. * * This always holds the original, unchanged values of the entity. The values - * are keyed by language code, whereas LANGUAGE_NOT_SPECIFIED is used for + * are keyed by language code, whereas Language::LANGUAGE_NOT_SPECIFIED is used for * values in default language. * * @todo: Add methods for getting original fields and for determining @@ -39,7 +40,7 @@ class EntityNG extends Entity { * @var array */ protected $values = array( - 'langcode' => array(LANGUAGE_DEFAULT => array(0 => array('value' => LANGUAGE_NOT_SPECIFIED))), + 'langcode' => array(Language::LANGUAGE_DEFAULT => array(0 => array('value' => Language::LANGUAGE_NOT_SPECIFIED))), ); /** @@ -79,12 +80,12 @@ public function uuid() { * Implements ComplexDataInterface::get(). */ public function get($property_name) { - // Values in default language are always stored using the LANGUAGE_DEFAULT + // Values in default language are always stored using the Language::LANGUAGE_DEFAULT // constant. - if (!isset($this->fields[$property_name][LANGUAGE_DEFAULT])) { - return $this->getTranslatedField($property_name, LANGUAGE_DEFAULT); + if (!isset($this->fields[$property_name][Language::LANGUAGE_DEFAULT])) { + return $this->getTranslatedField($property_name, Language::LANGUAGE_DEFAULT); } - return $this->fields[$property_name][LANGUAGE_DEFAULT]; + return $this->fields[$property_name][Language::LANGUAGE_DEFAULT]; } /** @@ -101,8 +102,8 @@ protected function getTranslatedField($property_name, $langcode) { throw new InvalidArgumentException('Field ' . check_plain($property_name) . ' is unknown.'); } // Non-translatable properties always use default language. - if ($langcode != LANGUAGE_DEFAULT && empty($definition['translatable'])) { - $this->fields[$property_name][$langcode] = $this->getTranslatedField($property_name, LANGUAGE_DEFAULT); + if ($langcode != Language::LANGUAGE_DEFAULT && empty($definition['translatable'])) { + $this->fields[$property_name][$langcode] = $this->getTranslatedField($property_name, Language::LANGUAGE_DEFAULT); } else { $value = isset($this->values[$property_name][$langcode]) ? $this->values[$property_name][$langcode] : NULL; @@ -217,15 +218,15 @@ public function language() { * @return \Drupal\Core\Entity\Field\Type\EntityTranslation */ public function getTranslation($langcode, $strict = TRUE) { - // If the default language is LANGUAGE_NOT_SPECIFIED, the entity is not - // translatable, so we use LANGUAGE_DEFAULT. - if ($langcode == LANGUAGE_DEFAULT || in_array($this->language()->langcode, array(LANGUAGE_NOT_SPECIFIED, $langcode))) { + // If the default language is Language::LANGUAGE_NOT_SPECIFIED, the entity is not + // translatable, so we use Language::Language::LANGUAGE_DEFAULT. + if ($langcode == Language::Language::LANGUAGE_DEFAULT || in_array($this->language()->langcode, array(Language::LANGUAGE_NOT_SPECIFIED, $langcode))) { // No translation needed, return the entity. return $this; } // Check whether the language code is valid, thus is of an available // language. - $languages = language_list(LANGUAGE_ALL); + $languages = language_list(Language::LANGUAGE_ALL); if (!isset($languages[$langcode])) { throw new InvalidArgumentException("Unable to get translation for the invalid language '$langcode'."); } @@ -263,7 +264,7 @@ public function getTranslationLanguages($include_default = TRUE) { } $translations += $this->fields[$name]; } - unset($translations[LANGUAGE_DEFAULT]); + unset($translations[Language::LANGUAGE_DEFAULT]); if ($include_default) { $translations[$this->language()->langcode] = TRUE; @@ -271,7 +272,7 @@ public function getTranslationLanguages($include_default = TRUE) { // Now get languages based upon translation langcodes. Empty languages must // be filtered out as they concern empty/unset properties. - $languages = array_intersect_key(language_list(LANGUAGE_ALL), array_filter($translations)); + $languages = array_intersect_key(language_list(Language::LANGUAGE_ALL), array_filter($translations)); return $languages; } @@ -324,8 +325,8 @@ public function &__get($name) { } return $this->values[$name]; } - if (isset($this->fields[$name][LANGUAGE_DEFAULT])) { - return $this->fields[$name][LANGUAGE_DEFAULT]; + if (isset($this->fields[$name][Language::LANGUAGE_DEFAULT])) { + return $this->fields[$name][Language::LANGUAGE_DEFAULT]; } if ($this->getPropertyDefinition($name)) { $return = $this->get($name); @@ -349,8 +350,8 @@ public function __set($name, $value) { if ($this->compatibilityMode) { $this->values[$name] = $value; } - elseif (isset($this->fields[$name][LANGUAGE_DEFAULT])) { - $this->fields[$name][LANGUAGE_DEFAULT]->setValue($value); + elseif (isset($this->fields[$name][Language::LANGUAGE_DEFAULT])) { + $this->fields[$name][Language::LANGUAGE_DEFAULT]->setValue($value); } elseif ($this->getPropertyDefinition($name)) { $this->get($name)->setValue($value); diff --git a/core/lib/Drupal/Core/Entity/EntityRenderController.php b/core/lib/Drupal/Core/Entity/EntityRenderController.php index eb3147e..7e5d1f3 100644 --- a/core/lib/Drupal/Core/Entity/EntityRenderController.php +++ b/core/lib/Drupal/Core/Entity/EntityRenderController.php @@ -7,6 +7,8 @@ namespace Drupal\Core\Entity; +use Drupal\Core\Language\Language; + /** * Base class for entity view controllers. */ @@ -143,7 +145,7 @@ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = N */ public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) { if (!isset($langcode)) { - $langcode = language(LANGUAGE_TYPE_CONTENT)->langcode; + $langcode = language(Language::LANGUAGE_TYPE_CONTENT)->langcode; } $this->buildContent($entities, $view_mode, $langcode); diff --git a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php index f29e0b0..425b906 100644 --- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php @@ -7,6 +7,7 @@ namespace Drupal\Core\EventSubscriber; +use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManager; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; @@ -50,10 +51,10 @@ public function onRespond(FilterResponseEvent $event) { // Set the X-UA-Compatible HTTP header to force IE to use the most recent // rendering engine or use Chrome's frame rendering engine if available. - $response->headers->set('X-UA-Compatible', 'IE=edge,chrome=1', false); + $response->headers->set('X-UA-Compatible', 'IE=edge,chrome=1', FALSE); // Set the Content-language header. - $response->headers->set('Content-language', $this->languageManager->getLanguage(LANGUAGE_TYPE_INTERFACE)->langcode); + $response->headers->set('Content-language', $this->languageManager->getLanguage(Language::LANGUAGE_TYPE_INTERFACE)->langcode); // Because pages are highly dynamic, set the last-modified time to now // since the page is in fact being regenerated right now. diff --git a/core/lib/Drupal/Core/Language/Language.php b/core/lib/Drupal/Core/Language/Language.php index 4db85da..1269e1f 100644 --- a/core/lib/Drupal/Core/Language/Language.php +++ b/core/lib/Drupal/Core/Language/Language.php @@ -20,13 +20,97 @@ class Language { // Properties within the Language are set up as the default language. public $name = ''; public $langcode = ''; - public $direction = LANGUAGE_LTR; + public $direction = static::LANGUAGE_LTR; public $weight = 0; public $default = FALSE; public $method_id = NULL; public $locked = FALSE; /** + * Special system language code (only applicable to UI language). + * + * Refers to the language used in Drupal and module/theme source code. Drupal + * uses the built-in text for English by default, but if configured to allow + * translation/customization of English, we need to differentiate between the + * built-in language and the English translation. + */ + const LANGUAGE_SYSTEM = 'system'; + + /** + * The language code used when no language is explicitly assigned (yet). + * + * Should be used when language information is not available or cannot be + * determined. This special language code is useful when we know the data + * might have linguistic information, but we don't know the language. + * + * See http://www.w3.org/International/questions/qa-no-language#undetermined. + */ + const LANGUAGE_NOT_SPECIFIED = 'und'; + + /** + * The language code used when the marked object has no linguistic content. + * + * Should be used when we explicitly know that the data referred has no + * linguistic content. + * + * See http://www.w3.org/International/questions/qa-no-language#nonlinguistic. + */ + const LANGUAGE_NOT_APPLICABLE = 'zxx'; + + /** + * Language code referring to the default language of data, e.g. of an entity. + * + * @todo: Change value to differ from Language::LANGUAGE_NOT_SPECIFIED once field API + * leverages the property API. + */ + const LANGUAGE_DEFAULT = 'und'; + + /** + * The language state when referring to configurable languages. + */ + const LANGUAGE_CONFIGURABLE = 1; + + /** + * The language state when referring to locked languages. + */ + const LANGUAGE_LOCKED = 2; + + /** + * The language state used when referring to all languages. + */ + const LANGUAGE_ALL = 3; + + /** + * The language state used when referring to the site's default language. + */ + const LANGUAGE_SITE_DEFAULT = 4; + + /** + * The type of language used to define the content language. + */ + const LANGUAGE_TYPE_CONTENT = 'language_content'; + + /** + * The type of language used to select the user interface. + */ + const LANGUAGE_TYPE_INTERFACE = 'language_interface'; + + /** + * The type of language used for URLs. + */ + const LANGUAGE_TYPE_URL = 'language_url'; + + /** + * Language written left to right. Possible value of $language->direction. + */ + const LANGUAGE_LTR = 0; + + /** + * Language written right to left. Possible value of $language->direction. + */ + const LANGUAGE_RTL = 1; + + /** * Language constructor builds the default language object. * * @param array $options diff --git a/core/lib/Drupal/Core/Path/AliasManager.php b/core/lib/Drupal/Core/Path/AliasManager.php index 47bf77b..712a0fe 100644 --- a/core/lib/Drupal/Core/Path/AliasManager.php +++ b/core/lib/Drupal/Core/Path/AliasManager.php @@ -9,6 +9,7 @@ use Drupal\Core\Database\Connection; use Drupal\Core\KeyValueStore\KeyValueFactory; +use Drupal\Core\Language\Language; class AliasManager implements AliasManagerInterface { @@ -81,7 +82,7 @@ class AliasManager implements AliasManagerInterface { public function __construct(Connection $connection, KeyValueFactory $keyvalue) { $this->connection = $connection; $this->state = $keyvalue->get('state'); - $this->langcode = language(LANGUAGE_TYPE_URL)->langcode; + $this->langcode = language(Language::LANGUAGE_TYPE_URL)->langcode; $this->whitelist = $this->state->get('system.path_alias_whitelist', NULL); if (!isset($this->whitelist)) { $this->whitelist = $this->pathAliasWhitelistRebuild(); @@ -178,7 +179,7 @@ protected function lookupPathAlias($path, $langcode) { $args = array( ':system' => $this->preloadedPathLookups, ':langcode' => $langcode, - ':langcode_undetermined' => LANGUAGE_NOT_SPECIFIED, + ':langcode_undetermined' => Language::LANGUAGE_NOT_SPECIFIED, ); // Always get the language-specific alias before the language-neutral // one. For example 'de' is less than 'und' so the order needs to be @@ -187,12 +188,12 @@ protected function lookupPathAlias($path, $langcode) { // the most recently created alias for each source. Subsequent queries // using fetchField() must use pid DESC to have the same effect. // For performance reasons, the query builder is not used here. - if ($langcode == LANGUAGE_NOT_SPECIFIED) { + if ($langcode == Language::LANGUAGE_NOT_SPECIFIED) { // Prevent PDO from complaining about a token the query doesn't use. unset($args[':langcode']); $result = $this->connection->query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND langcode = :langcode_undetermined ORDER BY pid ASC', $args); } - elseif ($langcode < LANGUAGE_NOT_SPECIFIED) { + elseif ($langcode < Language::LANGUAGE_NOT_SPECIFIED) { $result = $this->connection->query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND langcode IN (:langcode, :langcode_undetermined) ORDER BY langcode ASC, pid ASC', $args); } else { @@ -218,14 +219,14 @@ protected function lookupPathAlias($path, $langcode) { $args = array( ':source' => $path, ':langcode' => $langcode, - ':langcode_undetermined' => LANGUAGE_NOT_SPECIFIED, + ':langcode_undetermined' => Language::LANGUAGE_NOT_SPECIFIED, ); // See the queries above. - if ($langcode == LANGUAGE_NOT_SPECIFIED) { + if ($langcode == Language::LANGUAGE_NOT_SPECIFIED) { unset($args[':langcode']); $alias = $this->connection->query("SELECT alias FROM {url_alias} WHERE source = :source AND langcode = :langcode_undetermined ORDER BY pid DESC", $args)->fetchField(); } - elseif ($langcode > LANGUAGE_NOT_SPECIFIED) { + elseif ($langcode > Language::LANGUAGE_NOT_SPECIFIED) { $alias = $this->connection->query("SELECT alias FROM {url_alias} WHERE source = :source AND langcode IN (:langcode, :langcode_undetermined) ORDER BY langcode DESC, pid DESC", $args)->fetchField(); } else { @@ -259,14 +260,14 @@ protected function lookupPathSource($path, $langcode) { $args = array( ':alias' => $path, ':langcode' => $langcode, - ':langcode_undetermined' => LANGUAGE_NOT_SPECIFIED, + ':langcode_undetermined' => Language::LANGUAGE_NOT_SPECIFIED, ); // See the queries above. - if ($langcode == LANGUAGE_NOT_SPECIFIED) { + if ($langcode == Language::LANGUAGE_NOT_SPECIFIED) { unset($args[':langcode']); $result = $this->connection->query("SELECT source FROM {url_alias} WHERE alias = :alias AND langcode = :langcode_undetermined ORDER BY pid DESC", $args); } - elseif ($langcode > LANGUAGE_NOT_SPECIFIED) { + elseif ($langcode > Language::LANGUAGE_NOT_SPECIFIED) { $result = $this->connection->query("SELECT source FROM {url_alias} WHERE alias = :alias AND langcode IN (:langcode, :langcode_undetermined) ORDER BY langcode DESC, pid DESC", $args); } else { diff --git a/core/lib/Drupal/Core/Path/Path.php b/core/lib/Drupal/Core/Path/Path.php index a7fd55a..e4ed4af 100644 --- a/core/lib/Drupal/Core/Path/Path.php +++ b/core/lib/Drupal/Core/Path/Path.php @@ -9,6 +9,7 @@ use Drupal\Core\Database\Database; use Drupal\Core\Database\Connection; +use Drupal\Core\Language\Language; /** * Defines a class for CRUD operations on path aliases. @@ -63,7 +64,7 @@ public function __construct(Connection $connection, AliasManager $alias_manager) * - pid: Unique path alias identifier. * - langcode: The language code of the alias. */ - public function save($source, $alias, $langcode = LANGUAGE_NOT_SPECIFIED, $pid = NULL) { + public function save($source, $alias, $langcode = Language::LANGUAGE_NOT_SPECIFIED, $pid = NULL) { $fields = array( 'source' => $source, diff --git a/core/lib/Drupal/Core/TypedData/TranslatableInterface.php b/core/lib/Drupal/Core/TypedData/TranslatableInterface.php index 975b870..e9aacca 100644 --- a/core/lib/Drupal/Core/TypedData/TranslatableInterface.php +++ b/core/lib/Drupal/Core/TypedData/TranslatableInterface.php @@ -40,7 +40,7 @@ public function getTranslationLanguages($include_default = TRUE); * AccessibleInterface, the translation object has to implement both as well. * * @param $langcode - * The language code of the translation to get or LANGUAGE_DEFAULT to get + * The language code of the translation to get or Language::LANGUAGE_DEFAULT to get * the data in default language. * @param $strict * (optional) If the data is complex, whether the translation should include diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php index f46c2c4..f8fb35f 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php @@ -7,6 +7,7 @@ namespace Drupal\aggregator\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -303,7 +304,7 @@ function getHtmlEntitiesSample() { * (optional) The number of nodes to generate. */ function createSampleNodes($count = 5) { - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Post $count article nodes. for ($i = 0; $i < $count; $i++) { $edit = array(); diff --git a/core/modules/block/block.admin.inc b/core/modules/block/block.admin.inc index f9fa425..690f20b 100644 --- a/core/modules/block/block.admin.inc +++ b/core/modules/block/block.admin.inc @@ -5,6 +5,8 @@ * Admin page callbacks for the block module. */ +use Drupal\Core\Language\Language; + /** * Page callback: Attaches CSS for the block region demo. * @@ -423,7 +425,7 @@ function block_admin_configure($form, &$form_state, $module, $delta) { } // Fetch languages. - $languages = language_list(LANGUAGE_ALL); + $languages = language_list(Language::LANGUAGE_ALL); foreach ($languages as $language) { // @TODO $language->name is not wrapped with t(), it should be replaced // by CMI translation implementation. diff --git a/core/modules/block/block.api.php b/core/modules/block/block.api.php index b734685..2f6f99f 100644 --- a/core/modules/block/block.api.php +++ b/core/modules/block/block.api.php @@ -5,6 +5,8 @@ * Hooks provided by the Block module. */ +use Drupal\Core\Language\Language; + /** * @addtogroup hooks * @{ @@ -330,7 +332,7 @@ function hook_block_view_MODULE_DELTA_alter(&$data, $block) { */ function hook_block_list_alter(&$blocks) { global $theme_key; - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); // This example shows how to achieve language specific visibility setting for // blocks. diff --git a/core/modules/book/book.admin.inc b/core/modules/book/book.admin.inc index 27f5cae..c5ae73e 100644 --- a/core/modules/book/book.admin.inc +++ b/core/modules/book/book.admin.inc @@ -5,6 +5,7 @@ * Admin page callbacks for the book module. */ +use Drupal\Core\Language\Language; use Drupal\node\Plugin\Core\Entity\Node; /** @@ -159,7 +160,7 @@ function book_admin_edit_submit($form, &$form_state) { // Update the title if changed. if ($row['title']['#default_value'] != $values['title']) { $node = node_load($values['nid']); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $node->title = $values['title']; $node->book['link_title'] = $values['title']; $node->setNewRevision(); diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 4e15fb3..ef30c29 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -5,6 +5,7 @@ * Allows users to create and organize related content in an outline. */ +use Drupal\Core\Language\Language; use Drupal\node\Plugin\Core\Entity\Node; use Drupal\Core\Template\Attribute; @@ -1205,12 +1206,12 @@ function book_toc($bid, $depth_limit, $exclude = array()) { */ function template_preprocess_book_export_html(&$variables) { global $base_url; - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); $variables['title'] = check_plain($variables['title']); $variables['base_url'] = $base_url; $variables['language'] = $language_interface; - $variables['language_rtl'] = ($language_interface->direction == LANGUAGE_RTL); + $variables['language_rtl'] = ($language_interface->direction == Language::LANGUAGE_RTL); $variables['head'] = drupal_get_html_head(); // HTML element attributes. diff --git a/core/modules/book/lib/Drupal/book/Tests/BookTest.php b/core/modules/book/lib/Drupal/book/Tests/BookTest.php index 5f50fe8..6422f99 100644 --- a/core/modules/book/lib/Drupal/book/Tests/BookTest.php +++ b/core/modules/book/lib/Drupal/book/Tests/BookTest.php @@ -7,6 +7,7 @@ namespace Drupal\book\Tests; +use Drupal\Core\Language\Language; use Drupal\node\Plugin\Core\Entity\Node; use Drupal\simpletest\WebTestBase; @@ -181,7 +182,7 @@ function checkBookNode(Node $node, $nodes, $previous = FALSE, $up = FALSE, $next // Check printer friendly version. $this->drupalGet('book/export/html/' . $node->nid); $this->assertText($node->label(), 'Printer friendly title found.'); - $this->assertRaw(check_markup($node->body[LANGUAGE_NOT_SPECIFIED][0]['value'], $node->body[LANGUAGE_NOT_SPECIFIED][0]['format']), 'Printer friendly body found.'); + $this->assertRaw(check_markup($node->body[Language::LANGUAGE_NOT_SPECIFIED][0]['value'], $node->body[Language::LANGUAGE_NOT_SPECIFIED][0]['format']), 'Printer friendly body found.'); $number++; } @@ -212,7 +213,7 @@ function createBookNode($book_nid, $parent = NULL) { static $number = 0; // Used to ensure that when sorted nodes stay in same order. $edit = array(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit["title"] = $number . ' - SimpleTest test node ' . $this->randomName(10); $edit["body[$langcode][0][value]"] = 'SimpleTest test body ' . $this->randomName(32) . ' ' . $this->randomName(32); $edit['book[bid]'] = $book_nid; @@ -250,7 +251,7 @@ function testBookExport() { // Make sure each part of the book is there. foreach ($nodes as $node) { $this->assertText($node->label(), 'Node title found in printer friendly version.'); - $this->assertRaw(check_markup($node->body[LANGUAGE_NOT_SPECIFIED][0]['value'], $node->body[LANGUAGE_NOT_SPECIFIED][0]['format']), 'Node body found in printer friendly version.'); + $this->assertRaw(check_markup($node->body[Language::LANGUAGE_NOT_SPECIFIED][0]['value'], $node->body[Language::LANGUAGE_NOT_SPECIFIED][0]['format']), 'Node body found in printer friendly version.'); } // Make sure we can't export an unsupported format. diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index 9baa5c5..3f5b34b 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -10,6 +10,7 @@ use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityFormController; +use Drupal\Core\Language\Language; /** * Base for controller for comment forms. @@ -177,7 +178,7 @@ public function form(array $form, array &$form_state, EntityInterface $comment) // Make the comment inherit the current content language unless specifically // set. if ($comment->isNew()) { - $language_content = language(LANGUAGE_TYPE_CONTENT); + $language_content = language(Language::LANGUAGE_TYPE_CONTENT); $comment->langcode = $language_content->langcode; } @@ -298,7 +299,7 @@ public function submit(array $form, array &$form_state) { // 2) Strip out all HTML tags // 3) Convert entities back to plain-text. $field = field_info_field('comment_body'); - $langcode = field_is_translatable('comment', $field) ? $this->getFormLangcode($form_state) : LANGUAGE_NOT_SPECIFIED; + $langcode = field_is_translatable('comment', $field) ? $this->getFormLangcode($form_state) : Language::LANGUAGE_NOT_SPECIFIED; $comment_body = $comment->comment_body[$langcode][0]; if (isset($comment_body['format'])) { $comment_text = check_markup($comment_body['value'], $comment_body['format']); diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php index e0bbfd9..e898b58 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php @@ -11,6 +11,7 @@ use Drupal\Core\Entity\Entity; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; +use Drupal\Core\Language\Language; /** * Defines the comment entity class. @@ -76,7 +77,7 @@ class Comment extends Entity implements ContentEntityInterface { * * @var string */ - public $langcode = LANGUAGE_NOT_SPECIFIED; + public $langcode = Language::LANGUAGE_NOT_SPECIFIED; /** * The comment title. diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentAnonymousTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentAnonymousTest.php index e78a963..573d01b 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentAnonymousTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentAnonymousTest.php @@ -7,6 +7,8 @@ namespace Drupal\comment\Tests; +use Drupal\Core\Language\Language; + /** * Tests anonymous commenting. */ @@ -66,7 +68,7 @@ function testAnonymous() { $this->assertTrue($this->commentExists($anonymous_comment2), 'Anonymous comment with contact info (optional) found.'); // Ensure anonymous users cannot post in the name of registered users. - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit = array( 'name' => $this->admin_user->name, 'mail' => $this->randomName() . '@example.com', diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php index 5cf0720..39cb8fd 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php @@ -7,6 +7,8 @@ namespace Drupal\comment\Tests; +use Drupal\Core\Language\Language; + /** * Tests comment CSS classes. */ @@ -53,8 +55,8 @@ function testCommentClasses() { 'uid' => $case['comment_uid'], 'status' => $case['comment_status'], 'subject' => $this->randomName(), - 'language' => LANGUAGE_NOT_SPECIFIED, - 'comment_body' => array(LANGUAGE_NOT_SPECIFIED => array($this->randomName())), + 'language' => Language::LANGUAGE_NOT_SPECIFIED, + 'comment_body' => array(Language::LANGUAGE_NOT_SPECIFIED => array($this->randomName())), )); comment_save($comment); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php index 1070107..c290190 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php @@ -7,6 +7,8 @@ namespace Drupal\comment\Tests; +use Drupal\Core\Language\Language; + /** * Tests the comment module administrative and end-user-facing interfaces. */ @@ -24,7 +26,7 @@ public static function getInfo() { * Tests the comment interface. */ function testCommentInterface() { - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Set comments to have subject and preview disabled. $this->drupalLogin($this->admin_user); $this->setCommentPreview(DRUPAL_DISABLED); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php index 474ae69..f03615f 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php @@ -7,6 +7,7 @@ namespace Drupal\comment\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -94,7 +95,7 @@ function testCommentLanguage() { // language and interface language do not influence comment language, as // only content language has to. foreach (language_list() as $node_langcode => $node_language) { - $langcode_not_specified = LANGUAGE_NOT_SPECIFIED; + $langcode_not_specified = Language::LANGUAGE_NOT_SPECIFIED; // Create "Article" content. $title = $this->randomName(); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php index d049aa3..5f77146 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php @@ -7,6 +7,8 @@ namespace Drupal\comment\Tests; +use Drupal\Core\Language\Language; + /** * Tests comment links based on environment configurations. */ @@ -135,8 +137,8 @@ function setEnvironment(array $info) { 'status' => COMMENT_PUBLISHED, 'subject' => $this->randomName(), 'hostname' => ip_address(), - 'langcode' => LANGUAGE_NOT_SPECIFIED, - 'comment_body' => array(LANGUAGE_NOT_SPECIFIED => array($this->randomName())), + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, + 'comment_body' => array(Language::LANGUAGE_NOT_SPECIFIED => array($this->randomName())), )); comment_save($comment); $this->comment = $comment; diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php index 324012e..60372fb 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php @@ -7,6 +7,8 @@ namespace Drupal\comment\Tests; +use Drupal\Core\Language\Language; + /** * Tests the 'new' marker on comments. */ @@ -44,8 +46,8 @@ public function testCommentNewCommentsIndicator() { 'status' => COMMENT_PUBLISHED, 'subject' => $this->randomName(), 'hostname' => ip_address(), - 'langcode' => LANGUAGE_NOT_SPECIFIED, - 'comment_body' => array(LANGUAGE_NOT_SPECIFIED => array($this->randomName())), + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, + 'comment_body' => array(Language::LANGUAGE_NOT_SPECIFIED => array($this->randomName())), )); comment_save($comment); $this->drupalLogout(); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeAccessTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeAccessTest.php index 37809c6..70c1ee5 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeAccessTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeAccessTest.php @@ -7,6 +7,7 @@ namespace Drupal\comment\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -52,7 +53,7 @@ function setUp() { * Test that threaded comments can be viewed. */ function testThreadedCommentView() { - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Set comments to have subject required and preview disabled. $this->drupalLogin($this->admin_user); $this->setCommentPreview(DRUPAL_DISABLED); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php index 0738076..4432f69 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php @@ -7,6 +7,8 @@ namespace Drupal\comment\Tests; +use Drupal\Core\Language\Language; + /** * Tests previewing comments. */ @@ -31,7 +33,7 @@ public static function getInfo() { * Tests comment preview. */ function testCommentPreview() { - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // As admin user, configure comment settings. $this->drupalLogin($this->admin_user); @@ -77,7 +79,7 @@ function testCommentPreview() { * Tests comment edit, preview, and save. */ function testCommentEditPreviewSave() { - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'skip comment approval')); $this->drupalLogin($this->admin_user); $this->setCommentPreview(DRUPAL_OPTIONAL); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentStatisticsTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentStatisticsTest.php index 3d092af..8c3940d 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentStatisticsTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentStatisticsTest.php @@ -7,6 +7,8 @@ namespace Drupal\comment\Tests; +use Drupal\Core\Language\Language; + /** * Tests the comment module administrative and end-user-facing interfaces. */ @@ -39,7 +41,7 @@ function setUp() { * Tests the node comment statistics. */ function testCommentNodeCommentStatistics() { - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Set comments to have subject and preview disabled. $this->drupalLogin($this->admin_user); $this->setCommentPreview(DRUPAL_DISABLED); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php index 902dbdd..683e697 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php @@ -7,6 +7,7 @@ namespace Drupal\comment\Tests; +use Drupal\Core\Language\Language; use Drupal\comment\Plugin\Core\Entity\Comment; use Drupal\simpletest\WebTestBase; @@ -90,7 +91,7 @@ function setUp() { * array of values to set contact info. */ function postComment($node, $comment, $subject = '', $contact = NULL) { - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit = array(); $edit['comment_body[' . $langcode . '][0][value]'] = $comment; diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php index ba03951..45a13cd 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php @@ -7,6 +7,8 @@ namespace Drupal\comment\Tests; +use Drupal\Core\Language\Language; + /** * Tests comment threading. */ @@ -23,7 +25,7 @@ public static function getInfo() { * Tests the comment threading. */ function testCommentThreading() { - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Set comments to have a subject with preview disabled. $this->drupalLogin($this->admin_user); $this->setCommentPreview(DRUPAL_DISABLED); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php index 34674e8..b00ef35 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php @@ -7,6 +7,8 @@ namespace Drupal\comment\Tests; +use Drupal\Core\Language\Language; + /** * Tests comment token replacement in strings. */ @@ -23,7 +25,7 @@ public static function getInfo() { * Creates a comment, then tests the tokens generated from it. */ function testCommentTokenReplacement() { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); $url_options = array( 'absolute' => TRUE, 'language' => $language_interface, @@ -56,7 +58,7 @@ function testCommentTokenReplacement() { $tests['[comment:mail]'] = check_plain($this->admin_user->mail); $tests['[comment:homepage]'] = check_url($comment->homepage); $tests['[comment:title]'] = filter_xss($comment->subject); - $tests['[comment:body]'] = _text_sanitize($instance, LANGUAGE_NOT_SPECIFIED, $comment->comment_body[LANGUAGE_NOT_SPECIFIED][0], 'value'); + $tests['[comment:body]'] = _text_sanitize($instance, Language::LANGUAGE_NOT_SPECIFIED, $comment->comment_body[Language::LANGUAGE_NOT_SPECIFIED][0], 'value'); $tests['[comment:url]'] = url('comment/' . $comment->cid, $url_options + array('fragment' => 'comment-' . $comment->cid)); $tests['[comment:edit-url]'] = url('comment/' . $comment->cid . '/edit', $url_options); $tests['[comment:created:since]'] = format_interval(REQUEST_TIME - $comment->created, 2, $language_interface->langcode); @@ -82,7 +84,7 @@ function testCommentTokenReplacement() { $tests['[comment:mail]'] = $this->admin_user->mail; $tests['[comment:homepage]'] = $comment->homepage; $tests['[comment:title]'] = $comment->subject; - $tests['[comment:body]'] = $comment->comment_body[LANGUAGE_NOT_SPECIFIED][0]['value']; + $tests['[comment:body]'] = $comment->comment_body[Language::LANGUAGE_NOT_SPECIFIED][0]['value']; $tests['[comment:parent:title]'] = $parent_comment->subject; $tests['[comment:node:title]'] = $node->title; $tests['[comment:author:name]'] = $this->admin_user->name; diff --git a/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php b/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php index b8e7d75..bb1a424 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php @@ -7,6 +7,7 @@ namespace Drupal\comment\Tests\Views; +use Drupal\Core\Language\Language; use Drupal\entity\DatabaseStorageController; use Drupal\views\Tests\ViewTestBase; @@ -82,8 +83,8 @@ public function setUp() { $comment->nid = $this->node->nid; $comment->subject = 'Test comment ' . $i; $comment->node_type = 'comment_node_' . $this->node->type; - $comment->comment_body[LANGUAGE_NOT_SPECIFIED][0]['value'] = 'Test body ' . $i; - $comment->comment_body[LANGUAGE_NOT_SPECIFIED][0]['format'] = 'full_html'; + $comment->comment_body[Language::LANGUAGE_NOT_SPECIFIED][0]['value'] = 'Test body ' . $i; + $comment->comment_body[Language::LANGUAGE_NOT_SPECIFIED][0]['format'] = 'full_html'; comment_save($comment); } diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php index efcbf0e..0b7f1bc 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php @@ -8,6 +8,7 @@ namespace Drupal\config\Tests; use Drupal\Core\Entity\EntityMalformedException; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -40,7 +41,7 @@ function testCRUD() { $this->assertTrue($empty->uuid); $this->assertIdentical($empty->label, NULL); $this->assertIdentical($empty->style, NULL); - $this->assertIdentical($empty->langcode, LANGUAGE_NOT_SPECIFIED); + $this->assertIdentical($empty->langcode, Language::LANGUAGE_NOT_SPECIFIED); // Verify ConfigEntity properties/methods on the newly created empty entity. $this->assertIdentical($empty->isNew(), TRUE); @@ -54,7 +55,7 @@ function testCRUD() { $this->assertTrue($empty->get('uuid')); $this->assertIdentical($empty->get('label'), NULL); $this->assertIdentical($empty->get('style'), NULL); - $this->assertIdentical($empty->get('langcode'), LANGUAGE_NOT_SPECIFIED); + $this->assertIdentical($empty->get('langcode'), Language::LANGUAGE_NOT_SPECIFIED); // Verify Entity properties/methods on the newly created empty entity. $this->assertIdentical($empty->isNewRevision(), FALSE); @@ -96,7 +97,7 @@ function testCRUD() { $this->assertNotEqual($config_test->uuid, $empty->uuid); $this->assertIdentical($config_test->label, $expected['label']); $this->assertIdentical($config_test->style, $expected['style']); - $this->assertIdentical($config_test->langcode, LANGUAGE_NOT_SPECIFIED); + $this->assertIdentical($config_test->langcode, Language::LANGUAGE_NOT_SPECIFIED); // Verify methods on the newly created entity. $this->assertIdentical($config_test->isNew(), TRUE); diff --git a/core/modules/contact/contact.install b/core/modules/contact/contact.install index d35abe9..8cd1ba5 100644 --- a/core/modules/contact/contact.install +++ b/core/modules/contact/contact.install @@ -6,6 +6,7 @@ */ use Drupal\Component\Uuid\Uuid; +use Drupal\Core\Language\Language; /** * Implements hook_install(). @@ -75,7 +76,7 @@ function contact_update_8001() { ->set('recipients', explode(',', $category->recipients)) ->set('reply', $category->reply) ->set('weight', $category->weight) - ->set('langcode', LANGUAGE_NOT_SPECIFIED) + ->set('langcode', Language::LANGUAGE_NOT_SPECIFIED) ->save(); } diff --git a/core/modules/contact/lib/Drupal/contact/MessageFormController.php b/core/modules/contact/lib/Drupal/contact/MessageFormController.php index e536675..7fea256 100644 --- a/core/modules/contact/lib/Drupal/contact/MessageFormController.php +++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityFormController; +use Drupal\Core\Language\Language; use Drupal\user\Plugin\Core\Entity\User; /** @@ -139,7 +140,7 @@ public function preview(array $form, array &$form_state) { public function save(array $form, array &$form_state) { global $user; - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); $message = $this->getEntity($form_state); $sender = clone user_load($user->uid); diff --git a/core/modules/dblog/lib/Drupal/dblog/Tests/DBLogTest.php b/core/modules/dblog/lib/Drupal/dblog/Tests/DBLogTest.php index ddfcac4..c95331a 100644 --- a/core/modules/dblog/lib/Drupal/dblog/Tests/DBLogTest.php +++ b/core/modules/dblog/lib/Drupal/dblog/Tests/DBLogTest.php @@ -7,6 +7,7 @@ namespace Drupal\dblog\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; use SimpleXMLElement; @@ -309,7 +310,7 @@ private function doNode($type) { // Create a node using the form in order to generate an add content event // (which is not triggered by drupalCreateNode). $edit = $this->getContent($type); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $title = $edit["title"]; $this->drupalPost('node/add/' . $type, $edit, t('Save')); $this->assertResponse(200); @@ -367,7 +368,7 @@ private function doNode($type) { * Random content needed by various node types. */ private function getContent($type) { - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; switch ($type) { case 'poll': $content = array( @@ -406,7 +407,7 @@ private function getContentUpdate($type) { break; default: - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $content = array( "body[$langcode][0][value]" => $this->randomName(32), ); diff --git a/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php b/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php index 37d4ee5..ee27670 100644 --- a/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php +++ b/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php @@ -7,6 +7,7 @@ namespace Drupal\email\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -71,7 +72,7 @@ function testEmailField() { // Display creation form. $this->drupalGet('test-entity/add/test_bundle'); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $this->assertFieldByName("{$this->field['field_name']}[$langcode][0][value]", '', 'Widget found.'); $this->assertRaw('placeholder="example@example.com"'); diff --git a/core/modules/field/field.default.inc b/core/modules/field/field.default.inc index d37d0ac..4adc9a9 100644 --- a/core/modules/field/field.default.inc +++ b/core/modules/field/field.default.inc @@ -10,6 +10,8 @@ * the corresponding field_attach_[operation]() function. */ +use Drupal\Core\Language\Language; + /** * Generic field validation handler. * @@ -109,8 +111,8 @@ function field_default_insert($entity_type, $entity, $field, $instance, $langcod function field_default_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) { $field_name = $field['field_name']; // If the field is untranslatable keep using LANGUAGE_NOT_SPECIFIED. - if ($langcode == LANGUAGE_NOT_SPECIFIED) { - $source_langcode = LANGUAGE_NOT_SPECIFIED; + if ($langcode == Language::LANGUAGE_NOT_SPECIFIED) { + $source_langcode = Language::LANGUAGE_NOT_SPECIFIED; } if (isset($source_entity->{$field_name}[$source_langcode])) { $items = $source_entity->{$field_name}[$source_langcode]; diff --git a/core/modules/field/field.info.inc b/core/modules/field/field.info.inc index 688d611..b5a2889 100644 --- a/core/modules/field/field.info.inc +++ b/core/modules/field/field.info.inc @@ -5,6 +5,7 @@ * Field Info API, providing information about available fields and field types. */ +use Drupal\Core\Language\Language; use Drupal\field\FieldInstance; use Drupal\field\FieldInfo; @@ -81,7 +82,7 @@ function field_info_cache_clear() { * @see _field_info_collate_types_reset() */ function _field_info_collate_types() { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); // Use the advanced drupal_static() pattern, since this is called very often. static $drupal_static_fast; diff --git a/core/modules/field/field.multilingual.inc b/core/modules/field/field.multilingual.inc index 73c47cb..96c418b 100644 --- a/core/modules/field/field.multilingual.inc +++ b/core/modules/field/field.multilingual.inc @@ -5,6 +5,8 @@ * Functions implementing Field API multilingual support. */ +use Drupal\Core\Language\Language; + /** * @defgroup field_language Field Language API * @{ @@ -17,10 +19,10 @@ * @endcode * Every field can hold a single or multiple value for each language code * belonging to the available language codes set: - * - For untranslatable fields this set only contains LANGUAGE_NOT_SPECIFIED. + * - For untranslatable fields this set only contains Language::LANGUAGE_NOT_SPECIFIED. * - For translatable fields this set can contain any language code. By default * it is the list returned by field_content_languages(), which contains all - * installed languages with the addition of LANGUAGE_NOT_SPECIFIED. This + * installed languages with the addition of Language::LANGUAGE_NOT_SPECIFIED. This * default can be altered by modules implementing * hook_field_available_languages_alter(). * @@ -108,7 +110,7 @@ function field_language_delete() { * Collects the available language codes for the given entity type and field. * * If the given field has language support enabled, an array of available - * language codes will be returned, otherwise only LANGUAGE_NOT_SPECIFIED will + * language codes will be returned, otherwise only Language::LANGUAGE_NOT_SPECIFIED will * be returned. Since the default value for a 'translatable' entity property is * FALSE, we ensure that only entities that are able to handle translations * actually get translatable fields. @@ -131,7 +133,7 @@ function field_available_languages($entity_type, $field) { if (!isset($field_langcodes[$entity_type][$field_name])) { // If the field has language support enabled we retrieve an (alterable) list - // of enabled languages, otherwise we return just LANGUAGE_NOT_SPECIFIED. + // of enabled languages, otherwise we return just Language::LANGUAGE_NOT_SPECIFIED. if (field_is_translatable($entity_type, $field)) { $langcodes = field_content_languages(); // Let other modules alter the available languages. @@ -140,7 +142,7 @@ function field_available_languages($entity_type, $field) { $field_langcodes[$entity_type][$field_name] = $langcodes; } else { - $field_langcodes[$entity_type][$field_name] = array(LANGUAGE_NOT_SPECIFIED); + $field_langcodes[$entity_type][$field_name] = array(Language::LANGUAGE_NOT_SPECIFIED); } } @@ -188,7 +190,7 @@ function _field_language_suggestion($available_langcodes, $langcode_suggestion, * An array of language codes. */ function field_content_languages() { - return array_keys(language_list(LANGUAGE_ALL)); + return array_keys(language_list(Language::LANGUAGE_ALL)); } /** @@ -264,7 +266,7 @@ function field_valid_language($langcode, $default = TRUE) { if (in_array($langcode, $languages)) { return $langcode; } - return $default ? language_default()->langcode : language(LANGUAGE_TYPE_CONTENT)->langcode; + return $default ? language_default()->langcode : language(Language::LANGUAGE_TYPE_CONTENT)->langcode; } /** @@ -275,7 +277,7 @@ function field_valid_language($langcode, $default = TRUE) { * requested language code and the actual data available in the fields * themselves. * If there is no registered translation handler for the given entity type, the - * display language code to be used is just LANGUAGE_NOT_SPECIFIED, as no other + * display language code to be used is just Language::LANGUAGE_NOT_SPECIFIED, as no other * language code is allowed by field_available_languages(). * * If translation handlers are found, we let modules provide alternative display @@ -318,8 +320,8 @@ function field_language($entity_type, $entity, $field_name = NULL, $langcode = N // If the field has a value for one of the locked languages, then use // that language for display. If not, the default one will be // LANGUAGE_NOT_SPECIFIED. - $display_langcode[$instance['field_name']] = LANGUAGE_NOT_SPECIFIED; - foreach (language_list(LANGUAGE_LOCKED) as $language_locked) { + $display_langcode[$instance['field_name']] = Language::LANGUAGE_NOT_SPECIFIED; + foreach (language_list(Language::LANGUAGE_LOCKED) as $language_locked) { if (isset($entity->{$instance['field_name']}[$language_locked->langcode])) { $display_langcode[$instance['field_name']] = $language_locked->langcode; break; diff --git a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php index eadd0b0..2d658ee 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php +++ b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php @@ -7,6 +7,7 @@ namespace Drupal\field\Plugin\views\field; +use Drupal\Core\Language\Language; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\field\FieldPluginBase; @@ -190,7 +191,7 @@ public function query($use_groupby = FALSE) { // @see this::field_langcode() $default_langcode = language_default()->langcode; $langcode = str_replace(array('***CURRENT_LANGUAGE***', '***DEFAULT_LANGUAGE***'), - array(drupal_container()->get(LANGUAGE_TYPE_CONTENT)->langcode, $default_langcode), + array(drupal_container()->get(Language::LANGUAGE_TYPE_CONTENT)->langcode, $default_langcode), $this->view->display_handler->options['field_langcode']); $placeholder = $this->placeholder(); $langcode_fallback_candidates = array($langcode); @@ -199,7 +200,7 @@ public function query($use_groupby = FALSE) { $langcode_fallback_candidates = array_merge($langcode_fallback_candidates, language_fallback_get_candidates()); } else { - $langcode_fallback_candidates[] = LANGUAGE_NOT_SPECIFIED; + $langcode_fallback_candidates[] = Language::LANGUAGE_NOT_SPECIFIED; } $this->query->add_where_expression(0, "$column IN($placeholder) OR $column IS NULL", array($placeholder => $langcode_fallback_candidates)); } @@ -839,11 +840,11 @@ function field_langcode($entity_type, $entity) { if (field_is_translatable($entity_type, $this->field_info)) { $default_langcode = language_default()->langcode; $langcode = str_replace(array('***CURRENT_LANGUAGE***', '***DEFAULT_LANGUAGE***'), - array(drupal_container()->get(LANGUAGE_TYPE_CONTENT)->langcode, $default_langcode), + array(drupal_container()->get(Language::LANGUAGE_TYPE_CONTENT)->langcode, $default_langcode), $this->view->display_handler->options['field_language']); // Give the Field Language API a chance to fallback to a different language - // (or LANGUAGE_NOT_SPECIFIED), in case the field has no data for the selected language. + // (or Language::LANGUAGE_NOT_SPECIFIED), in case the field has no data for the selected language. // field_view_field() does this as well, but since the returned language code // is used before calling it, the fallback needs to happen explicitly. $langcode = field_language($entity_type, $entity, $this->field_info['field_name'], $langcode); @@ -851,7 +852,7 @@ function field_langcode($entity_type, $entity) { return $langcode; } else { - return LANGUAGE_NOT_SPECIFIED; + return Language::LANGUAGE_NOT_SPECIFIED; } } diff --git a/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php b/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php index cc47e59..5d7ffef 100644 --- a/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php @@ -10,6 +10,8 @@ /** * Unit test class for field bulk delete and batch purge functionality. */ +use Drupal\Core\Language\Language; + class BulkDeleteTest extends FieldTestBase { /** @@ -131,7 +133,7 @@ function setUp() { for ($i = 0; $i < 10; $i++) { $entity = field_test_create_entity($id, $id, $bundle); foreach ($this->fields as $field) { - $entity->{$field['field_name']}[LANGUAGE_NOT_SPECIFIED] = $this->_generateTestFieldValues($field['cardinality']); + $entity->{$field['field_name']}[Language::LANGUAGE_NOT_SPECIFIED] = $this->_generateTestFieldValues($field['cardinality']); } $entity->save(); $id++; diff --git a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php index 204419e..eb248ea 100644 --- a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php @@ -7,6 +7,7 @@ namespace Drupal\field\Tests; +use Drupal\Core\Language\Language; use Drupal\field\FieldException; use Exception; @@ -336,7 +337,7 @@ function testDeleteField() { // Save an entity with data for the field $entity = field_test_create_entity(0, 0, $instance['bundle']); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $values[0]['value'] = mt_rand(1, 127); $entity->{$field['field_name']}[$langcode] = $values; $entity_type = 'test_entity'; @@ -403,17 +404,17 @@ function testUpdateField() { $entity = field_test_create_entity($id, $id, $instance['bundle']); // Fill in the entity with more values than $cardinality. for ($i = 0; $i < 20; $i++) { - $entity->field_update[LANGUAGE_NOT_SPECIFIED][$i]['value'] = $i; + $entity->field_update[Language::LANGUAGE_NOT_SPECIFIED][$i]['value'] = $i; } // Save the entity. field_attach_insert('test_entity', $entity); // Load back and assert there are $cardinality number of values. $entity = field_test_create_entity($id, $id, $instance['bundle']); field_attach_load('test_entity', array($id => $entity)); - $this->assertEqual(count($entity->field_update[LANGUAGE_NOT_SPECIFIED]), $field_definition['cardinality'], 'Cardinality is kept'); + $this->assertEqual(count($entity->field_update[Language::LANGUAGE_NOT_SPECIFIED]), $field_definition['cardinality'], 'Cardinality is kept'); // Now check the values themselves. for ($delta = 0; $delta < $cardinality; $delta++) { - $this->assertEqual($entity->field_update[LANGUAGE_NOT_SPECIFIED][$delta]['value'], $delta, 'Value is kept'); + $this->assertEqual($entity->field_update[Language::LANGUAGE_NOT_SPECIFIED][$delta]['value'], $delta, 'Value is kept'); } // Increase $cardinality and set the field cardinality to the new value. $field_definition['cardinality'] = ++$cardinality; diff --git a/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php b/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php index 32f91fd..807d3b1 100644 --- a/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php @@ -7,6 +7,8 @@ namespace Drupal\field\Tests; +use Drupal\Core\Language\Language; + class DisplayApiTest extends FieldTestBase { /** @@ -74,7 +76,7 @@ function setUp() { $this->values = $this->_generateTestFieldValues($this->cardinality); $this->entity = field_test_create_entity(); $this->is_new = TRUE; - $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED] = $this->values; + $this->entity->{$this->field_name}[Language::LANGUAGE_NOT_SPECIFIED] = $this->values; field_test_entity_save($this->entity); } @@ -159,7 +161,7 @@ function testFieldViewValue() { $settings = field_info_formatter_settings('field_test_default'); $setting = $settings['test_formatter_setting']; foreach ($this->values as $delta => $value) { - $item = $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][$delta]; + $item = $this->entity->{$this->field_name}[Language::LANGUAGE_NOT_SPECIFIED][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item); $this->drupalSetContent(drupal_render($output)); $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); @@ -175,7 +177,7 @@ function testFieldViewValue() { $setting = $display['settings']['test_formatter_setting_multiple']; $array = array(); foreach ($this->values as $delta => $value) { - $item = $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][$delta]; + $item = $this->entity->{$this->field_name}[Language::LANGUAGE_NOT_SPECIFIED][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, $display); $this->drupalSetContent(drupal_render($output)); $this->assertText($setting . '|0:' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); @@ -191,7 +193,7 @@ function testFieldViewValue() { $setting = $display['settings']['test_formatter_setting_additional']; $array = array(); foreach ($this->values as $delta => $value) { - $item = $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][$delta]; + $item = $this->entity->{$this->field_name}[Language::LANGUAGE_NOT_SPECIFIED][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, $display); $this->drupalSetContent(drupal_render($output)); $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); @@ -201,7 +203,7 @@ function testFieldViewValue() { // used. $setting = $this->display_options['teaser']['settings']['test_formatter_setting']; foreach ($this->values as $delta => $value) { - $item = $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][$delta]; + $item = $this->entity->{$this->field_name}[Language::LANGUAGE_NOT_SPECIFIED][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, 'teaser'); $this->drupalSetContent(drupal_render($output)); $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); @@ -211,7 +213,7 @@ function testFieldViewValue() { // are used. $setting = $this->display_options['default']['settings']['test_formatter_setting']; foreach ($this->values as $delta => $value) { - $item = $this->entity->{$this->field_name}[LANGUAGE_NOT_SPECIFIED][$delta]; + $item = $this->entity->{$this->field_name}[Language::LANGUAGE_NOT_SPECIFIED][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, 'unknown_view_mode'); $this->drupalSetContent(drupal_render($output)); $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAccessTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAccessTest.php index bc1a380..285cafa 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAccessTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAccessTest.php @@ -64,7 +64,7 @@ function setUp() { $settings = array(); $settings['type'] = $this->content_type; $settings['title'] = 'Field view access test'; - $settings['test_view_field'] = array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->test_view_field_value))); + $settings['test_view_field'] = array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->test_view_field_value))); $this->node = $this->drupalCreateNode($settings); } diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php index 5f8ad5d..120da87 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php @@ -7,6 +7,7 @@ namespace Drupal\field\Tests; +use Drupal\Core\Language\Language; use Drupal\field\FieldValidationException; /** @@ -29,7 +30,7 @@ function testFieldAttachView() { $entity_type = 'test_entity'; $entity_init = field_test_create_entity(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $options = array('field_name' => $this->field_name_2); // Populate values to be displayed. @@ -176,7 +177,7 @@ function testFieldAttachView() { */ function testFieldAttachPrepareViewMultiple() { $entity_type = 'test_entity'; - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Set the instance to be hidden. $display = entity_get_display('test_entity', 'test_bundle', 'full') @@ -232,7 +233,7 @@ function testFieldAttachPrepareViewMultiple() { function testFieldAttachCache() { // Initialize random values and a test entity. $entity_init = field_test_create_entity(1, 1, $this->instance['bundle']); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $values = $this->_generateTestFieldValues($this->field['cardinality']); // Non-cacheable entity type. @@ -326,7 +327,7 @@ function testFieldAttachValidate() { $entity_type = 'test_entity'; $entity = field_test_create_entity(0, 0, $this->instance['bundle']); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Set up all but one values of the first field to generate errors. $values = array(); @@ -418,7 +419,7 @@ function testFieldAttachForm() { $entity_type = 'test_entity'; $entity = field_test_create_entity(0, 0, $this->instance['bundle']); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // When generating form for all fields. $form = array(); @@ -458,7 +459,7 @@ function testFieldAttachSubmit() { $entity_type = 'test_entity'; $entity_init = field_test_create_entity(0, 0, $this->instance['bundle']); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Build the form for all fields. $form = array(); diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php index a4be944..f1d85e2 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php @@ -33,7 +33,7 @@ function testFieldAttachSaveLoad() { // field_test_field_load() in field_test.module). $this->instance['settings']['test_hook_field_load'] = TRUE; field_update_instance($this->instance); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $entity_type = 'test_entity'; $values = array(); @@ -90,7 +90,7 @@ function testFieldAttachSaveLoad() { */ function testFieldAttachLoadMultiple() { $entity_type = 'test_entity'; - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Define 2 bundles. $bundles = array( @@ -166,7 +166,7 @@ function testFieldAttachLoadMultiple() { */ function testFieldAttachSaveLoadDifferentStorage() { $entity_type = 'test_entity'; - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Create two fields using different storage backends, and their instances. $fields = array( @@ -260,7 +260,7 @@ function testFieldStorageDetailsAlter() { function testFieldAttachSaveMissingData() { $entity_type = 'test_entity'; $entity_init = field_test_create_entity(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Insert: Field is missing. $entity = clone($entity_init); @@ -342,7 +342,7 @@ function testFieldAttachSaveMissingDataDefaultValue() { $entity_type = 'test_entity'; $entity_init = field_test_create_entity(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Insert: Field is NULL. $entity = clone($entity_init); @@ -369,7 +369,7 @@ function testFieldAttachSaveMissingDataDefaultValue() { */ function testFieldAttachDelete() { $entity_type = 'test_entity'; - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $rev[0] = field_test_create_entity(0, 0, $this->instance['bundle']); // Create revision 0 @@ -433,7 +433,7 @@ function testFieldAttachCreateRenameBundle() { // Save an entity with data in the field. $entity = field_test_create_entity(0, 0, $this->instance['bundle']); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $values = $this->_generateTestFieldValues($this->field['cardinality']); $entity->{$this->field_name}[$langcode] = $values; $entity_type = 'test_entity'; @@ -490,7 +490,7 @@ function testFieldAttachDeleteBundle() { // Save an entity with data for both fields $entity = field_test_create_entity(0, 0, $this->instance['bundle']); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $values = $this->_generateTestFieldValues($this->field['cardinality']); $entity->{$this->field_name}[$langcode] = $values; $entity->{$field_name}[$langcode] = $this->_generateTestFieldValues(1); diff --git a/core/modules/field/lib/Drupal/field/Tests/FormTest.php b/core/modules/field/lib/Drupal/field/Tests/FormTest.php index b11638f..f8e466b 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FormTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FormTest.php @@ -7,6 +7,8 @@ namespace Drupal\field\Tests; +use Drupal\Core\Language\Language; + class FormTest extends FieldTestBase { /** @@ -59,7 +61,7 @@ function testFieldFormSingle() { $this->instance['field_name'] = $this->field_name; field_create_field($this->field); field_create_instance($this->instance); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Display creation form. $this->drupalGet('test-entity/add/test_bundle'); @@ -123,7 +125,7 @@ function testFieldFormSingleRequired() { $this->instance['required'] = TRUE; field_create_field($this->field); field_create_instance($this->instance); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Submit with missing required value. $edit = array(); @@ -161,7 +163,7 @@ function testFieldFormUnlimited() { $this->instance['field_name'] = $this->field_name; field_create_field($this->field); field_create_instance($this->instance); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Display creation form -> 1 widget. $this->drupalGet('test-entity/add/test_bundle'); @@ -241,7 +243,7 @@ function testFieldFormMultivalueWithRequiredRadio() { $this->instance['field_name'] = $this->field_name; field_create_field($this->field); field_create_instance($this->instance); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Add a required radio field. field_create_field(array( @@ -283,7 +285,7 @@ function testFieldFormJSAddMore() { $this->instance['field_name'] = $this->field_name; field_create_field($this->field); field_create_instance($this->instance); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Display creation form -> 1 widget. $this->drupalGet('test-entity/add/test_bundle'); @@ -343,7 +345,7 @@ function testFieldFormMultipleWidget() { $this->instance['widget']['type'] = 'test_field_widget_multiple'; field_create_field($this->field); field_create_instance($this->instance); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Display creation form. $this->drupalGet('test-entity/add/test_bundle'); @@ -398,7 +400,7 @@ function testFieldFormAccess() { field_create_field($field_no_access); field_create_instance($instance_no_access); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Test that the form structure includes full information for each delta // apart from #access. @@ -460,14 +462,14 @@ function testNestedFieldForm() { // Create two entities. $entity_1 = field_test_create_entity(1, 1); $entity_1->is_new = TRUE; - $entity_1->field_single[LANGUAGE_NOT_SPECIFIED][] = array('value' => 0); - $entity_1->field_unlimited[LANGUAGE_NOT_SPECIFIED][] = array('value' => 1); + $entity_1->field_single[Language::LANGUAGE_NOT_SPECIFIED][] = array('value' => 0); + $entity_1->field_unlimited[Language::LANGUAGE_NOT_SPECIFIED][] = array('value' => 1); field_test_entity_save($entity_1); $entity_2 = field_test_create_entity(2, 2); $entity_2->is_new = TRUE; - $entity_2->field_single[LANGUAGE_NOT_SPECIFIED][] = array('value' => 10); - $entity_2->field_unlimited[LANGUAGE_NOT_SPECIFIED][] = array('value' => 11); + $entity_2->field_single[Language::LANGUAGE_NOT_SPECIFIED][] = array('value' => 10); + $entity_2->field_unlimited[Language::LANGUAGE_NOT_SPECIFIED][] = array('value' => 11); field_test_entity_save($entity_2); // Display the 'combined form'. @@ -490,10 +492,10 @@ function testNestedFieldForm() { field_cache_clear(); $entity_1 = field_test_create_entity(1); $entity_2 = field_test_create_entity(2); - $this->assertFieldValues($entity_1, 'field_single', LANGUAGE_NOT_SPECIFIED, array(1)); - $this->assertFieldValues($entity_1, 'field_unlimited', LANGUAGE_NOT_SPECIFIED, array(2, 3)); - $this->assertFieldValues($entity_2, 'field_single', LANGUAGE_NOT_SPECIFIED, array(11)); - $this->assertFieldValues($entity_2, 'field_unlimited', LANGUAGE_NOT_SPECIFIED, array(12, 13)); + $this->assertFieldValues($entity_1, 'field_single', Language::LANGUAGE_NOT_SPECIFIED, array(1)); + $this->assertFieldValues($entity_1, 'field_unlimited', Language::LANGUAGE_NOT_SPECIFIED, array(2, 3)); + $this->assertFieldValues($entity_2, 'field_single', Language::LANGUAGE_NOT_SPECIFIED, array(11)); + $this->assertFieldValues($entity_2, 'field_unlimited', Language::LANGUAGE_NOT_SPECIFIED, array(12, 13)); // Submit invalid values and check that errors are reported on the // correct widgets. @@ -521,8 +523,8 @@ function testNestedFieldForm() { ); $this->drupalPost('test-entity/nested/1/2', $edit, t('Save')); field_cache_clear(); - $this->assertFieldValues($entity_1, 'field_unlimited', LANGUAGE_NOT_SPECIFIED, array(3, 2)); - $this->assertFieldValues($entity_2, 'field_unlimited', LANGUAGE_NOT_SPECIFIED, array(13, 12)); + $this->assertFieldValues($entity_1, 'field_unlimited', Language::LANGUAGE_NOT_SPECIFIED, array(3, 2)); + $this->assertFieldValues($entity_2, 'field_unlimited', Language::LANGUAGE_NOT_SPECIFIED, array(13, 12)); // Test the 'add more' buttons. Only Ajax submission is tested, because // the two 'add more' buttons present in the form have the same #value, @@ -548,7 +550,7 @@ function testNestedFieldForm() { // Save the form and check values are saved correclty. $this->drupalPost(NULL, array(), t('Save')); field_cache_clear(); - $this->assertFieldValues($entity_1, 'field_unlimited', LANGUAGE_NOT_SPECIFIED, array(3, 2)); - $this->assertFieldValues($entity_2, 'field_unlimited', LANGUAGE_NOT_SPECIFIED, array(13, 14, 15)); + $this->assertFieldValues($entity_1, 'field_unlimited', Language::LANGUAGE_NOT_SPECIFIED, array(3, 2)); + $this->assertFieldValues($entity_2, 'field_unlimited', Language::LANGUAGE_NOT_SPECIFIED, array(13, 14, 15)); } } diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php index 8f813c0..10d198f 100644 --- a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php @@ -93,7 +93,7 @@ function testFieldAvailableLanguages() { $this->field['translatable'] = FALSE; field_update_field($this->field); $available_langcodes = field_available_languages($this->entity_type, $this->field); - $this->assertTrue(count($available_langcodes) == 1 && $available_langcodes[0] === LANGUAGE_NOT_SPECIFIED, 'For untranslatable fields only LANGUAGE_NOT_SPECIFIED is available.'); + $this->assertTrue(count($available_langcodes) == 1 && $available_langcodes[0] === Language::LANGUAGE_NOT_SPECIFIED, 'For untranslatable fields only Language::LANGUAGE_NOT_SPECIFIED is available.'); } /** @@ -292,12 +292,12 @@ function testFieldDisplayLanguage() { $entity->{$field_name}[$langcode] = $this->_generateTestFieldValues($field['cardinality']); // If the langcode is one of the locked languages, then that one // will also be used for display. Otherwise, the default one should be - // used, which is LANGUAGE_NOT_SPECIFIED. + // used, which is Language::LANGUAGE_NOT_SPECIFIED. if (language_is_locked($langcode)) { $locked_languages[$field_name] = $langcode; } else { - $locked_languages[$field_name] = LANGUAGE_NOT_SPECIFIED; + $locked_languages[$field_name] = Language::LANGUAGE_NOT_SPECIFIED; } } @@ -349,7 +349,7 @@ function testFieldFormTranslationRevisions() { $eid = 1; $entity = field_test_create_entity($eid, $eid, $this->instance['bundle']); $available_langcodes = array_flip(field_available_languages($this->entity_type, $this->field)); - unset($available_langcodes[LANGUAGE_NOT_SPECIFIED]); + unset($available_langcodes[Language::LANGUAGE_NOT_SPECIFIED]); $field_name = $this->field['field_name']; // Store the field translations. diff --git a/core/modules/field/lib/Drupal/field/Tests/Views/ApiDataTest.php b/core/modules/field/lib/Drupal/field/Tests/Views/ApiDataTest.php index 00c48d9..d7b6717 100644 --- a/core/modules/field/lib/Drupal/field/Tests/Views/ApiDataTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/Views/ApiDataTest.php @@ -28,7 +28,7 @@ public static function getInfo() { function setUp() { parent::setUp(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $field_names = $this->setUpFields(); diff --git a/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php b/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php index 3f5aea2..40757df 100644 --- a/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php @@ -7,6 +7,7 @@ namespace Drupal\field\Tests\Views; +use Drupal\Core\Language\Language; use Drupal\views\ViewExecutable; /** @@ -59,13 +60,13 @@ protected function setUp() { for ($key = 0; $key < 3; $key++) { $field = $this->fields[$key]; - $edit[$field['field_name']][LANGUAGE_NOT_SPECIFIED][0]['value'] = $this->randomName(8); + $edit[$field['field_name']][Language::LANGUAGE_NOT_SPECIFIED][0]['value'] = $this->randomName(8); } for ($j = 0; $j < 5; $j++) { - $edit[$this->fields[3]['field_name']][LANGUAGE_NOT_SPECIFIED][$j]['value'] = $this->randomName(8); + $edit[$this->fields[3]['field_name']][Language::LANGUAGE_NOT_SPECIFIED][$j]['value'] = $this->randomName(8); } // Set this field to be empty. - $edit[$this->fields[4]['field_name']] = array(LANGUAGE_NOT_SPECIFIED => array(0 => array('value' => NULL))); + $edit[$this->fields[4]['field_name']] = array(Language::LANGUAGE_NOT_SPECIFIED => array(0 => array('value' => NULL))); $this->nodes[$i] = $this->drupalCreateNode($edit); } @@ -102,7 +103,7 @@ public function _testSimpleFieldRender() { for ($key = 0; $key < 2; $key++) { $field = $this->fields[$key]; $rendered_field = $view->style_plugin->get_field($i, $field['field_name']); - $expected_field = $this->nodes[$i]->{$field['field_name']}[LANGUAGE_NOT_SPECIFIED][0]['value']; + $expected_field = $this->nodes[$i]->{$field['field_name']}[Language::LANGUAGE_NOT_SPECIFIED][0]['value']; $this->assertEqual($rendered_field, $expected_field); } } @@ -141,7 +142,7 @@ public function _testMultipleFieldRender() { for ($i = 0; $i < 3; $i++) { $rendered_field = $view->style_plugin->get_field($i, $field_name); $items = array(); - $pure_items = $this->nodes[$i]->{$field_name}[LANGUAGE_NOT_SPECIFIED]; + $pure_items = $this->nodes[$i]->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED]; $pure_items = array_splice($pure_items, 0, 3); foreach ($pure_items as $j => $item) { $items[] = $pure_items[$j]['value']; @@ -164,7 +165,7 @@ public function _testMultipleFieldRender() { for ($i = 0; $i < 3; $i++) { $rendered_field = $view->style_plugin->get_field($i, $field_name); $items = array(); - $pure_items = $this->nodes[$i]->{$field_name}[LANGUAGE_NOT_SPECIFIED]; + $pure_items = $this->nodes[$i]->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED]; $pure_items = array_splice($pure_items, 1, 3); foreach ($pure_items as $j => $item) { $items[] = $pure_items[$j]['value']; @@ -184,7 +185,7 @@ public function _testMultipleFieldRender() { for ($i = 0; $i < 3; $i++) { $rendered_field = $view->style_plugin->get_field($i, $field_name); $items = array(); - $pure_items = $this->nodes[$i]->{$field_name}[LANGUAGE_NOT_SPECIFIED]; + $pure_items = $this->nodes[$i]->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED]; array_splice($pure_items, 0, -3); $pure_items = array_reverse($pure_items); foreach ($pure_items as $j => $item) { @@ -205,7 +206,7 @@ public function _testMultipleFieldRender() { for ($i = 0; $i < 3; $i++) { $rendered_field = $view->style_plugin->get_field($i, $field_name); $items = array(); - $pure_items = $this->nodes[$i]->{$field_name}[LANGUAGE_NOT_SPECIFIED]; + $pure_items = $this->nodes[$i]->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED]; $items[] = $pure_items[0]['value']; $items[] = $pure_items[4]['value']; $this->assertEqual($rendered_field, implode(', ', $items), 'Take sure that the amount of items are limited.'); @@ -223,7 +224,7 @@ public function _testMultipleFieldRender() { for ($i = 0; $i < 3; $i++) { $rendered_field = $view->style_plugin->get_field($i, $field_name); $items = array(); - $pure_items = $this->nodes[$i]->{$field_name}[LANGUAGE_NOT_SPECIFIED]; + $pure_items = $this->nodes[$i]->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED]; $pure_items = array_splice($pure_items, 0, 3); foreach ($pure_items as $j => $item) { $items[] = $pure_items[$j]['value']; diff --git a/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php b/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php index 5681f59..d682361 100644 --- a/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php +++ b/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php @@ -8,6 +8,7 @@ namespace Drupal\field_sql_storage\Tests; use Drupal\Core\Database\Database; +use Drupal\Core\Language\Language; use Drupal\field\FieldException; use Drupal\simpletest\WebTestBase; use Exception; @@ -59,7 +60,7 @@ function setUp() { function testFieldAttachLoad() { $entity_type = 'test_entity'; $eid = 0; - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $columns = array('entity_type', 'entity_id', 'revision_id', 'delta', 'langcode', $this->field_name . '_value'); @@ -128,7 +129,7 @@ function testFieldAttachLoad() { function testFieldAttachInsertAndUpdate() { $entity_type = 'test_entity'; $entity = field_test_create_entity(0, 0, $this->instance['bundle']); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Test insert. $values = array(); @@ -209,7 +210,7 @@ function testFieldAttachInsertAndUpdate() { function testFieldAttachSaveMissingData() { $entity_type = 'test_entity'; $entity = field_test_create_entity(0, 0, $this->instance['bundle']); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Insert: Field is missing field_attach_insert($entity_type, $entity); @@ -308,7 +309,7 @@ function testUpdateFieldSchemaWithData() { $instance = array('field_name' => 'decimal52', 'entity_type' => 'test_entity', 'bundle' => 'test_bundle'); $instance = field_create_instance($instance); $entity = field_test_create_entity(0, 0, $instance['bundle']); - $entity->decimal52[LANGUAGE_NOT_SPECIFIED][0]['value'] = '1.235'; + $entity->decimal52[Language::LANGUAGE_NOT_SPECIFIED][0]['value'] = '1.235'; $entity->save(); // Attempt to update the field in a way that would work without data. @@ -368,7 +369,7 @@ function testFieldUpdateIndexesWithData() { // Add data so the table cannot be dropped. $entity = field_test_create_entity(1, 1, $instance['bundle']); - $entity->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['value'] = 'field data'; + $entity->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['value'] = 'field data'; $entity->save(); // Add an index @@ -389,7 +390,7 @@ function testFieldUpdateIndexesWithData() { // Verify that the tables were not dropped. $entity = field_test_create_entity(1, 1, $instance['bundle']); field_attach_load('test_entity', array(1 => $entity)); - $this->assertEqual($entity->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['value'], 'field data', t("Index changes performed without dropping the tables")); + $this->assertEqual($entity->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['value'], 'field data', t("Index changes performed without dropping the tables")); } /** diff --git a/core/modules/field_ui/field_ui.admin.inc b/core/modules/field_ui/field_ui.admin.inc index 27dad1e..183ce69 100644 --- a/core/modules/field_ui/field_ui.admin.inc +++ b/core/modules/field_ui/field_ui.admin.inc @@ -5,6 +5,7 @@ * Administrative interface for custom field type creation. */ +use Drupal\Core\Language\Language; use Drupal\field\FieldInstance; use Drupal\field_ui\FieldOverview; use Drupal\field_ui\DisplayOverview; @@ -960,7 +961,7 @@ function field_ui_default_value_widget($field, $instance, &$form, &$form_state) // Insert the widget. Since we do not use the "official" instance definition, // the whole flow cannot use field_invoke_method(). $items = (array) $instance['default_value']; - $element += $instance->getWidget()->form($entity, LANGUAGE_NOT_SPECIFIED, $items, $element, $form_state); + $element += $instance->getWidget()->form($entity, Language::LANGUAGE_NOT_SPECIFIED, $items, $element, $form_state); return $element; } @@ -982,27 +983,27 @@ function field_ui_field_edit_form_validate($form, &$form_state) { // Extract the 'default value'. $items = array(); - $instance->getWidget()->submit($entity, LANGUAGE_NOT_SPECIFIED, $items, $element, $form_state); + $instance->getWidget()->submit($entity, Language::LANGUAGE_NOT_SPECIFIED, $items, $element, $form_state); // Grab the field definition from $form_state. - $field_state = field_form_get_state($element['#parents'], $field_name, LANGUAGE_NOT_SPECIFIED, $form_state); + $field_state = field_form_get_state($element['#parents'], $field_name, Language::LANGUAGE_NOT_SPECIFIED, $form_state); $field = $field_state['field']; // Validate the value. $errors = array(); $function = $field['module'] . '_field_validate'; if (function_exists($function)) { - $function(NULL, NULL, $field, $instance, LANGUAGE_NOT_SPECIFIED, $items, $errors); + $function(NULL, NULL, $field, $instance, Language::LANGUAGE_NOT_SPECIFIED, $items, $errors); } // Report errors. - if (isset($errors[$field_name][LANGUAGE_NOT_SPECIFIED])) { + if (isset($errors[$field_name][Language::LANGUAGE_NOT_SPECIFIED])) { // Store reported errors in $form_state. - $field_state['errors'] = $errors[$field_name][LANGUAGE_NOT_SPECIFIED]; - field_form_set_state($element['#parents'], $field_name, LANGUAGE_NOT_SPECIFIED, $form_state, $field_state); + $field_state['errors'] = $errors[$field_name][Language::LANGUAGE_NOT_SPECIFIED]; + field_form_set_state($element['#parents'], $field_name, Language::LANGUAGE_NOT_SPECIFIED, $form_state, $field_state); // Assign reported errors to the correct form element. - $instance->getWidget()->flagErrors($entity, LANGUAGE_NOT_SPECIFIED, $items, $element, $form_state); + $instance->getWidget()->flagErrors($entity, Language::LANGUAGE_NOT_SPECIFIED, $items, $element, $form_state); } } } @@ -1023,7 +1024,7 @@ function field_ui_field_edit_form_submit($form, &$form_state) { // Extract field values. $items = array(); - $instance->getWidget()->submit($entity, LANGUAGE_NOT_SPECIFIED, $items, $element, $form_state); + $instance->getWidget()->submit($entity, Language::LANGUAGE_NOT_SPECIFIED, $items, $element, $form_state); $instance['default_value'] = $items ? $items : NULL; } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php index aa923f1..2f02740 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php @@ -38,7 +38,7 @@ function setUp() { 'name' => $this->randomName(), 'description' => $this->randomName(), 'vid' => drupal_strtolower($this->randomName()), - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, 'help' => '', 'nodes' => array('article' => 'article'), 'weight' => mt_rand(0, 10), diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php index 45de66e..f926096 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php @@ -7,6 +7,7 @@ namespace Drupal\field_ui\Tests; +use Drupal\Core\Language\Language; use Drupal\node\Plugin\Core\Entity\Node; /** @@ -111,7 +112,7 @@ function testViewModeCustom() { $value = 12345; $settings = array( 'type' => $this->type, - 'field_test' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $value))), + 'field_test' => array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => $value))), ); $node = $this->drupalCreateNode($settings); diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php index 8f75f34..4dc98d6 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php @@ -7,6 +7,8 @@ namespace Drupal\field_ui\Tests; +use Drupal\Core\Language\Language; + /** * Tests the functionality of the 'Manage fields' screen. */ @@ -35,7 +37,7 @@ function setUp() { $vocabulary = entity_create('taxonomy_vocabulary', array( 'name' => 'Tags', 'vid' => 'tags', - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, )); $vocabulary->save(); @@ -255,7 +257,7 @@ function testDefaultValue() { ); field_create_instance($instance); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $admin_path = 'admin/structure/types/manage/' . $this->type . '/fields/' . $field_name; $element_id = "edit-$field_name-$langcode-0-value"; $element_name = "{$field_name}[$langcode][0][value]"; diff --git a/core/modules/file/lib/Drupal/file/FileStorageController.php b/core/modules/file/lib/Drupal/file/FileStorageController.php index fb72a5d..69c9d93 100644 --- a/core/modules/file/lib/Drupal/file/FileStorageController.php +++ b/core/modules/file/lib/Drupal/file/FileStorageController.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\DatabaseStorageController; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Language\Language; /** * File storage controller for files. @@ -42,7 +43,7 @@ protected function preSave(EntityInterface $entity) { // neutral more often than language dependent. Until we have better // flexible settings. // @todo See http://drupal.org/node/258785 and followups. - $entity->langcode = LANGUAGE_NOT_SPECIFIED; + $entity->langcode = Language::LANGUAGE_NOT_SPECIFIED; } } diff --git a/core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php b/core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php index bc54514..6cf7917 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php +++ b/core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php @@ -11,6 +11,7 @@ use Drupal\Core\Entity\Entity; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; +use Drupal\Core\Language\Language; /** * Defines the file entity class. @@ -56,7 +57,7 @@ class File extends Entity implements ContentEntityInterface { * * @var string */ - public $langcode = LANGUAGE_NOT_SPECIFIED; + public $langcode = Language::LANGUAGE_NOT_SPECIFIED; /** * The uid of the user who is associated with the file. diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php index 9d7dd30..80ff29a 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php @@ -7,6 +7,8 @@ namespace Drupal\file\Tests; +use Drupal\Core\Language\Language; + /** * Tests that formatters are working properly. */ @@ -58,12 +60,12 @@ function testNodeDisplay() { // Check that the default formatter is displaying with the file name. $node = node_load($nid, TRUE); - $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $node_file = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); $default_output = theme('file_link', array('file' => $node_file)); $this->assertRaw($default_output, t('Default formatter displaying correctly on full node view.')); // Turn the "display" option off and check that the file is no longer displayed. - $edit = array($field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][display]' => FALSE); + $edit = array($field_name . '[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][display]' => FALSE); $this->drupalPost('node/' . $nid . '/edit', $edit, t('Save')); $this->assertNoRaw($default_output, t('Field is hidden when "display" option is unchecked.')); diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php index d963b89..d7a887c 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php @@ -7,6 +7,8 @@ namespace Drupal\file\Tests; +use Drupal\Core\Language\Language; + /** * Tests that files are uploaded to proper locations. */ @@ -33,7 +35,7 @@ function testUploadPath() { // Check that the file was uploaded to the file root. $node = node_load($nid, TRUE); - $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $node_file = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); $this->assertPathMatch('public://' . $test_file->filename, $node_file->uri, t('The file %file was uploaded to the correct path.', array('%file' => $node_file->uri))); // Change the path to contain multiple subdirectories. @@ -44,7 +46,7 @@ function testUploadPath() { // Check that the file was uploaded into the subdirectory. $node = node_load($nid, TRUE); - $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $node_file = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); $this->assertPathMatch('public://foo/bar/baz/' . $test_file->filename, $node_file->uri, t('The file %file was uploaded to the correct path.', array('%file' => $node_file->uri))); // Check the path when used with tokens. @@ -56,7 +58,7 @@ function testUploadPath() { // Check that the file was uploaded into the subdirectory. $node = node_load($nid, TRUE); - $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $node_file = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); // Do token replacement using the same user which uploaded the file, not // the user running the test case. $data = array('user' => $this->admin_user); diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php index f69d9f7..adfcf3b 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldRSSContentTest.php @@ -7,6 +7,8 @@ namespace Drupal\file\Tests; +use Drupal\Core\Language\Language; + /** * Tests that formatters are working properly. */ @@ -59,7 +61,7 @@ function testFileFieldRSSContent() { // Get the uploaded file from the node. $node = node_load($nid, TRUE); - $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $node_file = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); // Check that the RSS enclosure appears in the RSS feed. $this->drupalGet('rss.xml'); diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php index 480f411..6ebe346 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php @@ -7,6 +7,8 @@ namespace Drupal\file\Tests; +use Drupal\Core\Language\Language; + /** * Tests file handling with node revisions. */ @@ -47,7 +49,7 @@ function testRevisions() { // Check that the file exists on disk and in the database. $node = node_load($nid, TRUE); - $node_file_r1 = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $node_file_r1 = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); $node_vid_r1 = $node->vid; $this->assertFileExists($node_file_r1, t('New file saved to disk on node creation.')); $this->assertFileEntryExists($node_file_r1, t('File entry exists in database on node creation.')); @@ -56,7 +58,7 @@ function testRevisions() { // Upload another file to the same node in a new revision. $this->replaceNodeFile($test_file, $field_name, $nid); $node = node_load($nid, TRUE); - $node_file_r2 = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $node_file_r2 = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); $node_vid_r2 = $node->vid; $this->assertFileExists($node_file_r2, t('Replacement file exists on disk after creating new revision.')); $this->assertFileEntryExists($node_file_r2, t('Replacement file entry exists in database after creating new revision.')); @@ -64,7 +66,7 @@ function testRevisions() { // Check that the original file is still in place on the first revision. $node = node_revision_load($node_vid_r1); - $this->assertEqual($node_file_r1, file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']), t('Original file still in place after replacing file in new revision.')); + $this->assertEqual($node_file_r1, file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']), t('Original file still in place after replacing file in new revision.')); $this->assertFileExists($node_file_r1, t('Original file still in place after replacing file in new revision.')); $this->assertFileEntryExists($node_file_r1, t('Original file entry still in place after replacing file in new revision')); $this->assertFileIsPermanent($node_file_r1, t('Original file is still permanent.')); @@ -73,7 +75,7 @@ function testRevisions() { // Check that the file is still the same as the previous revision. $this->drupalPost('node/' . $nid . '/edit', array('revision' => '1'), t('Save')); $node = node_load($nid, TRUE); - $node_file_r3 = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $node_file_r3 = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); $node_vid_r3 = $node->vid; $this->assertEqual($node_file_r2, $node_file_r3, t('Previous revision file still in place after creating a new revision without a new file.')); $this->assertFileIsPermanent($node_file_r3, t('New revision file is permanent.')); @@ -81,7 +83,7 @@ function testRevisions() { // Revert to the first revision and check that the original file is active. $this->drupalPost('node/' . $nid . '/revisions/' . $node_vid_r1 . '/revert', array(), t('Revert')); $node = node_load($nid, TRUE); - $node_file_r4 = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $node_file_r4 = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); $node_vid_r4 = $node->vid; $this->assertEqual($node_file_r1, $node_file_r4, t('Original revision file still in place after reverting to the original revision.')); $this->assertFileIsPermanent($node_file_r4, t('Original revision file still permanent after reverting to the original revision.')); @@ -95,8 +97,8 @@ function testRevisions() { // Attach the second file to a user. $user = $this->drupalCreateUser(); - $user->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'] = $node_file_r3->fid; - $user->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['display'] = 1; + $user->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid'] = $node_file_r3->fid; + $user->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['display'] = 1; $user->save(); $this->drupalGet('user/' . $user->uid . '/edit'); diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php index e291bec..ec6759a 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php @@ -7,6 +7,7 @@ namespace Drupal\file\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -127,7 +128,7 @@ function updateFileField($name, $type_name, $instance_settings = array(), $widge * Uploads a file to a node. */ function uploadNodeFile($file, $field_name, $nid_or_type, $new_revision = TRUE, $extras = array()) { - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit = array( "title" => $this->randomName(), 'revision' => (string) (int) $new_revision, @@ -173,7 +174,7 @@ function removeNodeFile($nid, $new_revision = TRUE) { */ function replaceNodeFile($file, $field_name, $nid, $new_revision = TRUE) { $edit = array( - 'files[' . $field_name . '_' . LANGUAGE_NOT_SPECIFIED . '_0]' => drupal_realpath($file->uri), + 'files[' . $field_name . '_' . Language::LANGUAGE_NOT_SPECIFIED . '_0]' => drupal_realpath($file->uri), 'revision' => (string) (int) $new_revision, ); diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php index 050931b..0076b9f 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php @@ -7,6 +7,8 @@ namespace Drupal\file\Tests; +use Drupal\Core\Language\Language; + /** * Tests various validations. */ @@ -35,7 +37,7 @@ function testRequired() { $test_file = $this->getTestFile('text'); // Try to post a new node without uploading a file. - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit = array("title" => $this->randomName()); $this->drupalPost('node/add/' . $type_name, $edit, t('Save')); $this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), t('Node save failed when required file field was empty.')); @@ -46,7 +48,7 @@ function testRequired() { $node = node_load($nid, TRUE); - $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $node_file = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); $this->assertFileExists($node_file, t('File exists after uploading to the required field.')); $this->assertFileEntryExists($node_file, t('File entry exists after uploading to the required field.')); @@ -62,7 +64,7 @@ function testRequired() { // Create a new node with the uploaded file into the multivalue field. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, TRUE); - $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $node_file = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); $this->assertFileExists($node_file, t('File exists after uploading to the required multiple value field.')); $this->assertFileEntryExists($node_file, t('File entry exists after uploading to the required multipel value field.')); @@ -98,7 +100,7 @@ function testFileMaxSize() { // Create a new node with the small file, which should pass. $nid = $this->uploadNodeFile($small_file, $field_name, $type_name); $node = node_load($nid, TRUE); - $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $node_file = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); $this->assertFileExists($node_file, t('File exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->filesize), '%maxsize' => $max_filesize))); $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->filesize), '%maxsize' => $max_filesize))); @@ -114,7 +116,7 @@ function testFileMaxSize() { // Upload the big file successfully. $nid = $this->uploadNodeFile($large_file, $field_name, $type_name); $node = node_load($nid, TRUE); - $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $node_file = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); $this->assertFileExists($node_file, t('File exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->filesize)))); $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->filesize)))); @@ -141,7 +143,7 @@ function testFileExtension() { // Check that the file can be uploaded with no extension checking. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, TRUE); - $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $node_file = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); $this->assertFileExists($node_file, t('File exists after uploading a file with no extension checking.')); $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file with no extension checking.')); @@ -159,7 +161,7 @@ function testFileExtension() { // Check that the file can be uploaded with extension checking. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, TRUE); - $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $node_file = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); $this->assertFileExists($node_file, t('File exists after uploading a file with extension checking.')); $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file with extension checking.')); diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php index 7fcf35f..6022491 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php @@ -42,7 +42,7 @@ function testSingleValuedWidget() { // does not yet support file uploads. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, TRUE); - $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $node_file = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); $this->assertFileExists($node_file, t('New file saved to disk on node creation.')); // Ensure the file can be downloaded. @@ -69,13 +69,13 @@ function testSingleValuedWidget() { $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), t('After clicking the "Remove" button, it is no longer displayed.')); $this->assertFieldByXpath('//input[@type="submit"]', t('Upload'), t('After clicking the "Remove" button, the "Upload" button is displayed.')); // Test label has correct 'for' attribute. - $label = $this->xpath("//label[@for='edit-" . drupal_clean_css_identifier($field_name) . "-" . LANGUAGE_NOT_SPECIFIED . "-0-upload']"); + $label = $this->xpath("//label[@for='edit-" . drupal_clean_css_identifier($field_name) . "-" . Language::LANGUAGE_NOT_SPECIFIED . "-0-upload']"); $this->assertTrue(isset($label[0]), 'Label for upload found.'); // Save the node and ensure it does not have the file. $this->drupalPost(NULL, array(), t('Save')); $node = node_load($nid, TRUE); - $this->assertTrue(empty($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']), t('File was successfully removed from the node.')); + $this->assertTrue(empty($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']), t('File was successfully removed from the node.')); } } @@ -113,7 +113,7 @@ function testMultiValuedWidget() { $this->drupalGet("node/add/$type_name"); foreach (array($field_name2, $field_name) as $each_field_name) { for ($delta = 0; $delta < 3; $delta++) { - $edit = array('files[' . $each_field_name . '_' . LANGUAGE_NOT_SPECIFIED . '_' . $delta . ']' => drupal_realpath($test_file->uri)); + $edit = array('files[' . $each_field_name . '_' . Language::LANGUAGE_NOT_SPECIFIED . '_' . $delta . ']' => drupal_realpath($test_file->uri)); // If the Upload button doesn't exist, drupalPost() will automatically // fail with an assertion message. $this->drupalPost(NULL, $edit, t('Upload')); @@ -144,11 +144,11 @@ function testMultiValuedWidget() { $check_field_name = $field_name; } - $this->assertIdentical((string) $button['name'], $check_field_name . '_' . LANGUAGE_NOT_SPECIFIED . '_' . $key. '_remove_button'); + $this->assertIdentical((string) $button['name'], $check_field_name . '_' . Language::LANGUAGE_NOT_SPECIFIED . '_' . $key. '_remove_button'); } // "Click" the remove button (emulating either a nojs or js submission). - $button_name = $current_field_name . '_' . LANGUAGE_NOT_SPECIFIED . '_' . $delta . '_remove_button'; + $button_name = $current_field_name . '_' . Language::LANGUAGE_NOT_SPECIFIED . '_' . $delta . '_remove_button'; switch ($type) { case 'nojs': // drupalPost() takes a $submit parameter that is the value of the @@ -176,7 +176,7 @@ function testMultiValuedWidget() { // Ensure an "Upload" button for the current field is displayed with the // correct name. - $upload_button_name = $current_field_name . '_' . LANGUAGE_NOT_SPECIFIED . '_' . $remaining . '_upload_button'; + $upload_button_name = $current_field_name . '_' . Language::LANGUAGE_NOT_SPECIFIED . '_' . $remaining . '_upload_button'; $buttons = $this->xpath('//input[@type="submit" and @value="Upload" and @name=:name]', array(':name' => $upload_button_name)); $this->assertTrue(is_array($buttons) && count($buttons) == 1, t('The upload button is displayed with the correct name (JSMode=%type).', array('%type' => $type))); @@ -196,7 +196,7 @@ function testMultiValuedWidget() { preg_match('/node\/([0-9]+)/', $this->getUrl(), $matches); $nid = $matches[1]; $node = node_load($nid, TRUE); - $this->assertTrue(empty($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']), t('Node was successfully saved without any files.')); + $this->assertTrue(empty($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']), t('Node was successfully saved without any files.')); } } @@ -221,7 +221,7 @@ function testPrivateFileSetting() { $this->drupalPost("admin/structure/types/manage/$type_name/fields/$field_name/field-settings", $edit, t('Save field settings')); $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, TRUE); - $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $node_file = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); $this->assertFileExists($node_file, t('New file saved to disk on node creation.')); // Ensure the private file is available to the user who uploaded it. @@ -274,8 +274,8 @@ function testPrivateFileComment() { // Add a comment with a file. $text_file = $this->getTestFile('text'); $edit = array( - 'files[field_' . $name . '_' . LANGUAGE_NOT_SPECIFIED . '_' . 0 . ']' => drupal_realpath($text_file->uri), - 'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $comment_body = $this->randomName(), + 'files[field_' . $name . '_' . Language::LANGUAGE_NOT_SPECIFIED . '_' . 0 . ']' => drupal_realpath($text_file->uri), + 'comment_body[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][value]' => $comment_body = $this->randomName(), ); $this->drupalPost(NULL, $edit, t('Save')); @@ -287,7 +287,7 @@ function testPrivateFileComment() { $this->drupalLogin($user); $comment = comment_load($cid); - $comment_file = file_load($comment->{'field_' . $name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $comment_file = file_load($comment->{'field_' . $name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); $this->assertFileExists($comment_file, t('New file saved to disk on node creation.')); // Test authenticated file download. $url = file_create_url($comment_file->uri); diff --git a/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php b/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php index 357d8bf..f737faf 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php @@ -7,6 +7,8 @@ namespace Drupal\file\Tests; +use Drupal\Core\Language\Language; + /** * Tests file access on private nodes. */ @@ -52,7 +54,7 @@ function testPrivateFile() { $test_file = $this->getTestFile('text'); $nid = $this->uploadNodeFile($test_file, $field_name, $type_name, TRUE, array('private' => TRUE)); $node = node_load($nid, TRUE); - $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $node_file = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); // Ensure the file can be downloaded. $this->drupalGet(file_create_url($node_file->uri)); $this->assertResponse(200, t('Confirmed that the generated URL is correct by downloading the shipped file.')); @@ -64,7 +66,7 @@ function testPrivateFile() { $this->drupalLogin($this->admin_user); $nid = $this->uploadNodeFile($test_file, $no_access_field_name, $type_name, TRUE, array('private' => TRUE)); $node = node_load($nid, TRUE); - $node_file = file_load($node->{$no_access_field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $node_file = file_load($node->{$no_access_field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); // Ensure the file cannot be downloaded. $this->drupalGet(file_create_url($node_file->uri)); $this->assertResponse(403, t('Confirmed that access is denied for the file without view field access permission.')); diff --git a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php index 4d56b7b..8b8d1e8 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php @@ -7,6 +7,8 @@ namespace Drupal\file\Tests; +use Drupal\Core\Language\Language; + /** * Tests the file token replacement in strings. */ @@ -23,7 +25,7 @@ public static function getInfo() { * Creates a file, then tests the tokens generated from it. */ function testFileTokenReplacement() { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); $url_options = array( 'absolute' => TRUE, 'language' => $language_interface, @@ -46,7 +48,7 @@ function testFileTokenReplacement() { // Load the node and the file. $node = node_load($nid, TRUE); - $file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $file = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); // Generate and test sanitized tokens. $tests = array(); diff --git a/core/modules/file/lib/Drupal/file/Tests/SaveTest.php b/core/modules/file/lib/Drupal/file/Tests/SaveTest.php index e2611e5..973f707 100644 --- a/core/modules/file/lib/Drupal/file/Tests/SaveTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/SaveTest.php @@ -7,6 +7,8 @@ namespace Drupal\file\Tests; +use Drupal\Core\Language\Language; + /** * Tests saving files. */ @@ -43,7 +45,7 @@ function testFileSave() { $this->assertEqual($loaded_file->status, $file->status, t("Status was saved correctly.")); $this->assertEqual($file->filesize, filesize($file->uri), t("File size was set correctly."), 'File'); $this->assertTrue($file->timestamp > 1, t("File size was set correctly."), 'File'); - $this->assertEqual($loaded_file->langcode, LANGUAGE_NOT_SPECIFIED, t("Langcode was defaulted correctly.")); + $this->assertEqual($loaded_file->langcode, Language::LANGUAGE_NOT_SPECIFIED, t("Langcode was defaulted correctly.")); // Resave the file, updating the existing record. file_test_reset(); diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index c4b596a..cdd1707 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -6,6 +6,7 @@ */ use Drupal\Core\Cache\CacheBackendInterface; +use Drupal\Core\Language\Language; use Drupal\Core\Template\Attribute; /** @@ -443,7 +444,7 @@ function filter_modules_disabled($modules) { * @see filter_formats_reset() */ function filter_formats($account = NULL) { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); $formats = &drupal_static(__FUNCTION__, array()); // All available formats are cached for performance. diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php index 9a09a76..fb0eef8 100644 --- a/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php +++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php @@ -7,6 +7,7 @@ namespace Drupal\filter\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; class FilterAdminTest extends WebTestBase { @@ -204,7 +205,7 @@ function testFilterAdmin() { $text = $body . '' . $extra_text . ''; $edit = array(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit["title"] = $this->randomName(); $edit["body[$langcode][0][value]"] = $text; $edit["body[$langcode][0][format]"] = $filtered; diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterFormatAccessTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterFormatAccessTest.php index 4636610..00361f1 100644 --- a/core/modules/filter/lib/Drupal/filter/Tests/FilterFormatAccessTest.php +++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterFormatAccessTest.php @@ -7,6 +7,7 @@ namespace Drupal\filter\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; class FilterFormatAccessTest extends WebTestBase { @@ -91,7 +92,7 @@ function testFormatPermissions() { // the disallowed format does not. $this->drupalLogin($this->web_user); $this->drupalGet('node/add/page'); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $elements = $this->xpath('//select[@name=:name]/option', array( ':name' => "body[$langcode][0][format]", ':option' => $this->allowed_format->format, @@ -161,7 +162,7 @@ function testFormatRoles() { * forced to choose a new format before saving the page. */ function testFormatWidgetPermissions() { - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $title_key = "title"; $body_value_key = "body[$langcode][0][value]"; $body_format_key = "body[$langcode][0][format]"; diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterSecurityTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterSecurityTest.php index 813d717..a23dc5d 100644 --- a/core/modules/filter/lib/Drupal/filter/Tests/FilterSecurityTest.php +++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterSecurityTest.php @@ -7,6 +7,7 @@ namespace Drupal\filter\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -65,8 +66,8 @@ function setUp() { function testDisableFilterModule() { // Create a new node. $node = $this->drupalCreateNode(array('promote' => 1)); - $body_raw = $node->body[LANGUAGE_NOT_SPECIFIED][0]['value']; - $format_id = $node->body[LANGUAGE_NOT_SPECIFIED][0]['format']; + $body_raw = $node->body[Language::LANGUAGE_NOT_SPECIFIED][0]['value']; + $format_id = $node->body[Language::LANGUAGE_NOT_SPECIFIED][0]['format']; $this->drupalGet('node/' . $node->nid); $this->assertText($body_raw, 'Node body found.'); diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php index e121cb8..a635da0 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php @@ -7,6 +7,7 @@ namespace Drupal\forum\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -104,14 +105,14 @@ function testActiveForumTopicsBlock() { // Comment on the first 5 topics. $timestamp = time(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; for ($index = 0; $index < 5; $index++) { // Get the node from the topic title. $node = $this->drupalGetNodeByTitle($topics[$index]); $comment = entity_create('comment', array( 'nid' => $node->nid, 'subject' => $this->randomString(20), - 'comment_body' => array(LANGUAGE_NOT_SPECIFIED => $this->randomString(256)), + 'comment_body' => array(Language::LANGUAGE_NOT_SPECIFIED => $this->randomString(256)), 'created' => $timestamp + $index, )); comment_save($comment); @@ -178,7 +179,7 @@ private function createForumTopics($count = 5) { $title = $this->randomName(20); $body = $this->randomName(200); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit = array( 'title' => $title, "body[$langcode][0][value]" => $body, diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumIndexTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumIndexTest.php index 7ae7d5f..8e83f1d 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumIndexTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumIndexTest.php @@ -7,6 +7,7 @@ namespace Drupal\forum\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -42,7 +43,7 @@ function setUp() { */ function testForumIndexStatus() { - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // The forum ID to use. $tid = 1; diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php index 402409a..001319e 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php @@ -7,6 +7,7 @@ namespace Drupal\forum\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -54,7 +55,7 @@ function testForumNodeAccess() { $this->drupalLogin($admin_user); // Create a private node. - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $private_node_title = $this->randomName(20); $edit = array( 'title' => $private_node_title, diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php index 7b0bef7..70a2df7 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php @@ -7,6 +7,7 @@ namespace Drupal\forum\Tests; +use Drupal\Core\Language\Language; use Drupal\node\Plugin\Core\Entity\Node; use Drupal\simpletest\WebTestBase; @@ -203,7 +204,7 @@ function testForum() { // Test adding a comment to a forum topic. $node = $this->createForumTopic($this->forum, FALSE); $edit = array(); - $edit['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]'] = $this->randomName(); + $edit['comment_body[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][value]'] = $this->randomName(); $this->drupalPost("node/$node->nid", $edit, t('Save')); $this->assertResponse(200); @@ -230,7 +231,7 @@ function testAddOrphanTopic() { // Create an orphan forum item. $this->drupalLogin($this->admin_user); - $this->drupalPost('node/add/forum', array('title' => $this->randomName(10), 'body[' . LANGUAGE_NOT_SPECIFIED .'][0][value]' => $this->randomName(120)), t('Save')); + $this->drupalPost('node/add/forum', array('title' => $this->randomName(10), 'body[' . Language::LANGUAGE_NOT_SPECIFIED .'][0][value]' => $this->randomName(120)), t('Save')); $nid_count = db_query('SELECT COUNT(nid) FROM {node}')->fetchField(); $this->assertEqual(0, $nid_count, 'A forum node was not created when missing a forum vocabulary.'); @@ -457,7 +458,7 @@ function createForumTopic($forum, $container = FALSE) { $title = $this->randomName(20); $body = $this->randomName(200); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit = array( "title" => $title, "body[$langcode][0][value]" => $body, @@ -481,7 +482,7 @@ function createForumTopic($forum, $container = FALSE) { // Retrieve node object, ensure that the topic was created and in the proper forum. $node = $this->drupalGetNodeByTitle($title); $this->assertTrue($node != NULL, format_string('Node @title was loaded', array('@title' => $title))); - $this->assertEqual($node->taxonomy_forums[LANGUAGE_NOT_SPECIFIED][0]['tid'], $tid, 'Saved forum topic was in the expected forum'); + $this->assertEqual($node->taxonomy_forums[Language::LANGUAGE_NOT_SPECIFIED][0]['tid'], $tid, 'Saved forum topic was in the expected forum'); // View forum topic. $this->drupalGet('node/' . $node->nid); @@ -543,7 +544,7 @@ private function verifyForums($node_user, Node $node, $admin, $response = 200) { if ($response == 200) { // Edit forum node (including moving it to another forum). $edit = array(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit["title"] = 'node/' . $node->nid; $edit["body[$langcode][0][value]"] = $this->randomName(256); // Assume the topic is initially associated with $forum. diff --git a/core/modules/image/image.module b/core/modules/image/image.module index 8312420..4a160e9 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -5,6 +5,7 @@ * Exposes global functionality for creating image styles. */ +use Drupal\Core\Language\Language; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\StreamedResponse; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; @@ -904,7 +905,7 @@ function image_style_path($style_name, $uri) { * @see image_effect_definition_load() */ function image_effect_definitions() { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); // hook_image_effect_info() includes translated strings, so each language is // cached separately. diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php index 0d09461..cbcaa85 100644 --- a/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php +++ b/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php @@ -7,6 +7,8 @@ namespace Drupal\image\Tests; +use Drupal\Core\Language\Language; + /** * Tests creation, deletion, and editing of image styles and effects. */ @@ -267,7 +269,7 @@ function testStyleReplacement() { // Test that image is displayed using newly created style. $this->drupalGet('node/' . $nid); - $this->assertRaw(image_style_url($style_name, file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri), format_string('Image displayed using style @style.', array('@style' => $style_name))); + $this->assertRaw(image_style_url($style_name, file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri), format_string('Image displayed using style @style.', array('@style' => $style_name))); // Rename the style and make sure the image field is updated. $new_style_name = strtolower($this->randomName(10)); @@ -279,7 +281,7 @@ function testStyleReplacement() { $this->drupalPost('admin/config/media/image-styles/edit/' . $style_name, $edit, t('Update style')); $this->assertText(t('Changes to the style have been saved.'), format_string('Style %name was renamed to %new_name.', array('%name' => $style_name, '%new_name' => $new_style_name))); $this->drupalGet('node/' . $nid); - $this->assertRaw(image_style_url($new_style_name, file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri), 'Image displayed using style replacement style.'); + $this->assertRaw(image_style_url($new_style_name, file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri), 'Image displayed using style replacement style.'); // Delete the style and choose a replacement style. $edit = array( @@ -290,7 +292,7 @@ function testStyleReplacement() { $this->assertRaw($message); $this->drupalGet('node/' . $nid); - $this->assertRaw(image_style_url('thumbnail', file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri), 'Image displayed using style replacement style.'); + $this->assertRaw(image_style_url('thumbnail', file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri), 'Image displayed using style replacement style.'); } /** diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php index 924bd2d..2534eca 100644 --- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php +++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php @@ -7,6 +7,8 @@ namespace Drupal\image\Tests; +use Drupal\Core\Language\Language; + /** * Test class to check that formatters and display settings are working. */ @@ -56,7 +58,7 @@ function _testImageFieldFormatters($scheme) { $node = node_load($nid, TRUE); // Test that the default formatter is being used. - $image_uri = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri; + $image_uri = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri; $image_info = array( 'uri' => $image_uri, 'width' => 40, @@ -162,13 +164,13 @@ function testImageFieldSettings() { // and title fields do not display until the image has been attached. $nid = $this->uploadNodeImage($test_image, $field_name, 'article'); $this->drupalGet('node/' . $nid . '/edit'); - $this->assertFieldByName($field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][alt]', '', 'Alt field displayed on article form.'); - $this->assertFieldByName($field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][title]', '', 'Title field displayed on article form.'); + $this->assertFieldByName($field_name . '[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][alt]', '', 'Alt field displayed on article form.'); + $this->assertFieldByName($field_name . '[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][title]', '', 'Title field displayed on article form.'); // Verify that the attached image is being previewed using the 'medium' // style. $node = node_load($nid, TRUE); $image_info = array( - 'uri' => file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri, + 'uri' => file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri, 'width' => 220, 'height' => 110, 'style_name' => 'medium', @@ -178,15 +180,15 @@ function testImageFieldSettings() { // Add alt/title fields to the image and verify that they are displayed. $image_info = array( - 'uri' => file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri, + 'uri' => file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri, 'alt' => $this->randomName(), 'title' => $this->randomName(), 'width' => 40, 'height' => 20, ); $edit = array( - $field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][alt]' => $image_info['alt'], - $field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][title]' => $image_info['title'], + $field_name . '[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][alt]' => $image_info['alt'], + $field_name . '[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][title]' => $image_info['title'], ); $this->drupalPost('node/' . $nid . '/edit', $edit, t('Save')); $default_output = theme('image', $image_info); @@ -195,8 +197,8 @@ function testImageFieldSettings() { // Verify that alt/title longer than allowed results in a validation error. $test_size = 2000; $edit = array( - $field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][alt]' => $this->randomName($test_size), - $field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][title]' => $this->randomName($test_size), + $field_name . '[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][alt]' => $this->randomName($test_size), + $field_name . '[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][title]' => $this->randomName($test_size), ); $this->drupalPost('node/' . $nid . '/edit', $edit, t('Save')); $this->assertRaw(t('Alternate text cannot be longer than %max characters but is currently %length characters long.', array( @@ -245,7 +247,7 @@ function testImageFieldDefaultImage() { $nid = $this->uploadNodeImage($images[1], $field_name, 'article'); $node = node_load($nid, TRUE); $image_info = array( - 'uri' => file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri, + 'uri' => file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri, 'width' => 40, 'height' => 20, ); diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php index 439db01..78de2a2 100644 --- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php +++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php @@ -7,6 +7,7 @@ namespace Drupal\image\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -118,7 +119,7 @@ function uploadNodeImage($image, $field_name, $type) { $edit = array( 'title' => $this->randomName(), ); - $edit['files[' . $field_name . '_' . LANGUAGE_NOT_SPECIFIED . '_0]'] = drupal_realpath($image->uri); + $edit['files[' . $field_name . '_' . Language::LANGUAGE_NOT_SPECIFIED . '_0]'] = drupal_realpath($image->uri); $this->drupalPost('node/add/' . $type, $edit, t('Save')); // Retrieve ID of the newly created node from the current URL. diff --git a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityNormalizer.php b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityNormalizer.php index b35caf1..89cc73d 100644 --- a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityNormalizer.php +++ b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityNormalizer.php @@ -7,6 +7,7 @@ namespace Drupal\jsonld; +use Drupal\Core\Language\Language; use Drupal\jsonld\JsonldNormalizerBase; use Drupal\rdf\RdfMappingException; use Symfony\Component\Serializer\Exception\UnexpectedValueException; @@ -43,7 +44,7 @@ public function normalize($entity, $format = NULL) { * * @throws \Symfony\Component\Serializer\Exception\UnexpectedValueException */ - public function denormalize($data, $class, $format = null) { + public function denormalize($data, $class, $format = NULL) { if (!isset($data['@type'])) { throw new UnexpectedValueException('JSON-LD @type parameter must be included.'); } @@ -69,14 +70,14 @@ public function denormalize($data, $class, $format = null) { ); // If the data specifies a default language, use it to create the entity. if (isset($data['langcode'])) { - $values['langcode'] = $data['langcode'][LANGUAGE_NOT_SPECIFIED][0]['value']; + $values['langcode'] = $data['langcode'][Language::LANGUAGE_NOT_SPECIFIED][0]['value']; } // Otherwise, if the default language is not specified but there are // translations of field values, explicitly set the entity's default // language to the site's default language. This is required to enable // field translation on this entity. else if ($this->containsTranslation($data)) { - $values['langcode'] = language(LANGUAGE_TYPE_CONTENT)->langcode; + $values['langcode'] = language(Language::LANGUAGE_TYPE_CONTENT)->langcode; } $entity = entity_create($typed_data_ids['entity_type'], $values); @@ -124,10 +125,10 @@ public function denormalize($data, $class, $format = null) { protected function containsTranslation($data) { // Langcodes which do not represent a translation of the entity. $defaultLangcodes = array( - LANGUAGE_DEFAULT, - LANGUAGE_NOT_SPECIFIED, - LANGUAGE_NOT_APPLICABLE, - language(LANGUAGE_TYPE_CONTENT)->langcode, + Language::LANGUAGE_DEFAULT, + Language::LANGUAGE_NOT_SPECIFIED, + Language::LANGUAGE_NOT_APPLICABLE, + language(Language::LANGUAGE_TYPE_CONTENT)->langcode, ); // Combine the langcodes from the field value keys in a single array. diff --git a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityWrapper.php b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityWrapper.php index a2e49e3..6a00622 100644 --- a/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityWrapper.php +++ b/core/modules/jsonld/lib/Drupal/jsonld/JsonldEntityWrapper.php @@ -8,6 +8,7 @@ namespace Drupal\jsonld; use Drupal\Core\Entity\Entity; +use Drupal\Core\Language\Language; use Drupal\rdf\SiteSchema\SiteSchema; use Drupal\rdf\SiteSchema\SiteSchemaManager; use Symfony\Component\Serializer\Serializer; @@ -116,7 +117,7 @@ public function getProperties() { foreach ($this->entity->getTranslationLanguages() as $langcode => $language) { foreach ($this->entity->getTranslation($langcode) as $name => $field) { $definition = $this->entity->getPropertyDefinition($name); - $langKey = empty($definition['translatable']) ? LANGUAGE_NOT_SPECIFIED : $langcode; + $langKey = empty($definition['translatable']) ? Language::LANGUAGE_NOT_SPECIFIED : $langcode; if (!$field->isEmpty()) { $properties[$name][$langKey] = $this->serializer->normalize($field, $this->format); } diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc index 14bbeb7..029c85d 100644 --- a/core/modules/language/language.admin.inc +++ b/core/modules/language/language.admin.inc @@ -13,7 +13,7 @@ */ function language_admin_overview_form($form, &$form_state) { drupal_static_reset('language_list'); - $languages = language_list(LANGUAGE_ALL); + $languages = language_list(Language::LANGUAGE_ALL); $default = language_default(); $form['languages'] = array( @@ -34,10 +34,10 @@ function language_admin_overview_form($form, &$form_state) { $title = check_plain($language->name); $description = ''; switch ($langcode) { - case LANGUAGE_NOT_APPLICABLE: + case Language::LANGUAGE_NOT_APPLICABLE: $description = t('For language independent content.'); break; - case LANGUAGE_NOT_SPECIFIED: + case Language::LANGUAGE_NOT_SPECIFIED: $description = t('Use this when the language is not (yet) known.'); break; } @@ -139,7 +139,7 @@ function theme_language_admin_overview_form_table($variables) { * Process language overview form submissions, updating existing languages. */ function language_admin_overview_form_submit($form, &$form_state) { - $languages = language_list(LANGUAGE_ALL); + $languages = language_list(Language::LANGUAGE_ALL); $old_default = language_default(); foreach ($languages as $langcode => $language) { @@ -261,7 +261,7 @@ function _language_admin_common_controls(&$form, $language = NULL) { '#required' => TRUE, '#description' => t('Direction that text in this language is presented.'), '#default_value' => @$language->direction, - '#options' => array(LANGUAGE_LTR => t('Left to right'), LANGUAGE_RTL => t('Right to left')), + '#options' => array(Language::LANGUAGE_LTR => t('Left to right'), Language::LANGUAGE_RTL => t('Right to left')), ); return $form; } @@ -811,7 +811,7 @@ function language_negotiation_configure_selected_form($form, &$form_state) { $form['selected_langcode'] = array( '#type' => 'language_select', '#title' => t('Language'), - '#languages' => LANGUAGE_CONFIGURABLE | LANGUAGE_SITE_DEFAULT, + '#languages' => Language::LANGUAGE_CONFIGURABLE | Language::LANGUAGE_SITE_DEFAULT, '#default_value' => config('language.negotiation')->get('selected_langcode'), ); diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 987553d..81dafe3 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -5,6 +5,8 @@ * Add language handling functionality to Drupal. */ +use Drupal\Core\Language\Language; + /** * Implements hook_help(). */ @@ -206,7 +208,7 @@ function language_element_info_alter(&$type) { $type['language_select']['#process'] = array_merge($type['language_select']['#process'], array('language_process_language_select', 'form_process_select', 'ajax_process_form')); $type['language_select']['#theme'] = 'select'; $type['language_select']['#theme_wrappers'] = array_merge($type['language_select']['#theme_wrappers'], array('form_element')); - $type['language_select']['#languages'] = LANGUAGE_CONFIGURABLE; + $type['language_select']['#languages'] = Language::LANGUAGE_CONFIGURABLE; $type['language_select']['#multiple'] = FALSE; } } @@ -253,7 +255,7 @@ function language_element_info() { function language_configuration_element_default_options() { $language_options = array(); - $languages = language_list(LANGUAGE_ALL); + $languages = language_list(Language::LANGUAGE_ALL); foreach ($languages as $langcode => $language) { $language_options[$langcode] = $language->locked ? t('- @name -', array('@name' => $language->name)) : $language->name; } @@ -419,7 +421,7 @@ function language_get_default_langcode($entity_type, $bundle) { } $default_value = NULL; - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); switch ($configuration['langcode']) { case 'site_default': $default_value = language_default()->langcode; @@ -515,7 +517,7 @@ function language_update_count() { * TRUE if language is successfully deleted. Otherwise FALSE. */ function language_delete($langcode) { - $languages = language_list(LANGUAGE_ALL); + $languages = language_list(Language::LANGUAGE_ALL); if (isset($languages[$langcode]) && !$languages[$langcode]->locked) { $language = $languages[$langcode]; @@ -544,10 +546,10 @@ function language_delete($langcode) { * and checks to see if a related right to left CSS file should be included. */ function language_css_alter(&$css) { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); // If the current language is RTL, add the CSS file with the RTL overrides. - if ($language_interface->direction == LANGUAGE_RTL) { + if ($language_interface->direction == Language::LANGUAGE_RTL) { foreach ($css as $data => $item) { // Only provide RTL overrides for files. if ($item['type'] == 'file') { @@ -582,16 +584,16 @@ function language_language_types_info() { language_negotiation_include(); return array( - LANGUAGE_TYPE_INTERFACE => array( + Language::LANGUAGE_TYPE_INTERFACE => array( 'name' => t('User interface text'), 'description' => t('Order of language detection methods for user interface text. If a translation of user interface text is available in the detected language, it will be displayed.'), ), - LANGUAGE_TYPE_CONTENT => array( + Language::LANGUAGE_TYPE_CONTENT => array( 'name' => t('Content'), 'description' => t('Order of language detection methods for content. If a version of content is available in the detected language, it will be displayed.'), 'fixed' => array(LANGUAGE_NEGOTIATION_INTERFACE), ), - LANGUAGE_TYPE_URL => array( + Language::LANGUAGE_TYPE_URL => array( 'fixed' => array(LANGUAGE_NEGOTIATION_URL, LANGUAGE_NEGOTIATION_URL_FALLBACK), ), ); @@ -606,7 +608,7 @@ function language_language_negotiation_info() { $negotiation_info = array(); $negotiation_info[LANGUAGE_NEGOTIATION_URL] = array( - 'types' => array(LANGUAGE_TYPE_CONTENT, LANGUAGE_TYPE_INTERFACE, LANGUAGE_TYPE_URL), + 'types' => array(Language::LANGUAGE_TYPE_CONTENT, Language::LANGUAGE_TYPE_INTERFACE, LANGUAGE_TYPE_URL), 'callbacks' => array( 'negotiation' => 'language_from_url', 'language_switch' => 'language_switcher_url', @@ -651,7 +653,7 @@ function language_language_negotiation_info() { ); $negotiation_info[LANGUAGE_NEGOTIATION_INTERFACE] = array( - 'types' => array(LANGUAGE_TYPE_CONTENT), + 'types' => array(Language::LANGUAGE_TYPE_CONTENT), 'callbacks' => array('negotiation' => 'language_from_interface'), 'file' => $file, 'weight' => 8, @@ -660,7 +662,7 @@ function language_language_negotiation_info() { ); $negotiation_info[LANGUAGE_NEGOTIATION_URL_FALLBACK] = array( - 'types' => array(LANGUAGE_TYPE_URL), + 'types' => array(Language::LANGUAGE_TYPE_URL), 'callbacks' => array('negotiation' => 'language_url_fallback'), 'file' => $file, 'weight' => 8, @@ -669,7 +671,7 @@ function language_language_negotiation_info() { ); $negotiation_info[LANGUAGE_NEGOTIATION_USER_ADMIN] = array( - 'types' => array(LANGUAGE_TYPE_INTERFACE), + 'types' => array(Language::LANGUAGE_TYPE_INTERFACE), 'callbacks' => array('negotiation' => 'language_from_user_admin'), 'file' => $file, 'weight' => 10, diff --git a/core/modules/language/language.negotiation.inc b/core/modules/language/language.negotiation.inc index 8bf45a6..bc72b3e 100644 --- a/core/modules/language/language.negotiation.inc +++ b/core/modules/language/language.negotiation.inc @@ -5,6 +5,8 @@ * Language negotiation functions. */ +use Drupal\Core\Language\Language; + /** * The language is determined using path prefix or domain. */ @@ -57,7 +59,7 @@ * The current interface language code. */ function language_from_interface() { - return language(LANGUAGE_TYPE_INTERFACE)->langcode; + return language(Language::LANGUAGE_TYPE_INTERFACE)->langcode; } /** @@ -351,7 +353,7 @@ function language_from_url($languages, $request) { * @return * A valid language code. */ -function language_url_fallback($language = NULL, $request = NULL, $language_type = LANGUAGE_TYPE_INTERFACE) { +function language_url_fallback($language = NULL, $request = NULL, $language_type = Language::LANGUAGE_TYPE_INTERFACE) { $default = language_default(); $prefix = (config('language.negotiation')->get('url.source') == LANGUAGE_NEGOTIATION_URL_PREFIX); @@ -438,7 +440,7 @@ function language_url_rewrite_url(&$path, &$options) { // Language can be passed as an option, or we go for current URL language. if (!isset($options['language'])) { - $language_url = language(LANGUAGE_TYPE_URL); + $language_url = language(Language::LANGUAGE_TYPE_URL); $options['language'] = $language_url; } // We allow only enabled languages here. diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php index 6f8d9c8..5f203ef 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageConfigurationElementTest.php @@ -83,7 +83,7 @@ public function testDefaultLangcode() { // Current interface. language_save_default_configuration('custom_type', 'custom_bundle', array('langcode' => 'current_interface', 'language_hidden' => FALSE)); $langcode = language_get_default_langcode('custom_type', 'custom_bundle'); - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); $this->assertEqual($langcode, $language_interface->langcode); // Site's default. diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageCustomLanguageConfigurationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageCustomLanguageConfigurationTest.php index a4a0e2d..08a6b72 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageCustomLanguageConfigurationTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageCustomLanguageConfigurationTest.php @@ -57,7 +57,7 @@ public function testLanguageConfiguration() { 'predefined_langcode' => 'custom', 'langcode' => 'white space', 'name' => 'evil markup', - 'direction' => LANGUAGE_LTR, + 'direction' => Language::LANGUAGE_LTR, ); $this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language')); $this->assertRaw(t('%field may only contain characters a-z, underscores, or hyphens.', array('%field' => t('Language code')))); @@ -69,7 +69,7 @@ public function testLanguageConfiguration() { 'predefined_langcode' => 'custom', 'langcode' => 'de', 'name' => 'German', - 'direction' => LANGUAGE_LTR, + 'direction' => Language::LANGUAGE_LTR, ); // Add the language the first time. diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php index f72c51a..3702e7f 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageDependencyInjectionTest.php @@ -49,7 +49,7 @@ function testDependencyInjectedNewLanguage() { drupal_language_initialize(); $expected = language_default(); - $result = language(LANGUAGE_TYPE_INTERFACE); + $result = language(Language::LANGUAGE_TYPE_INTERFACE); foreach ($expected as $property => $value) { $this->assertEqual($expected->$property, $result->$property, format_string('The dependency injected language object %prop property equals the new Language object %prop property.', array('%prop' => $property))); } @@ -79,7 +79,7 @@ function testDependencyInjectedNewDefaultLanguage() { // The language system creates a Language object which contains the // same properties as the new default language object. $expected = new Language($new_language_default); - $result = language(LANGUAGE_TYPE_INTERFACE); + $result = language(Language::LANGUAGE_TYPE_INTERFACE); foreach ($expected as $property => $value) { $this->assertEqual($expected->$property, $result->$property, format_string('The dependency injected language object %prop property equals the default language object %prop property.', array('%prop' => $property))); } diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php index 9128bf7..af5e203 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php @@ -181,10 +181,10 @@ function testLanguageStates() { $expected_all_languages = array('l4' => 'l4', 'l3' => 'l3', 'l2' => 'l2', 'l1' => 'l1', 'en' => 'en', 'und' => 'und', 'zxx' => 'zxx'); $expected_conf_languages = array('l3' => 'l3', 'l1' => 'l1', 'en' => 'en'); - $locked_languages = language_list(LANGUAGE_LOCKED); + $locked_languages = language_list(Language::LANGUAGE_LOCKED); $this->assertEqual(array_diff_key($expected_locked_languages, $locked_languages), array(), 'Locked languages loaded correctly.'); - $all_languages = language_list(LANGUAGE_ALL); + $all_languages = language_list(Language::LANGUAGE_ALL); $this->assertEqual(array_diff_key($expected_all_languages, $all_languages), array(), 'All languages loaded correctly.'); $conf_languages = language_list(); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php index 436b371..fa51638 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php @@ -7,6 +7,7 @@ namespace Drupal\language\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -54,7 +55,7 @@ function testInfoAlterations() { // negotiation settings with the proper flag enabled. state()->set('language_test.content_language_type', TRUE); $this->languageNegotiationUpdate(); - $type = LANGUAGE_TYPE_CONTENT; + $type = Language::LANGUAGE_TYPE_CONTENT; $language_types = variable_get('language_types', language_types_get_default()); $this->assertTrue($language_types[$type], 'Content language type is configurable.'); @@ -96,7 +97,7 @@ function testInfoAlterations() { $last = state()->get('language_test.language_negotiation_last'); foreach (language_types_get_all() as $type) { $langcode = $last[$type]; - $value = $type == LANGUAGE_TYPE_CONTENT || strpos($type, 'test') !== FALSE ? 'it' : 'en'; + $value = $type == Language::LANGUAGE_TYPE_CONTENT || strpos($type, 'test') !== FALSE ? 'it' : 'en'; $this->assertEqual($langcode, $value, format_string('The negotiated language for %type is %language', array('%type' => $type, '%language' => $langcode))); } diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php index 19ec30c..36861b3 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php @@ -7,6 +7,7 @@ namespace Drupal\language\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -42,7 +43,7 @@ function setUp() { */ function testLanguageBlock() { // Enable the language switching block. - $language_type = LANGUAGE_TYPE_INTERFACE; + $language_type = Language::LANGUAGE_TYPE_INTERFACE; $edit = array( "blocks[language_{$language_type}][region]" => 'sidebar_first', ); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php index 1943d1a..6f4f74a 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php @@ -138,7 +138,7 @@ function testUILanguageNegotiation() { $this->drupalPost('admin/config/regional/translate/translate', $edit, t('Save translations')); // Configure URL language rewrite. - variable_set('language_negotiation_url_type', LANGUAGE_TYPE_INTERFACE); + variable_set('language_negotiation_url_type', Language::LANGUAGE_TYPE_INTERFACE); // Configure selected language negotiation to use zh-hans. $edit = array('selected_langcode' => $langcode); @@ -230,7 +230,7 @@ function testUILanguageNegotiation() { } // Unknown language prefix should return 404. - variable_set('language_negotiation_' . LANGUAGE_TYPE_INTERFACE, language_language_negotiation_info()); + variable_set('language_negotiation_' . Language::LANGUAGE_TYPE_INTERFACE, language_language_negotiation_info()); $this->drupalGet("$langcode_unknown/admin/config", array(), $http_header_browser_fallback); $this->assertResponse(404, "Unknown language path prefix should return 404"); @@ -359,7 +359,7 @@ function testUILanguageNegotiation() { protected function runTest($test) { if (!empty($test['language_negotiation'])) { $method_weights = array_flip($test['language_negotiation']); - language_negotiation_set(LANGUAGE_TYPE_INTERFACE, $method_weights); + language_negotiation_set(Language::LANGUAGE_TYPE_INTERFACE, $method_weights); } if (!empty($test['language_negotiation_url_part'])) { config('language.negotiation') diff --git a/core/modules/language/tests/language_test.module b/core/modules/language/tests/language_test.module index c15cc80..33fbcb7 100644 --- a/core/modules/language/tests/language_test.module +++ b/core/modules/language/tests/language_test.module @@ -5,6 +5,8 @@ * Mock module for language layer tests. */ +use Drupal\Core\Language\Language; + /** * Implements hook_boot(). * @@ -22,8 +24,8 @@ function language_test_boot() { */ function language_test_init() { language_test_store_language_negotiation(); - if (isset(language(LANGUAGE_TYPE_INTERFACE)->langcode) && isset(language(LANGUAGE_TYPE_INTERFACE)->method_id)) { - drupal_set_message(t('Language negotiation method: @name', array('@name' => language(LANGUAGE_TYPE_INTERFACE)->method_id))); + if (isset(language(Language::LANGUAGE_TYPE_INTERFACE)->langcode) && isset(language(Language::LANGUAGE_TYPE_INTERFACE)->method_id)) { + drupal_set_message(t('Language negotiation method: @name', array('@name' => language(Language::LANGUAGE_TYPE_INTERFACE)->method_id))); } } @@ -49,7 +51,7 @@ function language_test_language_types_info() { */ function language_test_language_types_info_alter(array &$language_types) { if (state()->get('language_test.content_language_type')) { - unset($language_types[LANGUAGE_TYPE_CONTENT]['fixed']); + unset($language_types[Language::LANGUAGE_TYPE_CONTENT]['fixed']); } } @@ -70,7 +72,7 @@ function language_test_language_negotiation_info() { return array( 'test_language_negotiation_method' => array( 'name' => t('Test'), - 'types' => array(LANGUAGE_TYPE_CONTENT, 'test_language_type', 'fixed_test_language_type'), + 'types' => array(Language::LANGUAGE_TYPE_CONTENT, 'test_language_type', 'fixed_test_language_type'), ) + $info, 'test_language_negotiation_method_ts' => array( 'name' => t('Type-specific test'), diff --git a/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php b/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php index a04a43f..6566945 100644 --- a/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php +++ b/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php @@ -7,6 +7,7 @@ namespace Drupal\link\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -70,7 +71,7 @@ function testURLValidation() { )) ->save(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Display creation form. $this->drupalGet('test-entity/add/test_bundle'); @@ -140,7 +141,7 @@ function testLinkTitle() { )) ->save(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Verify that the title field works according to the field setting. foreach (array(DRUPAL_DISABLED, DRUPAL_REQUIRED, DRUPAL_OPTIONAL) as $title_setting) { @@ -247,7 +248,7 @@ function testLinkFormatter() { ->setComponent($this->field['field_name'], $display_options) ->save(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Create an entity with two link field values: // - The first field item uses a URL only. @@ -383,7 +384,7 @@ function testLinkSeparateFormatter() { ->setComponent($this->field['field_name'], $display_options) ->save(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Create an entity with two link field values: // - The first field item uses a URL only. diff --git a/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php b/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php index 3d2fd4a..acb8559 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleConfigSubscriber.php @@ -9,9 +9,9 @@ use Drupal\Core\Config\Config; use Drupal\Core\Config\ConfigEvent; use Drupal\Core\Config\StorageDispatcher; +use Drupal\Core\Language\Language; use Symfony\Component\EventDispatcher\EventSubscriberInterface; - /** * Locale Config helper * @@ -26,7 +26,7 @@ class LocaleConfigSubscriber implements EventSubscriberInterface { */ public function configLoad(ConfigEvent $event) { $config = $event->getConfig(); - $language = language(LANGUAGE_TYPE_INTERFACE); + $language = language(Language::LANGUAGE_TYPE_INTERFACE); $locale_name = $this->getLocaleConfigName($config->getName(), $language); if ($override = $config->getStorage()->read($locale_name)) { $config->setOverride($override); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php index d1ad5f0..bad7be6 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php @@ -7,6 +7,7 @@ namespace Drupal\locale\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -107,7 +108,7 @@ function testPathLanguageConfiguration() { $edit = array( 'source' => 'node/' . $node->nid, 'alias' => $custom_path, - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, ); drupal_container()->get('path.crud')->save($edit['source'], $edit['alias'], $edit['langcode']); $lookup_path = drupal_container()->get('path.alias_manager')->getPathAlias('node/' . $node->nid, 'en'); @@ -129,11 +130,11 @@ function testPathLanguageConfiguration() { ); drupal_container()->get('path.crud')->save($edit['source'], $edit['alias'], $edit['langcode']); - // Assign a custom path alias to second node with LANGUAGE_NOT_SPECIFIED. + // Assign a custom path alias to second node with Language::LANGUAGE_NOT_SPECIFIED. $edit = array( 'source' => 'node/' . $second_node->nid, 'alias' => $custom_path, - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, ); drupal_container()->get('path.crud')->save($edit['source'], $edit['alias'], $edit['langcode']); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php index 57b68ff..1d5721a 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php @@ -155,7 +155,7 @@ function testStringTranslation() { locale_reset(); // Now we should get the proper fresh translation from t(). $this->assertTrue($name != $translation_to_en && t($name, array(), array('langcode' => 'en')) == $translation_to_en, t('t() works for English.')); - $this->assertTrue(t($name, array(), array('langcode' => LANGUAGE_SYSTEM)) == $name, t('t() works for LANGUAGE_SYSTEM.')); + $this->assertTrue(t($name, array(), array('langcode' => Language::LANGUAGE_SYSTEM)) == $name, t('t() works for Language::LANGUAGE_SYSTEM.')); $search = array( 'string' => $name, diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php index 06583de..6113504 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php @@ -60,7 +60,7 @@ function testUninstallProcess() { language(NULL, TRUE); // Check the UI language. drupal_language_initialize(); - $this->assertEqual(language(LANGUAGE_TYPE_INTERFACE)->langcode, $this->langcode, t('Current language: %lang', array('%lang' => language(LANGUAGE_TYPE_INTERFACE)->langcode))); + $this->assertEqual(language(Language::LANGUAGE_TYPE_INTERFACE)->langcode, $this->langcode, t('Current language: %lang', array('%lang' => language(Language::LANGUAGE_TYPE_INTERFACE)->langcode))); // Enable multilingual workflow option for articles. language_save_default_configuration('node', 'article', array('langcode' => 'site_default', 'language_hidden' => FALSE)); @@ -88,9 +88,9 @@ function testUninstallProcess() { // Change language negotiation options. drupal_load('module', 'locale'); variable_set('language_types', language_types_get_default() + array('language_custom' => TRUE)); - variable_set('language_negotiation_' . LANGUAGE_TYPE_INTERFACE, language_language_negotiation_info()); - variable_set('language_negotiation_' . LANGUAGE_TYPE_CONTENT, language_language_negotiation_info()); - variable_set('language_negotiation_' . LANGUAGE_TYPE_URL, language_language_negotiation_info()); + variable_set('language_negotiation_' . Language::LANGUAGE_TYPE_INTERFACE, language_language_negotiation_info()); + variable_set('language_negotiation_' . Language::LANGUAGE_TYPE_CONTENT, language_language_negotiation_info()); + variable_set('language_negotiation_' . Language::LANGUAGE_TYPE_URL, language_language_negotiation_info()); // Change language negotiation settings. config('language.negotiation') @@ -108,7 +108,7 @@ function testUninstallProcess() { language(NULL, TRUE); // Check the init language logic. drupal_language_initialize(); - $this->assertEqual(language(LANGUAGE_TYPE_INTERFACE)->langcode, 'en', t('Language after uninstall: %lang', array('%lang' => language(LANGUAGE_TYPE_INTERFACE)->langcode))); + $this->assertEqual(language(Language::LANGUAGE_TYPE_INTERFACE)->langcode, 'en', t('Language after uninstall: %lang', array('%lang' => language(Language::LANGUAGE_TYPE_INTERFACE)->langcode))); // Check JavaScript files deletion. $this->assertTrue($result = !file_exists($js_file), t('JavaScript file deleted: %file', array('%file' => $result ? $js_file : t('found')))); @@ -120,11 +120,11 @@ function testUninstallProcess() { // Check language negotiation. require_once DRUPAL_ROOT . '/core/includes/language.inc'; $this->assertTrue(count(language_types_get_all()) == count(language_types_get_default()), t('Language types reset')); - $language_negotiation = language_negotiation_method_get_first(LANGUAGE_TYPE_INTERFACE) == LANGUAGE_NEGOTIATION_SELECTED; + $language_negotiation = language_negotiation_method_get_first(Language::LANGUAGE_TYPE_INTERFACE) == LANGUAGE_NEGOTIATION_SELECTED; $this->assertTrue($language_negotiation, t('Interface language negotiation: %setting', array('%setting' => t($language_negotiation ? 'none' : 'set')))); - $language_negotiation = language_negotiation_method_get_first(LANGUAGE_TYPE_CONTENT) == LANGUAGE_NEGOTIATION_SELECTED; + $language_negotiation = language_negotiation_method_get_first(Language::LANGUAGE_TYPE_CONTENT) == LANGUAGE_NEGOTIATION_SELECTED; $this->assertTrue($language_negotiation, t('Content language negotiation: %setting', array('%setting' => t($language_negotiation ? 'none' : 'set')))); - $language_negotiation = language_negotiation_method_get_first(LANGUAGE_TYPE_URL) == LANGUAGE_NEGOTIATION_SELECTED; + $language_negotiation = language_negotiation_method_get_first(Language::LANGUAGE_TYPE_URL) == LANGUAGE_NEGOTIATION_SELECTED; $this->assertTrue($language_negotiation, t('URL language negotiation: %setting', array('%setting' => t($language_negotiation ? 'none' : 'set')))); // Check language negotiation method settings. diff --git a/core/modules/locale/locale.bulk.inc b/core/modules/locale/locale.bulk.inc index 64d2c55..4ee7ca9 100644 --- a/core/modules/locale/locale.bulk.inc +++ b/core/modules/locale/locale.bulk.inc @@ -157,7 +157,7 @@ function locale_translate_export_form($form, &$form_state) { if (empty($language_options)) { $form['langcode'] = array( '#type' => 'value', - '#value' => LANGUAGE_SYSTEM, + '#value' => Language::LANGUAGE_SYSTEM, ); $form['langcode_text'] = array( '#type' => 'item', @@ -172,7 +172,7 @@ function locale_translate_export_form($form, &$form_state) { '#options' => $language_options, '#default_value' => $language_default->langcode, '#empty_option' => t('Source text only, no translations'), - '#empty_value' => LANGUAGE_SYSTEM, + '#empty_value' => Language::LANGUAGE_SYSTEM, ); $form['content_options'] = array( '#type' => 'details', @@ -182,7 +182,7 @@ function locale_translate_export_form($form, &$form_state) { '#tree' => TRUE, '#states' => array( 'invisible' => array( - ':input[name="langcode"]' => array('value' => LANGUAGE_SYSTEM), + ':input[name="langcode"]' => array('value' => Language::LANGUAGE_SYSTEM), ), ), ); @@ -218,7 +218,7 @@ function locale_translate_export_form($form, &$form_state) { */ function locale_translate_export_form_submit($form, &$form_state) { // If template is required, language code is not given. - if ($form_state['values']['langcode'] != LANGUAGE_SYSTEM) { + if ($form_state['values']['langcode'] != Language::LANGUAGE_SYSTEM) { $language = language_load($form_state['values']['langcode']); } else { @@ -421,7 +421,7 @@ function locale_translate_batch_build($files, $options) { * * @param object $file * A file object of the gettext file to be imported. The file object must - * contain a language parameter (other than LANGUAGE_NOT_SPECIFIED). This + * contain a language parameter (other than Language::LANGUAGE_NOT_SPECIFIED). This * is used as the language of the import. * * @param array $options @@ -446,7 +446,7 @@ function locale_translate_batch_import($file, $options, &$context) { 'customized' => LOCALE_NOT_CUSTOMIZED, ); - if (isset($file->langcode) && $file->langcode != LANGUAGE_NOT_SPECIFIED) { + if (isset($file->langcode) && $file->langcode != Language::LANGUAGE_NOT_SPECIFIED) { try { if (empty($context['sandbox'])) { @@ -656,7 +656,7 @@ function locale_translate_file_attach_properties($file, $options = array()) { $file->langcode = isset($options['langcode']) ? $options['langcode'] : $matches[5]; } else { - $file->langcode = LANGUAGE_NOT_SPECIFIED; + $file->langcode = Language::LANGUAGE_NOT_SPECIFIED; } return $file; } diff --git a/core/modules/locale/locale.install b/core/modules/locale/locale.install index b439bb6..f12068d 100644 --- a/core/modules/locale/locale.install +++ b/core/modules/locale/locale.install @@ -5,6 +5,8 @@ * Install, update, and uninstall functions for the Locale module. */ +use Drupal\Core\Language\Language; + /** * Implements hook_install(). */ @@ -658,9 +660,9 @@ function locale_update_8007() { // Add all language type weight variables. As the function language_types() // is not available its functionality is rebuild. $language_types = update_variable_get('language_types', array( - LANGUAGE_TYPE_INTERFACE => TRUE, - LANGUAGE_TYPE_CONTENT => FALSE, - LANGUAGE_TYPE_URL => FALSE, + Language::LANGUAGE_TYPE_INTERFACE => TRUE, + Language::LANGUAGE_TYPE_CONTENT => FALSE, + Language::LANGUAGE_TYPE_URL => FALSE, )); foreach ($language_types as $language_type => $configurable) { $variable_names[] = 'language_negotiation_methods_weight_' . $language_type; diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index c8ccc37..0214a44 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -10,6 +10,7 @@ * object files are supported. */ +use Drupal\Core\Language\Language; use Drupal\locale\LocaleLookup; use Drupal\locale\LocaleConfigSubscriber; use Drupal\locale\SourceString; @@ -361,7 +362,7 @@ function locale_translatable_language_list() { * Language code to use for the lookup. */ function locale($string = NULL, $context = NULL, $langcode = NULL) { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); // Use the advanced drupal_static() pattern, since this is called very often. static $drupal_static_fast; @@ -435,7 +436,7 @@ function locale_storage() { * plural formula. */ function locale_get_plural($count, $langcode = NULL) { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); // Used to locally cache the plural formulas for all languages. $plural_formulas = &drupal_static(__FUNCTION__, array()); @@ -582,7 +583,7 @@ function locale_system_remove($components) { * file if necessary, and adds it to the page. */ function locale_js_alter(&$javascript) { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); $dir = 'public://' . variable_get('locale_js_directory', 'languages'); $parsed = state()->get('system.javascript_parsed') ?: array(); @@ -674,7 +675,7 @@ function locale_library_info() { */ function locale_library_info_alter(&$libraries, $module) { if ($module == 'system' && isset($libraries['jquery.ui.datepicker'])) { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); // locale.datepicker.js should be added in the JS_LIBRARY group, so that // this attach behavior will execute early. JS_LIBRARY is the default for // hook_library_info_alter(), thus does not have to be specified explicitly. @@ -684,7 +685,7 @@ function locale_library_info_alter(&$libraries, $module) { 'jquery' => array( 'ui' => array( 'datepicker' => array( - 'isRTL' => $language_interface->direction == LANGUAGE_RTL, + 'isRTL' => $language_interface->direction == Language::LANGUAGE_RTL, 'firstDay' => config('system.date')->get('first_day'), ), ), @@ -840,8 +841,8 @@ function locale_system_file_system_settings_submit(&$form, $form_state) { * Implements hook_preprocess_HOOK() for node.tpl.php. */ function locale_preprocess_node(&$variables) { - if ($variables['node']->langcode != LANGUAGE_NOT_SPECIFIED) { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + if ($variables['node']->langcode != Language::LANGUAGE_NOT_SPECIFIED) { + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); $node_language = language_load($variables['node']->langcode); if ($node_language->langcode != $language_interface->langcode) { @@ -1190,7 +1191,7 @@ function _locale_invalidate_js($langcode = NULL) { */ function _locale_rebuild_js($langcode = NULL) { if (!isset($langcode)) { - $language = language(LANGUAGE_TYPE_INTERFACE); + $language = language(Language::LANGUAGE_TYPE_INTERFACE); } else { // Get information about the locale. diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc index dcf12b9..96f570f 100644 --- a/core/modules/locale/locale.pages.inc +++ b/core/modules/locale/locale.pages.inc @@ -5,6 +5,7 @@ * Interface translation summary, editing and deletion user interfaces. */ +use Drupal\Core\Language\Language; use Drupal\locale\SourceString; use Drupal\locale\TranslationString; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -107,7 +108,7 @@ function locale_translate_filters() { } // Pick the current interface language code for the filter. - $default_langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode; + $default_langcode = language(Language::LANGUAGE_TYPE_INTERFACE)->langcode; if (!isset($language_options[$default_langcode])) { $available_langcodes = array_keys($language_options); $default_langcode = array_shift($available_langcodes); diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php index d2d023b..00455fb 100644 --- a/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php +++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php @@ -7,6 +7,7 @@ namespace Drupal\menu\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -62,7 +63,7 @@ function testMenuNodeFormWidget() { // Create a node. $node_title = $this->randomName(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit = array( "title" => $node_title, "body[$langcode][0][value]" => $this->randomString(), diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php index 4f5315e..63f8236 100644 --- a/core/modules/node/lib/Drupal/node/NodeFormController.php +++ b/core/modules/node/lib/Drupal/node/NodeFormController.php @@ -10,6 +10,7 @@ use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityFormController; +use Drupal\Core\Language\Language; /** * Form controller for the node edit forms. @@ -104,7 +105,7 @@ public function form(array $form, array &$form_state, EntityInterface $node) { '#title' => t('Language'), '#type' => 'language_select', '#default_value' => $node->langcode, - '#languages' => LANGUAGE_ALL, + '#languages' => Language::LANGUAGE_ALL, '#access' => isset($language_configuration['language_hidden']) && !$language_configuration['language_hidden'], ); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php index 1794e89..5c1f31c 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php @@ -10,6 +10,8 @@ /** * Tests the interaction of the node access system with fields. */ +use Drupal\Core\Language\Language; + class NodeAccessFieldTest extends NodeTestBase { /** @@ -55,7 +57,7 @@ public function setUp() { */ function testNodeAccessAdministerField() { // Create a page node. - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $field_data = array(); $value = $field_data[$langcode][0]['value'] = $this->randomName(); $node = $this->drupalCreateNode(array($this->field_name => $field_data)); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php index 0667e1b..c3bd762 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php @@ -7,6 +7,7 @@ namespace Drupal\node\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -49,7 +50,7 @@ public function testCommentPager() { 'nid' => $node->nid, 'subject' => $this->randomName(), 'comment_body' => array( - LANGUAGE_NOT_SPECIFIED => array( + Language::LANGUAGE_NOT_SPECIFIED => array( array('value' => $this->randomName()), ), ), @@ -87,7 +88,7 @@ public function testForumPager() { 'nid' => NULL, 'type' => 'forum', 'taxonomy_forums' => array( - LANGUAGE_NOT_SPECIFIED => array( + Language::LANGUAGE_NOT_SPECIFIED => array( array('tid' => $tid, 'vid' => $vid), ), ), diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php index 36baad2..b6f4600 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php @@ -8,6 +8,7 @@ namespace Drupal\node\Tests; use Drupal\Core\Database\Database; +use Drupal\Core\Language\Language; use Exception; /** @@ -45,7 +46,7 @@ function setUp() { function testNodeCreation() { // Create a node. $edit = array(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit["title"] = $this->randomName(8); $edit["body[$langcode][0][value]"] = $this->randomName(16); $this->drupalPost('node/add/page', $edit, t('Save')); @@ -67,7 +68,7 @@ function testFailedPageCreation() { 'uid' => $this->loggedInUser->uid, 'name' => $this->loggedInUser->name, 'type' => 'page', - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, 'title' => 'testing_transaction_exception', ); @@ -112,7 +113,7 @@ function testUnpublishedNodeCreation() { // Create a node. $edit = array(); $edit["title"] = $this->randomName(8); - $edit["body[" . LANGUAGE_NOT_SPECIFIED . "][0][value]"] = $this->randomName(16); + $edit["body[" . Language::LANGUAGE_NOT_SPECIFIED . "][0][value]"] = $this->randomName(16); $this->drupalPost('node/add/page', $edit, t('Save')); // Check that the user was redirected to the home page. diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php index 2333dd9..6d91875 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php @@ -7,6 +7,8 @@ namespace Drupal\node\Tests; +use Drupal\Core\Language\Language; + /** * Tests node_query_entity_field_access_alter(). */ @@ -44,13 +46,13 @@ function setUp() { // Creating 4 nodes with an entity field so we can test that sort of query // alter. All field values starts with 'A' so we can identify and fetch them // in the node_access_test module. - $settings = array('langcode' => LANGUAGE_NOT_SPECIFIED); + $settings = array('langcode' => Language::LANGUAGE_NOT_SPECIFIED); for ($i = 0; $i < 4; $i++) { $body = array( 'value' => 'A' . $this->randomName(32), 'format' => filter_default_format(), ); - $settings['body'][LANGUAGE_NOT_SPECIFIED][0] = $body; + $settings['body'][Language::LANGUAGE_NOT_SPECIFIED][0] = $body; $this->drupalCreateNode($settings); } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php index b66944a..7516b46 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php @@ -10,6 +10,8 @@ /** * Tests changing view modes for nodes. */ +use Drupal\Core\Language\Language; + class NodeEntityViewModeAlterTest extends NodeTestBase { /** @@ -34,7 +36,7 @@ function testNodeViewModeChange() { // Create a node. $edit = array(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit["title"] = $this->randomName(8); $edit["body[$langcode][0][value]"] = t('Data that should appear only in the body for the node.'); $edit["body[$langcode][0][summary]"] = t('Extra data that should appear only in the teaser for the node.'); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php index ffe0332..1d34590 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php @@ -85,7 +85,7 @@ function testMultilingualNodeForm() { $node = $this->drupalGetNodeByTitle($edit[$title_key]); $this->assertTrue($node, 'Node found in database.'); - $assert = isset($node->body['en']) && !isset($node->body[LANGUAGE_NOT_SPECIFIED]) && $node->body['en'][0]['value'] == $body_value; + $assert = isset($node->body['en']) && !isset($node->body[Language::LANGUAGE_NOT_SPECIFIED]) && $node->body['en'][0]['value'] == $body_value; $this->assertTrue($assert, 'Field language correctly set.'); // Change node language. @@ -102,7 +102,7 @@ function testMultilingualNodeForm() { $this->assertTrue($assert, 'Field language correctly changed.'); // Enable content language URL detection. - language_negotiation_set(LANGUAGE_TYPE_CONTENT, array(LANGUAGE_NEGOTIATION_URL => 0)); + language_negotiation_set(Language::LANGUAGE_TYPE_CONTENT, array(LANGUAGE_NEGOTIATION_URL => 0)); // Test multilingual field language fallback logic. $this->drupalGet("it/node/$node->nid"); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php index ce48614..71e03e6 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php @@ -7,6 +7,8 @@ namespace Drupal\node\Tests; +use Drupal\Core\Language\Language; + /** * Checks that the post information displays when enabled for a content type. */ @@ -39,7 +41,7 @@ function testPagePostInfo() { // Create a node. $edit = array(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit["title"] = $this->randomName(8); $edit["body[$langcode][0][value]"] = $this->randomName(16); $this->drupalPost('node/add/page', $edit, t('Save')); @@ -62,7 +64,7 @@ function testPageNotPostInfo() { // Create a node. $edit = array(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit["title"] = $this->randomName(8); $edit["body[$langcode][0][value]"] = $this->randomName(16); $this->drupalPost('node/add/page', $edit, t('Save')); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php index 2ce2abb..7eec490 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php @@ -10,6 +10,8 @@ /** * Tests the node revision functionality. */ +use Drupal\Core\Language\Language; + class NodeRevisionsTest extends NodeTestBase { protected $nodes; protected $logs; @@ -80,7 +82,7 @@ function testRevisions() { // Confirm the correct revision text appears on "view revisions" page. $this->drupalGet("node/$node->nid/revisions/$node->vid/view"); - $this->assertText($node->body[LANGUAGE_NOT_SPECIFIED][0]['value'], 'Correct text displays for version.'); + $this->assertText($node->body[Language::LANGUAGE_NOT_SPECIFIED][0]['value'], 'Correct text displays for version.'); // Confirm the correct log message appears on "revisions overview" page. $this->drupalGet("node/$node->nid/revisions"); @@ -97,7 +99,7 @@ function testRevisions() { array('@type' => 'Basic page', '%title' => $nodes[1]->label(), '%revision-date' => format_date($nodes[1]->revision_timestamp))), 'Revision reverted.'); $reverted_node = node_load($node->nid); - $this->assertTrue(($nodes[1]->body[LANGUAGE_NOT_SPECIFIED][0]['value'] == $reverted_node->body[LANGUAGE_NOT_SPECIFIED][0]['value']), 'Node reverted correctly.'); + $this->assertTrue(($nodes[1]->body[Language::LANGUAGE_NOT_SPECIFIED][0]['value'] == $reverted_node->body[Language::LANGUAGE_NOT_SPECIFIED][0]['value']), 'Node reverted correctly.'); // Confirm that this is not the default version. $node = node_revision_load($node->vid); @@ -130,7 +132,7 @@ function testRevisions() { // This will create a new revision that is not "front facing". $new_node_revision = clone $node; $new_body = $this->randomName(); - $new_node_revision->body[LANGUAGE_NOT_SPECIFIED][0]['value'] = $new_body; + $new_node_revision->body[Language::LANGUAGE_NOT_SPECIFIED][0]['value'] = $new_body; // Save this as a non-default revision. $new_node_revision->setNewRevision(); $new_node_revision->isDefaultRevision = FALSE; @@ -282,7 +284,7 @@ function testRevisions() { // Confirm the correct revision text appears on "view revisions" page. $this->drupalGet("node/$node->nid/revisions/$node->vid/view"); - $this->assertText($node->body[LANGUAGE_NOT_SPECIFIED][0]['value'], t('Correct text displays for version.')); + $this->assertText($node->body[Language::LANGUAGE_NOT_SPECIFIED][0]['value'], t('Correct text displays for version.')); // Confirm the correct log message appears on "revisions overview" page. $this->drupalGet("node/$node->nid/revisions"); @@ -303,7 +305,7 @@ function testRevisions() { )), 'Revision reverted.'); $reverted_node = node_load($node->nid); - $this->assertTrue(($nodes[1]->body[LANGUAGE_NOT_SPECIFIED][0]['value'] == $reverted_node->body[LANGUAGE_NOT_SPECIFIED][0]['value']), t('Node reverted correctly.')); + $this->assertTrue(($nodes[1]->body[Language::LANGUAGE_NOT_SPECIFIED][0]['value'] == $reverted_node->body[Language::LANGUAGE_NOT_SPECIFIED][0]['value']), t('Node reverted correctly.')); // Confirm that this is not the current version. $node = node_load($node->nid, $node->vid); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php index f86bc52..5b58a81 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php @@ -7,6 +7,8 @@ namespace Drupal\node\Tests; +use Drupal\Core\Language\Language; + /** * Tests node save related functionality, including import-save. */ @@ -51,7 +53,7 @@ function testImport() { $title = $this->randomName(8); $node = array( 'title' => $title, - 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->randomName(32)))), + 'body' => array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->randomName(32)))), 'uid' => $this->web_user->uid, 'type' => 'article', 'nid' => $test_nid, diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php index 452f0f4..b41e4cc 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php @@ -7,6 +7,8 @@ namespace Drupal\node\Tests; +use Drupal\Core\Language\Language; + /** * Test node token replacement in strings. */ @@ -23,7 +25,7 @@ public static function getInfo() { * Creates a node, then tests the tokens generated from it. */ function testNodeTokenReplacement() { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); $url_options = array( 'absolute' => TRUE, 'language' => $language_interface, @@ -35,7 +37,7 @@ function testNodeTokenReplacement() { 'type' => 'article', 'uid' => $account->uid, 'title' => 'Blinking Text', - 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->randomName(32), 'summary' => $this->randomName(16)))), + 'body' => array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->randomName(32), 'summary' => $this->randomName(16)))), ); $node = $this->drupalCreateNode($settings); @@ -83,7 +85,7 @@ function testNodeTokenReplacement() { } // Repeat for a node without a summary. - $settings['body'] = array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->randomName(32), 'summary' => ''))); + $settings['body'] = array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->randomName(32), 'summary' => ''))); $node = $this->drupalCreateNode($settings); // Load node (without summary) so that the body and summary fields are diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTypeInitialLanguageTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTypeInitialLanguageTest.php index b689141..ad1b816 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTypeInitialLanguageTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTypeInitialLanguageTest.php @@ -7,6 +7,8 @@ namespace Drupal\node\Tests; +use Drupal\Core\Language\Language; + /** * Tests related to node type initial language. */ @@ -98,7 +100,7 @@ function testNodeTypeInitialLanguageDefaults() { * Tests language field visibility features. */ function testLanguageFieldVisibility() { - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Creates a node to test Language field visibility feature. $edit = array( diff --git a/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php b/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php index 20ebfbd..c287bdb 100644 --- a/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php @@ -7,6 +7,8 @@ namespace Drupal\node\Tests; +use Drupal\Core\Language\Language; + /** * Tests the node edit functionality. */ @@ -35,7 +37,7 @@ function setUp() { function testPageEdit() { $this->drupalLogin($this->web_user); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $title_key = "title"; $body_key = "body[$langcode][0][value]"; // Create node to edit. @@ -103,7 +105,7 @@ function testPageAuthoredBy() { $this->drupalLogin($this->admin_user); // Create node to edit. - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $body_key = "body[$langcode][0][value]"; $edit = array(); $edit['title'] = $this->randomName(8); diff --git a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php index b429e07..3c9c42d 100644 --- a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php @@ -7,6 +7,8 @@ namespace Drupal\node\Tests; +use Drupal\Core\Language\Language; + /** * Tests the node entity preview functionality. */ @@ -30,7 +32,7 @@ function setUp() { * Checks the node preview functionality. */ function testPagePreview() { - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $title_key = "title"; $body_key = "body[$langcode][0][value]"; @@ -54,7 +56,7 @@ function testPagePreview() { * Checks the node preview functionality, when using revisions. */ function testPagePreviewWithRevisions() { - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $title_key = "title"; $body_key = "body[$langcode][0][value]"; // Force revision on "Basic page" content. diff --git a/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php b/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php index 6b966e8..b657fac 100644 --- a/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php @@ -7,6 +7,8 @@ namespace Drupal\node\Tests; +use Drupal\Core\Language\Language; + /** * Tests the summary length functionality. */ @@ -25,7 +27,7 @@ public static function getInfo() { function testSummaryLength() { // Create a node to view. $settings = array( - 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vitae arcu at leo cursus laoreet. Curabitur dui tortor, adipiscing malesuada tempor in, bibendum ac diam. Cras non tellus a libero pellentesque condimentum. What is a Drupalism? Suspendisse ac lacus libero. Ut non est vel nisl faucibus interdum nec sed leo. Pellentesque sem risus, vulputate eu semper eget, auctor in libero. Ut fermentum est vitae metus convallis scelerisque. Phasellus pellentesque rhoncus tellus, eu dignissim purus posuere id. Quisque eu fringilla ligula. Morbi ullamcorper, lorem et mattis egestas, tortor neque pretium velit, eget eleifend odio turpis eu purus. Donec vitae metus quis leo pretium tincidunt a pulvinar sem. Morbi adipiscing laoreet mauris vel placerat. Nullam elementum, nisl sit amet scelerisque malesuada, dolor nunc hendrerit quam, eu ultrices erat est in orci. Curabitur feugiat egestas nisl sed accumsan.'))), + 'body' => array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vitae arcu at leo cursus laoreet. Curabitur dui tortor, adipiscing malesuada tempor in, bibendum ac diam. Cras non tellus a libero pellentesque condimentum. What is a Drupalism? Suspendisse ac lacus libero. Ut non est vel nisl faucibus interdum nec sed leo. Pellentesque sem risus, vulputate eu semper eget, auctor in libero. Ut fermentum est vitae metus convallis scelerisque. Phasellus pellentesque rhoncus tellus, eu dignissim purus posuere id. Quisque eu fringilla ligula. Morbi ullamcorper, lorem et mattis egestas, tortor neque pretium velit, eget eleifend odio turpis eu purus. Donec vitae metus quis leo pretium tincidunt a pulvinar sem. Morbi adipiscing laoreet mauris vel placerat. Nullam elementum, nisl sit amet scelerisque malesuada, dolor nunc hendrerit quam, eu ultrices erat est in orci. Curabitur feugiat egestas nisl sed accumsan.'))), 'promote' => 1, ); $node = $this->drupalCreateNode($settings); diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc index 74f100c..da5ac95 100644 --- a/core/modules/node/node.admin.inc +++ b/core/modules/node/node.admin.inc @@ -6,6 +6,7 @@ */ use Drupal\Core\Database\Query\SelectInterface; +use Drupal\Core\Language\Language; /** * Page callback: Form constructor for the permission rebuild confirmation form. @@ -110,7 +111,7 @@ function node_filters() { // Language filter if language support is present. if (language_multilingual()) { - $languages = language_list(LANGUAGE_ALL); + $languages = language_list(Language::LANGUAGE_ALL); foreach ($languages as $langcode => $language) { // Make locked languages appear special in the list. $language_options[$langcode] = $language->locked ? t('- @name -', array('@name' => $language->name)) : $language->name; @@ -520,7 +521,7 @@ function node_admin_nodes() { $nodes = node_load_multiple($nids); // Prepare the list of nodes. - $languages = language_list(LANGUAGE_ALL); + $languages = language_list(Language::LANGUAGE_ALL); $destination = drupal_get_destination(); $form['nodes'] = array( '#type' => 'table', @@ -528,7 +529,7 @@ function node_admin_nodes() { '#empty' => t('No content available.'), ); foreach ($nodes as $node) { - $l_options = $node->langcode != LANGUAGE_NOT_SPECIFIED && isset($languages[$node->langcode]) ? array('language' => $languages[$node->langcode]) : array(); + $l_options = $node->langcode != Language::LANGUAGE_NOT_SPECIFIED && isset($languages[$node->langcode]) ? array('language' => $languages[$node->langcode]) : array(); $form['nodes'][$node->nid]['title'] = array( '#type' => 'link', '#title' => $node->label(), diff --git a/core/modules/node/node.install b/core/modules/node/node.install index 697d3a7..49d485a 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -1,4 +1,7 @@ -fetchCol(); foreach ($types as $type) { - update_variable_set('node_type_language_default_' . $type, LANGUAGE_NOT_SPECIFIED); + update_variable_set('node_type_language_default_' . $type, Language::LANGUAGE_NOT_SPECIFIED); $node_type_language = update_variable_get('node_type_language_' . $type, 0); if ($node_type_language == 0) { update_variable_set('node_type_language_hidden_' . $type, TRUE); @@ -541,7 +544,7 @@ function node_update_8003() { if ($node_type_language == 2) { // Translation was enabled, so enable it again and // unhide the language selector. Because if language is - // LANGUAGE_NOT_SPECIFIED and the selector hidden, translation + // Language::LANGUAGE_NOT_SPECIFIED and the selector hidden, translation // cannot be enabled. update_variable_set('node_type_language_hidden_' . $type, FALSE); update_variable_set('node_type_language_translation_enabled_' . $type, TRUE); diff --git a/core/modules/node/node.module b/core/modules/node/node.module index d56bee5..2e5091f 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -8,6 +8,7 @@ * API pattern. */ +use Drupal\Core\Language\Language; use Symfony\Component\HttpFoundation\Response; use Drupal\Core\Cache\CacheBackendInterface; @@ -690,7 +691,7 @@ function node_type_update_nodes($old_type, $type) { * type object by $type->disabled being set to TRUE. */ function _node_types_build($rebuild = FALSE) { - $cid = 'node_types:' . language(LANGUAGE_TYPE_INTERFACE)->langcode; + $cid = 'node_types:' . language(Language::LANGUAGE_TYPE_INTERFACE)->langcode; if (!$rebuild) { $_node_types = &drupal_static(__FUNCTION__); @@ -2227,7 +2228,7 @@ function node_block_list_alter(&$blocks) { */ function node_feed($nids = FALSE, $channel = array()) { global $base_url; - $language_content = language(LANGUAGE_TYPE_CONTENT); + $language_content = language(Language::LANGUAGE_TYPE_CONTENT); $rss_config = config('system.rss'); if ($nids === FALSE) { @@ -2528,7 +2529,7 @@ function node_form_search_form_alter(&$form, $form_state) { // Languages: $language_options = array(); - foreach (language_list(LANGUAGE_ALL) as $langcode => $language) { + foreach (language_list(Language::LANGUAGE_ALL) as $langcode => $language) { // Make locked languages appear special in the list. $language_options[$langcode] = $language->locked ? t('- @name -', array('@name' => $language->name)) : $language->name; } diff --git a/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php b/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php index 232acea..606e892 100644 --- a/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php +++ b/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php @@ -7,6 +7,7 @@ namespace Drupal\number\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -76,7 +77,7 @@ function testNumberDecimalField() { // Display creation form. $this->drupalGet('test-entity/add/test_bundle'); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $this->assertFieldByName("{$this->field['field_name']}[$langcode][0][value]", '', 'Widget is displayed'); $this->assertRaw('placeholder="0.00"'); diff --git a/core/modules/openid/openid.inc b/core/modules/openid/openid.inc index 8d5aae9..128ddcc 100644 --- a/core/modules/openid/openid.inc +++ b/core/modules/openid/openid.inc @@ -5,6 +5,8 @@ * OpenID utility functions. */ +use Drupal\Core\Language\Language; + /** * Diffie-Hellman Key Exchange Default Value. * @@ -83,7 +85,7 @@ function openid_redirect_http($url, $message) { * Creates a js auto-submit redirect for (for the 2.x protocol) */ function openid_redirect($url, $message) { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); $output = '' . "\n"; $output .= '' . "\n"; diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesValidationTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesValidationTest.php index 0fa0763..06319e9 100644 --- a/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesValidationTest.php +++ b/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesValidationTest.php @@ -7,6 +7,7 @@ namespace Drupal\options\Tests; +use Drupal\Core\Language\Language; use Drupal\field\FieldValidationException; /** @@ -27,7 +28,7 @@ public static function getInfo() { function testDynamicAllowedValues() { // Verify that the test passes against every value we had. foreach ($this->test as $key => $value) { - $this->entity->test_options[LANGUAGE_NOT_SPECIFIED][0]['value'] = $value; + $this->entity->test_options[Language::LANGUAGE_NOT_SPECIFIED][0]['value'] = $value; try { field_attach_validate('test_entity', $this->entity); $this->pass("$key should pass"); @@ -39,7 +40,7 @@ function testDynamicAllowedValues() { } // Now verify that the test does not pass against anything else. foreach ($this->test as $key => $value) { - $this->entity->test_options[LANGUAGE_NOT_SPECIFIED][0]['value'] = is_numeric($value) ? (100 - $value) : ('X' . $value); + $this->entity->test_options[Language::LANGUAGE_NOT_SPECIFIED][0]['value'] = is_numeric($value) ? (100 - $value) : ('X' . $value); $pass = FALSE; try { field_attach_validate('test_entity', $this->entity); diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php index 1027eb1..f16e7cf 100644 --- a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php +++ b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php @@ -7,6 +7,7 @@ namespace Drupal\options\Tests; +use Drupal\Core\Language\Language; use Drupal\field\FieldException; use Drupal\field\Tests\FieldTestBase; @@ -59,7 +60,7 @@ function setUp() { * Test that allowed values can be updated. */ function testUpdateAllowedValues() { - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // All three options appear. $entity = field_test_create_entity(); diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php index 8723bbf..82e5706 100644 --- a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php +++ b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php @@ -7,6 +7,7 @@ namespace Drupal\options\Tests; +use Drupal\Core\Language\Language; use Drupal\field\Tests\FieldTestBase; /** @@ -70,7 +71,7 @@ function testOptionsAllowedValuesInteger() { // Create a node with actual data for the field. $settings = array( 'type' => $this->type, - $this->field_name => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => 1))), + $this->field_name => array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => 1))), ); $node = $this->drupalCreateNode($settings); @@ -120,7 +121,7 @@ function testOptionsAllowedValuesFloat() { // Create a node with actual data for the field. $settings = array( 'type' => $this->type, - $this->field_name => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => .5))), + $this->field_name => array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => .5))), ); $node = $this->drupalCreateNode($settings); @@ -172,7 +173,7 @@ function testOptionsAllowedValuesText() { // Create a node with actual data for the field. $settings = array( 'type' => $this->type, - $this->field_name => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => 'One'))), + $this->field_name => array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => 'One'))), ); $node = $this->drupalCreateNode($settings); diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php index 6804b6a..7d8fbcf 100644 --- a/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php +++ b/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php @@ -7,6 +7,7 @@ namespace Drupal\options\Tests; +use Drupal\Core\Language\Language; use Drupal\field\Tests\FieldTestBase; /** @@ -87,7 +88,7 @@ function testRadioButtons() { ), ); $instance = field_create_instance($instance); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Create an entity. $entity_init = field_test_create_entity(); @@ -141,7 +142,7 @@ function testCheckBoxes() { ), ); $instance = field_create_instance($instance); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Create an entity. $entity_init = field_test_create_entity(); @@ -229,7 +230,7 @@ function testSelectListSingle() { ), ); $instance = field_create_instance($instance); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Create an entity. $entity_init = field_test_create_entity(); @@ -325,7 +326,7 @@ function testSelectListMultiple() { ), ); $instance = field_create_instance($instance); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Create an entity. $entity_init = field_test_create_entity(); @@ -442,7 +443,7 @@ function testOnOffCheckbox() { ), ); $instance = field_create_instance($instance); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Create an entity. $entity_init = field_test_create_entity(); diff --git a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php index 83be7b5..2848f0b 100644 --- a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php +++ b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php @@ -7,6 +7,8 @@ namespace Drupal\path\Tests; +use Drupal\Core\Language\Language; + /** * Tests URL aliases for translated nodes. */ @@ -74,7 +76,7 @@ function testAliasTranslation() { $this->drupalGet('node/' . $english_node->nid . '/translate'); $this->clickLink(t('add translation')); $edit = array(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit["title"] = $this->randomName(); $edit["body[$langcode][0][value]"] = $this->randomName(); $french_alias = $this->randomName(); diff --git a/core/modules/path/path.admin.inc b/core/modules/path/path.admin.inc index 0535454..d9d2207 100644 --- a/core/modules/path/path.admin.inc +++ b/core/modules/path/path.admin.inc @@ -5,6 +5,8 @@ * Administrative page callbacks for the path module. */ +use Drupal\Core\Language\Language; + /** * Returns a listing of all defined URL aliases. * @@ -16,7 +18,7 @@ function path_admin_overview($keys = NULL) { $build['path_admin_filter_form'] = drupal_get_form('path_admin_filter_form', $keys); // Enable language column if language.module is enabled or if we have any // alias with a language. - $alias_exists = (bool) db_query_range('SELECT 1 FROM {url_alias} WHERE langcode <> :langcode', 0, 1, array(':langcode' => LANGUAGE_NOT_SPECIFIED))->fetchField(); + $alias_exists = (bool) db_query_range('SELECT 1 FROM {url_alias} WHERE langcode <> :langcode', 0, 1, array(':langcode' => Language::LANGUAGE_NOT_SPECIFIED))->fetchField(); $multilanguage = (module_exists('language') || $alias_exists); $header = array(); @@ -127,7 +129,7 @@ function path_admin_edit($path = array()) { * @see path_admin_form_submit() * @see path_admin_form_delete_submit() */ -function path_admin_form($form, &$form_state, $path = array('source' => '', 'alias' => '', 'langcode' => LANGUAGE_NOT_SPECIFIED, 'pid' => NULL)) { +function path_admin_form($form, &$form_state, $path = array('source' => '', 'alias' => '', 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, 'pid' => NULL)) { $form['source'] = array( '#type' => 'textfield', '#title' => t('Existing system path'), @@ -160,7 +162,7 @@ function path_admin_form($form, &$form_state, $path = array('source' => '', 'ali '#type' => 'select', '#title' => t('Language'), '#options' => $language_options, - '#empty_value' => LANGUAGE_NOT_SPECIFIED, + '#empty_value' => Language::LANGUAGE_NOT_SPECIFIED, '#empty_option' => t('- None -'), '#default_value' => $path['langcode'], '#weight' => -10, @@ -222,7 +224,7 @@ function path_admin_form_validate($form, &$form_state) { $pid = isset($form_state['values']['pid']) ? $form_state['values']['pid'] : 0; // Language is only set if language.module is enabled, otherwise save for all // languages. - $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : LANGUAGE_NOT_SPECIFIED; + $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : Language::LANGUAGE_NOT_SPECIFIED; $has_alias = db_query("SELECT COUNT(alias) FROM {url_alias} WHERE pid <> :pid AND alias = :alias AND langcode = :langcode", array( ':pid' => $pid, @@ -255,7 +257,7 @@ function path_admin_form_submit($form, &$form_state) { $alias = $form_state['values']['alias']; // Language is only set if language.module is enabled, otherwise save for all // languages. - $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : LANGUAGE_NOT_SPECIFIED; + $langcode = isset($form_state['values']['langcode']) ? $form_state['values']['langcode'] : Language::LANGUAGE_NOT_SPECIFIED; drupal_container()->get('path.crud')->save($source, $alias, $langcode, $pid); diff --git a/core/modules/path/path.module b/core/modules/path/path.module index 63e5c6c..afed0ae 100644 --- a/core/modules/path/path.module +++ b/core/modules/path/path.module @@ -5,6 +5,7 @@ * Enables users to rename URLs. */ +use Drupal\Core\Language\Language; use Drupal\node\Plugin\Core\Entity\Node; use Drupal\taxonomy\Plugin\Core\Entity\Term; @@ -104,7 +105,7 @@ function path_form_node_form_alter(&$form, $form_state) { $path = array(); if (!empty($node->nid)) { $conditions = array('source' => 'node/' . $node->nid); - if ($node->langcode != LANGUAGE_NOT_SPECIFIED) { + if ($node->langcode != Language::LANGUAGE_NOT_SPECIFIED) { $conditions['langcode'] = $node->langcode; } $path = drupal_container()->get('path.crud')->load($conditions); @@ -116,7 +117,7 @@ function path_form_node_form_alter(&$form, $form_state) { 'pid' => NULL, 'source' => isset($node->nid) ? 'node/' . $node->nid : NULL, 'alias' => '', - 'langcode' => isset($node->langcode) ? $node->langcode : LANGUAGE_NOT_SPECIFIED, + 'langcode' => isset($node->langcode) ? $node->langcode : Language::LANGUAGE_NOT_SPECIFIED, ); $form['path'] = array( @@ -195,7 +196,7 @@ function path_node_insert(Node $node) { if (!empty($alias)) { // Ensure fields for programmatic executions. $source = 'node/' . $node->nid; - $langcode = isset($node->langcode) ? $node->langcode : LANGUAGE_NOT_SPECIFIED; + $langcode = isset($node->langcode) ? $node->langcode : Language::LANGUAGE_NOT_SPECIFIED; drupal_container()->get('path.crud')->save($source, $alias, $langcode); } } @@ -216,7 +217,7 @@ function path_node_update(Node $node) { if (!empty($path['alias'])) { // Ensure fields for programmatic executions. $source = 'node/' . $node->nid; - $langcode = isset($node->langcode) ? $node->langcode : LANGUAGE_NOT_SPECIFIED; + $langcode = isset($node->langcode) ? $node->langcode : Language::LANGUAGE_NOT_SPECIFIED; drupal_container()->get('path.crud')->save($source, $alias, $langcode, $path['pid']); } } @@ -245,7 +246,7 @@ function path_form_taxonomy_term_form_alter(&$form, $form_state) { 'pid' => NULL, 'source' => isset($term->tid) ? 'taxonomy/term/' . $term->tid : NULL, 'alias' => '', - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, ); $form['path'] = array( '#access' => user_access('create url aliases') || user_access('administer url aliases'), @@ -277,7 +278,7 @@ function path_taxonomy_term_insert(Term $term) { if (!empty($path['alias'])) { // Ensure fields for programmatic executions. $path['source'] = 'taxonomy/term/' . $term->tid; - $path['langcode'] = LANGUAGE_NOT_SPECIFIED; + $path['langcode'] = Language::LANGUAGE_NOT_SPECIFIED; drupal_container()->get('path.crud')->save($path['source'], $path['alias'], $path['langcode']); } } @@ -299,7 +300,7 @@ function path_taxonomy_term_update(Term $term) { $pid = (!empty($path['pid']) ? $path['pid'] : NULL); // Ensure fields for programmatic executions. $path['source'] = 'taxonomy/term/' . $term->tid; - $path['langcode'] = LANGUAGE_NOT_SPECIFIED; + $path['langcode'] = Language::LANGUAGE_NOT_SPECIFIED; drupal_container()->get('path.crud')->save($path['source'], $path['alias'], $path['langcode'], $pid); } } diff --git a/core/modules/php/lib/Drupal/php/Tests/PhpFilterTest.php b/core/modules/php/lib/Drupal/php/Tests/PhpFilterTest.php index ffab8c5..e448d5b 100644 --- a/core/modules/php/lib/Drupal/php/Tests/PhpFilterTest.php +++ b/core/modules/php/lib/Drupal/php/Tests/PhpFilterTest.php @@ -7,6 +7,8 @@ namespace Drupal\php\Tests; +use Drupal\Core\Language\Language; + /** * Tests to make sure the PHP filter actually evaluates PHP code when used. */ @@ -37,7 +39,7 @@ function testPhpFilter() { // Change filter to PHP filter and see that PHP code is evaluated. $edit = array(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit["body[$langcode][0][format]"] = $this->php_code_format->format; $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); $this->assertRaw(t('Basic page %title has been updated.', array('%title' => $node->label())), 'PHP code filter turned on.'); diff --git a/core/modules/php/lib/Drupal/php/Tests/PhpTestBase.php b/core/modules/php/lib/Drupal/php/Tests/PhpTestBase.php index 596ebd8..21452cc 100644 --- a/core/modules/php/lib/Drupal/php/Tests/PhpTestBase.php +++ b/core/modules/php/lib/Drupal/php/Tests/PhpTestBase.php @@ -7,6 +7,7 @@ namespace Drupal\php\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -58,6 +59,6 @@ function setUp() { * @return stdObject Node object. */ function createNodeWithCode() { - return $this->drupalCreateNode(array('body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => ''))))); + return $this->drupalCreateNode(array('body' => array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => ''))))); } } diff --git a/core/modules/picture/lib/Drupal/picture/Tests/PictureFieldDisplayTest.php b/core/modules/picture/lib/Drupal/picture/Tests/PictureFieldDisplayTest.php index de0f782..9efc9da 100644 --- a/core/modules/picture/lib/Drupal/picture/Tests/PictureFieldDisplayTest.php +++ b/core/modules/picture/lib/Drupal/picture/Tests/PictureFieldDisplayTest.php @@ -7,6 +7,7 @@ namespace Drupal\picture\Tests; +use Drupal\Core\Language\Language; use Drupal\breakpoint\Plugin\Core\Entity\Breakpoint; use Drupal\image\Tests\ImageFieldTestBase; @@ -121,7 +122,7 @@ public function _testPictureFieldFormatters($scheme) { $node = node_load($nid, TRUE); // Test that the default formatter is being used. - $image_uri = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri; + $image_uri = file_load($node->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED][0]['fid'])->uri; $image_info = array( 'uri' => $image_uri, 'width' => 40, diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollTokenReplaceTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollTokenReplaceTest.php index 13f2f79..e5f0536 100644 --- a/core/modules/poll/lib/Drupal/poll/Tests/PollTokenReplaceTest.php +++ b/core/modules/poll/lib/Drupal/poll/Tests/PollTokenReplaceTest.php @@ -23,7 +23,7 @@ public static function getInfo() { * Creates a poll, then tests the tokens generated from it. */ function testPollTokenReplacement() { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); // Craete a poll with three choices. $title = $this->randomName(); diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php index 368d221..dabfb4c 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php @@ -7,6 +7,7 @@ namespace Drupal\rdf\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -102,7 +103,7 @@ function testAttributesInMarkupFile() { $admin_user = $this->drupalCreateUser(array('edit own article content', 'revert article revisions', 'administer content types')); $this->drupalLogin($admin_user); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $bundle_name = "article"; $field_name = 'file_test'; @@ -170,7 +171,7 @@ function testAttributesInMarkupFile() { $tag1 = $this->randomName(8); $tag2 = $this->randomName(8); $edit = array(); - $edit['field_tags[' . LANGUAGE_NOT_SPECIFIED . ']'] = "$tag1, $tag2"; + $edit['field_tags[' . Language::LANGUAGE_NOT_SPECIFIED . ']'] = "$tag1, $tag2"; $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); // Ensures the RDFa markup for the relationship between the node and its // tags is correct. diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php index b7771c6..b4d65b9 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php @@ -7,6 +7,7 @@ namespace Drupal\rdf\Tests; +use Drupal\Core\Language\Language; use Drupal\node\Plugin\Core\Entity\Node; use Drupal\simpletest\WebTestBase; @@ -117,7 +118,7 @@ function _testBasicTrackerRdfaMarkup(Node $node) { // date has been added to the tracker output after a comment is posted. $comment = array( 'subject' => $this->randomName(), - 'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(), + 'comment_body[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(), ); $this->drupalPost('comment/reply/' . $node->nid, $comment, t('Save')); $this->drupalGet('tracker'); diff --git a/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php b/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php index 6808020..a35198e 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/ReadTest.php @@ -7,6 +7,7 @@ namespace Drupal\rest\Tests; +use Drupal\Core\Language\Language; use Drupal\rest\Tests\RESTTestBase; /** @@ -57,7 +58,7 @@ public function testRead() { $data = drupal_json_decode($response); // Only assert one example property here, other properties should be // checked in serialization tests. - $this->assertEqual($data['uuid'][LANGUAGE_DEFAULT][0]['value'], $entity->uuid(), 'Entity UUID is correct'); + $this->assertEqual($data['uuid'][Language::LANGUAGE_DEFAULT][0]['value'], $entity->uuid(), 'Entity UUID is correct'); // Try to read the entity with an unsupported media format. $response = $this->httpRequest('entity/' . $entity_type . '/' . $entity->id(), 'GET', NULL, 'application/wrongformat'); diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php index 338174d..d6453e0 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php @@ -7,6 +7,8 @@ namespace Drupal\search\Tests; +use Drupal\Core\Language\Language; + /** * Tests that comment count display toggles properly on comment status of node * @@ -47,7 +49,7 @@ function setUp() { $this->searching_user = $this->drupalCreateUser(array('search content', 'access content', 'access comments', 'skip comment approval')); // Create initial nodes. - $node_params = array('type' => 'article', 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => 'SearchCommentToggleTestCase')))); + $node_params = array('type' => 'article', 'body' => array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => 'SearchCommentToggleTestCase')))); $this->searchable_nodes['1 comment'] = $this->drupalCreateNode($node_params); $this->searchable_nodes['0 comments'] = $this->drupalCreateNode($node_params); @@ -58,9 +60,9 @@ function setUp() { // Create a comment array $edit_comment = array(); $edit_comment['subject'] = $this->randomName(); - $edit_comment['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]'] = $this->randomName(); + $edit_comment['comment_body[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][value]'] = $this->randomName(); $filtered_html_format_id = 'filtered_html'; - $edit_comment['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][format]'] = $filtered_html_format_id; + $edit_comment['comment_body[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][format]'] = $filtered_html_format_id; // Post comment to the test node with comment $this->drupalPost('comment/reply/' . $this->searchable_nodes['1 comment']->nid, $edit_comment, t('Save')); diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php index d6c25b1..1c0514d 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php @@ -7,6 +7,8 @@ namespace Drupal\search\Tests; +use Drupal\Core\Language\Language; + /** * Test integration searching comments. */ @@ -75,9 +77,9 @@ function testSearchResultsComment() { // Post a comment using 'Full HTML' text format. $edit_comment = array(); $edit_comment['subject'] = 'Test comment subject'; - $edit_comment['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]'] = '

' . $comment_body . '

'; + $edit_comment['comment_body[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][value]'] = '

' . $comment_body . '

'; $full_html_format_id = 'full_html'; - $edit_comment['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][format]'] = $full_html_format_id; + $edit_comment['comment_body[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][format]'] = $full_html_format_id; $this->drupalPost('comment/reply/' . $node->nid, $edit_comment, t('Save')); // Invoke search index update. @@ -103,7 +105,7 @@ function testSearchResultsComment() { // Verify that comment is rendered using proper format. $this->assertText($comment_body, 'Comment body text found in search results.'); $this->assertNoRaw(t('n/a'), 'HTML in comment body is not hidden.'); - $this->assertNoRaw(check_plain($edit_comment['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]']), 'HTML in comment body is not escaped.'); + $this->assertNoRaw(check_plain($edit_comment['comment_body[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][value]']), 'HTML in comment body is not escaped.'); // Hide comments. $this->drupalLogin($this->admin_user); @@ -136,7 +138,7 @@ function testSearchResultsCommentAccess() { // Post a comment using 'Full HTML' text format. $edit_comment = array(); $edit_comment['subject'] = $this->comment_subject; - $edit_comment['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]'] = '

' . $comment_body . '

'; + $edit_comment['comment_body[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][value]'] = '

' . $comment_body . '

'; $this->drupalPost('comment/reply/' . $this->node->nid, $edit_comment, t('Save')); $this->drupalLogout(); @@ -221,7 +223,7 @@ function testAddNewComment() { $settings = array( 'type' => 'article', 'title' => 'short title', - 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => 'short body text'))), + 'body' => array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => 'short body text'))), ); $user = $this->drupalCreateUser(array('search content', 'create article content', 'access content')); diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php index 066da60..9df33fb 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php @@ -7,6 +7,8 @@ namespace Drupal\search\Tests; +use Drupal\Core\Language\Language; + /** * Test config page. */ @@ -42,7 +44,7 @@ function setUp() { $this->search_node = $node; // Link the node to itself to test that it's only indexed once. The content // also needs the word "pizza" so we can use it as the search keyword. - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $body_key = "body[$langcode][0][value]"; $edit[$body_key] = l($node->label(), 'node/' . $node->nid) . ' pizza sandwich'; $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchExactTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchExactTest.php index 7d3ba42..78906cb 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchExactTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchExactTest.php @@ -7,6 +7,8 @@ namespace Drupal\search\Tests; +use Drupal\Core\Language\Language; + /** * Tests that searching for a phrase gets the correct page count. */ @@ -32,12 +34,12 @@ function testExactQuery() { ); // Create nodes with exact phrase. for ($i = 0; $i <= 17; $i++) { - $settings['body'] = array(LANGUAGE_NOT_SPECIFIED => array(array('value' => 'love pizza'))); + $settings['body'] = array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => 'love pizza'))); $this->drupalCreateNode($settings); } // Create nodes containing keywords. for ($i = 0; $i <= 17; $i++) { - $settings['body'] = array(LANGUAGE_NOT_SPECIFIED => array(array('value' => 'love cheesy pizza'))); + $settings['body'] = array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => 'love cheesy pizza'))); $this->drupalCreateNode($settings); } diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchMatchTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchMatchTest.php index 118cbf7..cd5a53d 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchMatchTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchMatchTest.php @@ -7,6 +7,8 @@ namespace Drupal\search\Tests; +use Drupal\Core\Language\Language; + // The search index can contain different types of content. Typically the type // is 'node'. Here we test with _test_ and _test2_ as the type. const SEARCH_TYPE = '_test_'; @@ -37,10 +39,10 @@ function _setup() { config('search.settings')->set('index.minimum_word_size', 3)->save(); for ($i = 1; $i <= 7; ++$i) { - search_index($i, SEARCH_TYPE, $this->getText($i), LANGUAGE_NOT_SPECIFIED); + search_index($i, SEARCH_TYPE, $this->getText($i), Language::LANGUAGE_NOT_SPECIFIED); } for ($i = 1; $i <= 5; ++$i) { - search_index($i + 7, SEARCH_TYPE_2, $this->getText2($i), LANGUAGE_NOT_SPECIFIED); + search_index($i + 7, SEARCH_TYPE_2, $this->getText2($i), Language::LANGUAGE_NOT_SPECIFIED); } // No getText builder function for Japanese text; just a simple array. foreach (array( @@ -48,7 +50,7 @@ function _setup() { 14 => 'ドルーパルが大好きよ!', 15 => 'コーヒーとケーキ', ) as $i => $jpn) { - search_index($i, SEARCH_TYPE_JPN, $jpn, LANGUAGE_NOT_SPECIFIED); + search_index($i, SEARCH_TYPE_JPN, $jpn, Language::LANGUAGE_NOT_SPECIFIED); } search_update_totals(); } diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchNodeAccessTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchNodeAccessTest.php index 19c94cb..924e111 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchNodeAccessTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchNodeAccessTest.php @@ -7,6 +7,8 @@ namespace Drupal\search\Tests; +use Drupal\Core\Language\Language; + /** * Tests node search with node access control. */ @@ -42,7 +44,7 @@ function setUp() { * Tests that search returns results with punctuation in the search phrase. */ function testPhraseSearchPunctuation() { - $node = $this->drupalCreateNode(array('body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => "The bunny's ears were fluffy."))))); + $node = $this->drupalCreateNode(array('body' => array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => "The bunny's ears were fluffy."))))); // Update the search index. module_invoke_all('update_index'); diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php index 540526b..0aa3b3c 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchNumberMatchingTest.php @@ -7,6 +7,8 @@ namespace Drupal\search\Tests; +use Drupal\Core\Language\Language; + /** * Tests that numbers can be searched, with more complex matching. */ @@ -45,9 +47,9 @@ function setUp() { foreach ($this->numbers as $num) { $info = array( - 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $num))), + 'body' => array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => $num))), 'type' => 'page', - 'language' => LANGUAGE_NOT_SPECIFIED, + 'language' => Language::LANGUAGE_NOT_SPECIFIED, ); $this->nodes[] = $this->drupalCreateNode($info); } diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php index 7d1a463..cbe0dbd 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchNumbersTest.php @@ -7,6 +7,8 @@ namespace Drupal\search\Tests; +use Drupal\Core\Language\Language; + /** * Tests that numbers can be searched. */ @@ -51,9 +53,9 @@ function setUp() { foreach ($this->numbers as $doc => $num) { $info = array( - 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $num))), + 'body' => array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => $num))), 'type' => 'page', - 'language' => LANGUAGE_NOT_SPECIFIED, + 'language' => Language::LANGUAGE_NOT_SPECIFIED, 'title' => $doc . ' number', ); $this->nodes[$doc] = $this->drupalCreateNode($info); diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php index a57e483..dfd1675 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php @@ -7,6 +7,8 @@ namespace Drupal\search\Tests; +use Drupal\Core\Language\Language; + class SearchRankingTest extends SearchTestBase { /** @@ -36,7 +38,7 @@ function testRankings() { $settings = array( 'type' => 'page', 'title' => 'Drupal rocks', - 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => "Drupal's search rocks"))), + 'body' => array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => "Drupal's search rocks"))), ); foreach (array(0, 1) as $num) { if ($num == 1) { @@ -46,7 +48,7 @@ function testRankings() { $settings[$node_rank] = 1; break; case 'relevance': - $settings['body'][LANGUAGE_NOT_SPECIFIED][0]['value'] .= " really rocks"; + $settings['body'][Language::LANGUAGE_NOT_SPECIFIED][0]['value'] .= " really rocks"; break; case 'recent': $settings['created'] = REQUEST_TIME + 3600; @@ -70,7 +72,7 @@ function testRankings() { // Add a comment to one of the nodes. $edit = array(); $edit['subject'] = 'my comment title'; - $edit['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]'] = 'some random comment'; + $edit['comment_body[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][value]'] = 'some random comment'; $this->drupalGet('comment/reply/' . $nodes['comments'][1]->nid); $this->drupalPost(NULL, $edit, t('Preview')); $this->drupalPost(NULL, $edit, t('Save')); @@ -129,13 +131,13 @@ function testHTMLRankings() { foreach ($shuffled_tags as $tag) { switch ($tag) { case 'a': - $settings['body'] = array(LANGUAGE_NOT_SPECIFIED => array(array('value' => l('Drupal Rocks', 'node'), 'format' => 'full_html'))); + $settings['body'] = array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => l('Drupal Rocks', 'node'), 'format' => 'full_html'))); break; case 'notag': - $settings['body'] = array(LANGUAGE_NOT_SPECIFIED => array(array('value' => 'Drupal Rocks'))); + $settings['body'] = array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => 'Drupal Rocks'))); break; default: - $settings['body'] = array(LANGUAGE_NOT_SPECIFIED => array(array('value' => "<$tag>Drupal Rocks", 'format' => 'full_html'))); + $settings['body'] = array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => "<$tag>Drupal Rocks", 'format' => 'full_html'))); break; } $nodes[$tag] = $this->drupalCreateNode($settings); @@ -168,7 +170,7 @@ function testHTMLRankings() { // Test tags with the same weight against the sorted tags. $unsorted_tags = array('u', 'b', 'i', 'strong', 'em'); foreach ($unsorted_tags as $tag) { - $settings['body'] = array(LANGUAGE_NOT_SPECIFIED => array(array('value' => "<$tag>Drupal Rocks", 'format' => 'full_html'))); + $settings['body'] = array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => "<$tag>Drupal Rocks", 'format' => 'full_html'))); $node = $this->drupalCreateNode($settings); // Update the search index. @@ -204,7 +206,7 @@ function testDoubleRankings() { $settings = array( 'type' => 'page', 'title' => 'Drupal rocks', - 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => "Drupal's search rocks"))), + 'body' => array(Language::LANGUAGE_NOT_SPECIFIED => array(array('value' => "Drupal's search rocks"))), 'sticky' => 1, ); diff --git a/core/modules/search/search.pages.inc b/core/modules/search/search.pages.inc index b6a1930..81924fe 100644 --- a/core/modules/search/search.pages.inc +++ b/core/modules/search/search.pages.inc @@ -5,6 +5,8 @@ * User page callbacks for the search module. */ +use Drupal\Core\Language\Language; + /** * Menu callback; presents the search form and/or search results. * @@ -104,12 +106,12 @@ function template_preprocess_search_results(&$variables) { * @see search-result.tpl.php */ function template_preprocess_search_result(&$variables) { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); $result = $variables['result']; $variables['url'] = check_url($result['link']); $variables['title'] = check_plain($result['title']); - if (isset($result['language']) && $result['language'] != $language_interface->langcode && $result['language'] != LANGUAGE_NOT_SPECIFIED) { + if (isset($result['language']) && $result['language'] != $language_interface->langcode && $result['language'] != Language::LANGUAGE_NOT_SPECIFIED) { $variables['title_attributes']['lang'] = $result['language']; $variables['content_attributes']['lang'] = $result['language']; } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index ec66409..ed51bc2 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -11,6 +11,7 @@ use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\Database\ConnectionNotDefinedException; use Drupal\Core\DrupalKernel; +use Drupal\Core\Language\Language; use ReflectionMethod; use ReflectionObject; use Exception; @@ -804,7 +805,7 @@ protected function changeDatabasePrefix() { */ protected function prepareEnvironment() { global $user, $conf; - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); // When running the test runner within a test, back up the original database // prefix and re-set the new/nested prefix in drupal_valid_test_ua(). diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 6e41540..686006e 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -11,6 +11,7 @@ use Drupal\Core\DrupalKernel; use Drupal\Core\Database\Database; use Drupal\Core\Database\ConnectionNotDefinedException; +use Drupal\Core\Language\Language; use PDO; use stdClass; use DOMDocument; @@ -200,7 +201,7 @@ function drupalGetNodeByTitle($title, $reset = FALSE) { * The following defaults are provided: * - body: Random string using the default filter format: * @code - * $settings['body'][LANGUAGE_NOT_SPECIFIED][0] = array( + * $settings['body'][Language::LANGUAGE_NOT_SPECIFIED][0] = array( * 'value' => $this->randomName(32), * 'format' => filter_default_format(), * ); @@ -213,10 +214,10 @@ function drupalGetNodeByTitle($title, $reset = FALSE) { * - status: NODE_PUBLISHED. * - sticky: NODE_NOT_STICKY. * - type: 'page'. - * - langcode: LANGUAGE_NOT_SPECIFIED. (If a 'langcode' key is provided in + * - langcode: Language::LANGUAGE_NOT_SPECIFIED. (If a 'langcode' key is provided in * the array, this language code will also be used for a randomly * generated body field for that language, and the body for - * LANGUAGE_NOT_SPECIFIED will remain empty.) + * Language::LANGUAGE_NOT_SPECIFIED will remain empty.) * - uid: The currently logged in user, or the user running test. * - revision: 1. (Backwards-compatible binary flag indicating whether a * new revision should be created; use 1 to specify a new revision.) @@ -227,7 +228,7 @@ function drupalGetNodeByTitle($title, $reset = FALSE) { protected function drupalCreateNode(array $settings = array()) { // Populate defaults array. $settings += array( - 'body' => array(LANGUAGE_NOT_SPECIFIED => array(array())), + 'body' => array(Language::LANGUAGE_NOT_SPECIFIED => array(array())), 'title' => $this->randomName(8), 'changed' => REQUEST_TIME, 'promote' => NODE_NOT_PROMOTED, @@ -236,7 +237,7 @@ protected function drupalCreateNode(array $settings = array()) { 'status' => NODE_PUBLISHED, 'sticky' => NODE_NOT_STICKY, 'type' => 'page', - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, ); // Add in comment settings for nodes. diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php index 0b5909d..27ae8b4 100644 --- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php +++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsTokenReplaceTest.php @@ -7,6 +7,8 @@ namespace Drupal\statistics\Tests; +use Drupal\Core\Language\Language; + /** * Tests statistics token replacement in strings. */ @@ -23,7 +25,7 @@ public static function getInfo() { * Creates a node, then tests the statistics tokens generated from it. */ function testStatisticsTokenReplacement() { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); // Create user and node. $user = $this->drupalCreateUser(array('create page content')); diff --git a/core/modules/system/language.api.php b/core/modules/system/language.api.php index eb8bc3c..8922b0f 100644 --- a/core/modules/system/language.api.php +++ b/core/modules/system/language.api.php @@ -26,7 +26,7 @@ function hook_language_init() { global $conf; - switch (language(LANGUAGE_TYPE_INTERFACE)->langcode) { + switch (language(\Drupal\Core\Language\Language::LANGUAGE_TYPE_INTERFACE)->langcode) { case 'it': $conf['system.site']['name'] = 'Il mio sito Drupal'; break; @@ -52,9 +52,9 @@ function hook_language_init() { * The current path. */ function hook_language_switch_links_alter(array &$links, $type, $path) { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(\Drupal\Core\Language\Language::LANGUAGE_TYPE_INTERFACE); - if ($type == LANGUAGE_TYPE_CONTENT && isset($links[$language_interface->langcode])) { + if ($type == \Drupal\Core\Language\Language::LANGUAGE_TYPE_CONTENT && isset($links[$language_interface->langcode])) { foreach ($links[$language_interface->langcode] as $link) { $link['attributes']['class'][] = 'active-language'; } @@ -213,7 +213,7 @@ function hook_language_fallback_candidates_alter(array &$fallback_candidates) { * Here is a code snippet to transliterate some text: * @code * // Use the current default interface language. - * $langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode; + * $langcode = language(\Drupal\Core\Language\Language::LANGUAGE_TYPE_INTERFACE)->langcode; * // Instantiate the transliteration class. * $trans = drupal_container()->get('transliteration'); * // Use this to transliterate some text. diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php index c40fbe8..b2a89b5 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Common; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -134,7 +135,7 @@ function testRenderInlineFullPage() { $settings = array( 'type' => 'page', 'body' => array( - LANGUAGE_NOT_SPECIFIED => array( + Language::LANGUAGE_NOT_SPECIFIED => array( array( 'value' => t('This tests the inline CSS!') . "", 'format' => $php_format_id, @@ -209,8 +210,8 @@ function testRenderOverride() { */ function testAlter() { // Switch the language to a right to left language and add system.base.css. - $language_interface = language(LANGUAGE_TYPE_INTERFACE); - $language_interface->direction = LANGUAGE_RTL; + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); + $language_interface->direction = Language::LANGUAGE_RTL; $path = drupal_get_path('module', 'system'); drupal_add_css($path . '/system.base.css'); @@ -219,7 +220,7 @@ function testAlter() { $this->assert(strpos($styles, $path . '/system.base-rtl.css') !== FALSE, 'CSS is alterable as right to left overrides are added.'); // Change the language back to left to right. - $language_interface->direction = LANGUAGE_LTR; + $language_interface->direction = Language::LANGUAGE_LTR; } /** diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php index 1f2575c..76e7c30 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Common; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -90,7 +91,7 @@ function testAdminDefinedFormatDate() { function testFormatDate() { global $user; - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); $timestamp = strtotime('2007-03-26T00:00:00+00:00'); $this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', 'Test all parameters.'); @@ -107,7 +108,7 @@ function testFormatDate() { 'predefined_langcode' => 'custom', 'langcode' => self::LANGCODE, 'name' => self::LANGCODE, - 'direction' => LANGUAGE_LTR, + 'direction' => Language::LANGUAGE_LTR, ); $this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language')); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php index 91c292c..4146440 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Entity; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -77,7 +78,7 @@ public function testCommentHooks() { 'comment' => 2, 'promote' => 0, 'sticky' => 0, - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, 'created' => REQUEST_TIME, 'changed' => REQUEST_TIME, )); @@ -93,7 +94,7 @@ public function testCommentHooks() { 'created' => REQUEST_TIME, 'changed' => REQUEST_TIME, 'status' => 1, - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, )); $_SESSION['entity_crud_hook_test'] = array(); @@ -204,7 +205,7 @@ public function testNodeHooks() { 'comment' => 2, 'promote' => 0, 'sticky' => 0, - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, 'created' => REQUEST_TIME, 'changed' => REQUEST_TIME, )); @@ -255,7 +256,7 @@ public function testTaxonomyTermHooks() { $vocabulary = entity_create('taxonomy_vocabulary', array( 'name' => 'Test vocabulary', 'vid' => 'test', - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, 'description' => NULL, 'module' => 'entity_crud_hook_test', )); @@ -264,7 +265,7 @@ public function testTaxonomyTermHooks() { $term = entity_create('taxonomy_term', array( 'vid' => $vocabulary->id(), 'name' => 'Test term', - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, 'description' => NULL, 'format' => 1, )); @@ -315,7 +316,7 @@ public function testTaxonomyVocabularyHooks() { $vocabulary = entity_create('taxonomy_vocabulary', array( 'name' => 'Test vocabulary', 'vid' => 'test', - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, 'description' => NULL, 'module' => 'entity_crud_hook_test', )); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php index 3dd810c..9fa1d6e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php @@ -10,6 +10,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\Field\FieldInterface; use Drupal\Core\Entity\Field\FieldItemInterface; +use Drupal\Core\Language\Language; use Drupal\Core\TypedData\TypedDataInterface; use Drupal\simpletest\WebTestBase; @@ -143,8 +144,8 @@ public function testReadWrite() { $this->assertFalse(isset($entity->name->value), 'Name is not set.'); // Access the language field. - $this->assertEqual(LANGUAGE_NOT_SPECIFIED, $entity->langcode->value, 'Language code can be read.'); - $this->assertEqual(language_load(LANGUAGE_NOT_SPECIFIED), $entity->langcode->language, 'Language object can be read.'); + $this->assertEqual(Language::LANGUAGE_NOT_SPECIFIED, $entity->langcode->value, 'Language code can be read.'); + $this->assertEqual(language_load(Language::LANGUAGE_NOT_SPECIFIED), $entity->langcode->language, 'Language object can be read.'); // Change the language by code. $entity->langcode->value = language_default()->langcode; @@ -152,7 +153,7 @@ public function testReadWrite() { $this->assertEqual(language_default(), $entity->langcode->language, 'Language object can be read.'); // Revert language by code then try setting it by language object. - $entity->langcode->value = LANGUAGE_NOT_SPECIFIED; + $entity->langcode->value = Language::LANGUAGE_NOT_SPECIFIED; $entity->langcode->language = language_default(); $this->assertEqual(language_default()->langcode, $entity->langcode->value, 'Language code can be read.'); $this->assertEqual(language_default(), $entity->langcode->language, 'Language object can be read.'); @@ -271,8 +272,8 @@ public function testSave() { // Access the name field. $this->assertEqual(1, $entity->id->value, 'ID value can be read.'); $this->assertTrue(is_string($entity->uuid->value), 'UUID value can be read.'); - $this->assertEqual(LANGUAGE_NOT_SPECIFIED, $entity->langcode->value, 'Language code can be read.'); - $this->assertEqual(language_load(LANGUAGE_NOT_SPECIFIED), $entity->langcode->language, 'Language object can be read.'); + $this->assertEqual(Language::LANGUAGE_NOT_SPECIFIED, $entity->langcode->value, 'Language code can be read.'); + $this->assertEqual(language_load(Language::LANGUAGE_NOT_SPECIFIED), $entity->langcode->language, 'Language object can be read.'); $this->assertEqual($this->entity_user->uid, $entity->user_id->value, 'User id can be read.'); $this->assertEqual($this->entity_user->name, $entity->user_id->entity->name, 'User name can be read.'); $this->assertEqual($this->entity_field_text, $entity->field_test_text->value, 'Text field can be read.'); @@ -372,7 +373,7 @@ public function testDataStructureInterfaces() { // the user name and other user entity strings as well. $target_strings = array( $entity->uuid->value, - LANGUAGE_NOT_SPECIFIED, + Language::LANGUAGE_NOT_SPECIFIED, $this->entity_name, $this->entity_field_text, // Field format. diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFormTest.php index 278e151..9718f55 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFormTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Entity; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -39,7 +40,7 @@ function setUp() { * Tests basic form CRUD functionality. */ function testFormCRUD() { - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $name1 = $this->randomName(8); $name2 = $this->randomName(10); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php index 1882e6f..b947db4 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Entity; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -84,11 +85,11 @@ function setUp() { $bundles[] = $bundle; } // Each unit is a list of field name, langcode and a column-value array. - $units[] = array($figures, LANGUAGE_NOT_SPECIFIED, array( + $units[] = array($figures, Language::LANGUAGE_NOT_SPECIFIED, array( 'color' => 'red', 'shape' => 'triangle', )); - $units[] = array($figures, LANGUAGE_NOT_SPECIFIED, array( + $units[] = array($figures, Language::LANGUAGE_NOT_SPECIFIED, array( 'color' => 'blue', 'shape' => 'circle', )); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php index d360229..dfa9f7d 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php @@ -60,9 +60,9 @@ function testEntityFormLanguage() { $web_user = $this->drupalCreateUser(array('create page content', 'edit own page content', 'administer content types')); $this->drupalLogin($web_user); - // Create a node with language LANGUAGE_NOT_SPECIFIED. + // Create a node with language Language::LANGUAGE_NOT_SPECIFIED. $edit = array(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit["title"] = $this->randomName(8); $edit["body[$langcode][0][value]"] = $this->randomName(16); @@ -86,14 +86,14 @@ function testEntityFormLanguage() { // Enable language selector. $this->drupalGet('admin/structure/types/manage/page'); - $edit = array('language_configuration[language_hidden]' => FALSE, 'language_configuration[langcode]' => LANGUAGE_NOT_SPECIFIED); + $edit = array('language_configuration[language_hidden]' => FALSE, 'language_configuration[langcode]' => Language::LANGUAGE_NOT_SPECIFIED); $this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type')); $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), 'Basic page content type has been updated.'); // Create a node with language. $edit = array(); $langcode = $this->langcodes[0]; - $field_langcode = LANGUAGE_NOT_SPECIFIED; + $field_langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit["title"] = $this->randomName(8); $edit["body[$field_langcode][0][value]"] = $this->randomName(16); $edit['langcode'] = $langcode; diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php index 370622d..8f24a02 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php @@ -78,13 +78,13 @@ function testEntityLanguageMethods() { 'name' => 'test', 'user_id' => $GLOBALS['user']->uid, )); - $this->assertEqual($entity->language()->langcode, LANGUAGE_NOT_SPECIFIED, 'Entity language not specified.'); + $this->assertEqual($entity->language()->langcode, Language::LANGUAGE_NOT_SPECIFIED, 'Entity language not specified.'); $this->assertFalse($entity->getTranslationLanguages(FALSE), 'No translations are available'); // Set the value in default language. $entity->set($this->field_name, array(0 => array('value' => 'default value'))); // Get the value. - $this->assertEqual($entity->getTranslation(LANGUAGE_DEFAULT)->get($this->field_name)->value, 'default value', 'Untranslated value retrieved.'); + $this->assertEqual($entity->getTranslation(Language::LANGUAGE_DEFAULT)->get($this->field_name)->value, 'default value', 'Untranslated value retrieved.'); // Set the value in a certain language. As the entity is not // language-specific it should use the default language and so ignore the @@ -184,9 +184,9 @@ function testMultilingualProperties() { $entity = entity_create('entity_test', array('name' => $name, 'user_id' => $uid)); $entity->save(); $entity = entity_test_load($entity->id()); - $this->assertEqual($entity->language()->langcode, LANGUAGE_NOT_SPECIFIED, 'Entity created as language neutral.'); - $this->assertEqual($name, $entity->getTranslation(LANGUAGE_DEFAULT)->get('name')->value, 'The entity name has been correctly stored as language neutral.'); - $this->assertEqual($uid, $entity->getTranslation(LANGUAGE_DEFAULT)->get('user_id')->value, 'The entity author has been correctly stored as language neutral.'); + $this->assertEqual($entity->language()->langcode, Language::LANGUAGE_NOT_SPECIFIED, 'Entity created as language neutral.'); + $this->assertEqual($name, $entity->getTranslation(Language::LANGUAGE_DEFAULT)->get('name')->value, 'The entity name has been correctly stored as language neutral.'); + $this->assertEqual($uid, $entity->getTranslation(Language::LANGUAGE_DEFAULT)->get('user_id')->value, 'The entity author has been correctly stored as language neutral.'); // As fields, translatable properties should ignore the given langcode and // use neutral language if the entity is not translatable. $this->assertEqual($name, $entity->getTranslation($langcode)->get('name')->value, 'The entity name defaults to neutral language.'); @@ -203,9 +203,9 @@ function testMultilingualProperties() { $this->assertEqual($name, $entity->getTranslation($langcode)->get('name')->value, 'The entity name has been correctly stored as a language-aware property.'); $this->assertEqual($uid, $entity->getTranslation($langcode)->get('user_id')->value, 'The entity author has been correctly stored as a language-aware property.'); // Translatable properties on a translatable entity should use default - // language if LANGUAGE_NOT_SPECIFIED is passed. - $this->assertEqual($name, $entity->getTranslation(LANGUAGE_NOT_SPECIFIED)->get('name')->value, 'The entity name defaults to the default language.'); - $this->assertEqual($uid, $entity->getTranslation(LANGUAGE_NOT_SPECIFIED)->get('user_id')->value, 'The entity author defaults to the default language.'); + // language if Language::LANGUAGE_NOT_SPECIFIED is passed. + $this->assertEqual($name, $entity->getTranslation(Language::LANGUAGE_NOT_SPECIFIED)->get('name')->value, 'The entity name defaults to the default language.'); + $this->assertEqual($uid, $entity->getTranslation(Language::LANGUAGE_NOT_SPECIFIED)->get('user_id')->value, 'The entity author defaults to the default language.'); $this->assertEqual($name, $entity->get('name')->value, 'The entity name can be retrieved without specifying a language.'); $this->assertEqual($uid, $entity->get('user_id')->value, 'The entity author can be retrieved without specifying a language.'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php index f5c589b..a19c0f7 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Form/LanguageSelectElementTest.php @@ -49,10 +49,10 @@ function testLanguageSelectElementOptions() { $this->drupalGet('form-test/language_select'); // Check that the language fields were rendered on the page. - $ids = array('edit-languages-all' => LANGUAGE_ALL, - 'edit-languages-configurable' => LANGUAGE_CONFIGURABLE, - 'edit-languages-locked' => LANGUAGE_LOCKED, - 'edit-languages-config-and-locked' => LANGUAGE_CONFIGURABLE | LANGUAGE_LOCKED); + $ids = array('edit-languages-all' => Language::LANGUAGE_ALL, + 'edit-languages-configurable' => Language::LANGUAGE_CONFIGURABLE, + 'edit-languages-locked' => Language::LANGUAGE_LOCKED, + 'edit-languages-config-and-locked' => Language::LANGUAGE_CONFIGURABLE | Language::LANGUAGE_LOCKED); foreach ($ids as $id => $flags) { $this->assertField($id, format_string('The @id field was found on the page.', array('@id' => $id))); $options = array(); @@ -90,7 +90,7 @@ function testHiddenLanguageSelectElement() { $values = drupal_json_decode($this->drupalGetContent()); $this->assertEqual($values['languages_all'], 'xx'); $this->assertEqual($values['languages_configurable'], 'en'); - $this->assertEqual($values['languages_locked'], LANGUAGE_NOT_SPECIFIED); + $this->assertEqual($values['languages_locked'], Language::LANGUAGE_NOT_SPECIFIED); $this->assertEqual($values['languages_config_and_locked'], 'dummy_value'); $this->assertEqual($values['language_custom_options'], 'opt2'); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php b/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php index 92be196..a742ea3 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php @@ -49,7 +49,7 @@ function setUp() { * Assert that the pluggable mail system is functional. */ public function testPluggableFramework() { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); // Use MailTestCase for sending a message. $message = drupal_mail('simpletest', 'mail_test', 'testing@example.com', $language_interface->langcode); @@ -64,7 +64,7 @@ public function testPluggableFramework() { * @see simpletest_mail_alter() */ public function testCancelMessage() { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); // Reset the class variable holding a copy of the last sent message. self::$sent_message = NULL; diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php index a77218b..73cfdfd 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php @@ -7,6 +7,8 @@ namespace Drupal\system\Tests\Menu; +use Drupal\Core\Language\Language; + /** * Menu breadcrumbs related tests. */ @@ -59,7 +61,7 @@ function testBreadCrumbs() { $admin = $home + array('admin' => t('Administration')); $config = $admin + array('admin/config' => t('Configuration')); $type = 'article'; - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Verify breadcrumbs for default local tasks. $expected = array( diff --git a/core/modules/system/lib/Drupal/system/Tests/Path/AliasTest.php b/core/modules/system/lib/Drupal/system/Tests/Path/AliasTest.php index 21a129a..954965f 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Path/AliasTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Path/AliasTest.php @@ -158,6 +158,6 @@ function testLookupPath() { // Test the situation where the alias and language are the same, but // the source differs. The newer alias record should be returned. $pathObject->save('user/2', 'bar'); - $this->assertEqual($aliasManager->getSystemPath('bar'), 'user/2', 'Newer alias record is returned when comparing two LANGUAGE_NOT_SPECIFIED paths with the same alias.'); + $this->assertEqual($aliasManager->getSystemPath('bar'), 'user/2', 'Newer alias record is returned when comparing two timplunkett: cool!LANGUAGE_NOT_SPECIFIED paths with the same alias.'); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Serialization/EntitySerializationTest.php b/core/modules/system/lib/Drupal/system/Tests/Serialization/EntitySerializationTest.php index f34cd9d..571b141 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Serialization/EntitySerializationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Serialization/EntitySerializationTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Serialization; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; use Symfony\Component\Serializer\Serializer; use Drupal\Core\Serialization\JsonEncoder; @@ -83,7 +84,7 @@ public function testNormalize() { array('value' => $this->entity->uuid()), ), 'langcode' => array( - array('value' => LANGUAGE_NOT_SPECIFIED), + array('value' => Language::LANGUAGE_NOT_SPECIFIED), ), 'default_langcode' => array(NULL), 'name' => array( diff --git a/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php b/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php index ff16e61..c61b63a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\System; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -51,7 +52,7 @@ function testLocalizeDateFormats() { $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); // Set language negotiation. - $language_type = LANGUAGE_TYPE_INTERFACE; + $language_type = Language::LANGUAGE_TYPE_INTERFACE; $edit = array( "{$language_type}[enabled][language-url]" => TRUE, ); diff --git a/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php b/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php index 7e89cf7..524e449 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\System; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; class PageTitleFilteringTest extends WebTestBase { @@ -69,7 +70,7 @@ function testTitleTags() { drupal_set_title($title, PASS_THROUGH); $this->assertTrue(strpos(drupal_get_title(), '') !== FALSE, 'Tags in title are not converted to entities when $output is PASS_THROUGH.'); // Generate node content. - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit = array( "title" => '!SimpleTest! ' . $title . $this->randomName(20), "body[$langcode][0][value]" => '!SimpleTest! test body' . $this->randomName(200), diff --git a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php index 3859041..1ccce38 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php @@ -30,7 +30,7 @@ function testTokenReplacement() { $node = $this->drupalCreateNode(array('uid' => $account->uid)); $node->title = 'Blinking Text'; global $user; - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); $source = '[node:title]'; // Title of the node we passed in $source .= '[node:author:name]'; // Node author's name @@ -75,7 +75,7 @@ function testTokenReplacement() { * Test whether token-replacement works in various contexts. */ function testSystemTokenRecognition() { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); // Generate prefixes and suffixes for the token context. $tests = array( @@ -104,7 +104,7 @@ function testSystemTokenRecognition() { * Tests the generation of all system site information tokens. */ function testSystemSiteTokenReplacement() { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); $url_options = array( 'absolute' => TRUE, 'language' => $language_interface, @@ -147,7 +147,7 @@ function testSystemSiteTokenReplacement() { * Tests the generation of all system date tokens. */ function testSystemDateTokenReplacement() { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); // Set time to one hour before request. $date = REQUEST_TIME - 3600; diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php index 27f3e6a..55100bf 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Theme; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -102,7 +103,7 @@ function setUp() { 'title' => $this->xss_label, 'type' => 'article', 'promote' => NODE_PROMOTED, - 'field_tags' => array(LANGUAGE_NOT_SPECIFIED => array(array('tid' => $this->term->tid))), + 'field_tags' => array(Language::LANGUAGE_NOT_SPECIFIED => array(array('tid' => $this->term->tid))), )); // Create a test comment on the test node. @@ -111,7 +112,7 @@ function setUp() { 'node_type' => $this->node->type, 'status' => COMMENT_PUBLISHED, 'subject' => $this->xss_label, - 'comment_body' => array(LANGUAGE_NOT_SPECIFIED => array($this->randomName())), + 'comment_body' => array(Language::LANGUAGE_NOT_SPECIFIED => array($this->randomName())), )); comment_save($this->comment); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php index 7c9b9a5..c9254af 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php @@ -13,6 +13,8 @@ * Loads a filled installation of Drupal 7 with language data and runs the * upgrade process on it. */ +use Drupal\Core\Language\Language; + class LanguageUpgradePathTest extends UpgradePathTestBase { public static function getInfo() { return array( @@ -40,7 +42,7 @@ public function testLanguageUpgrade() { // Ensure Catalan was properly upgraded to be the new default language. $this->assertTrue(language_default()->langcode == 'ca', 'Catalan is the default language'); - $languages = language_list(LANGUAGE_ALL); + $languages = language_list(Language::LANGUAGE_ALL); foreach ($languages as $language) { $this->assertTrue($language->default == ($language->langcode == 'ca'), format_string('@language default property properly set', array('@language' => $language->name))); } @@ -66,7 +68,7 @@ public function testLanguageUpgrade() { $translation_source_nid = 52; $translation_nid = 53; // Check directly for the $node->langcode property. - $this->assertEqual(node_load($language_none_nid)->langcode, LANGUAGE_NOT_SPECIFIED, "'language' property was renamed to 'langcode' for LANGUAGE_NOT_SPECIFIED node."); + $this->assertEqual(node_load($language_none_nid)->langcode, Language::LANGUAGE_NOT_SPECIFIED, "'language' property was renamed to 'langcode' for Language::LANGUAGE_NOT_SPECIFIED node."); $this->assertEqual(node_load($spanish_nid)->langcode, 'ca', "'language' property was renamed to 'langcode' for Catalan node."); // Check that the translation table works correctly. $this->drupalGet("node/$translation_source_nid/translate"); @@ -95,9 +97,9 @@ public function testLanguageUpgrade() { $this->assertEqual($term->langcode, 'ca'); // A langcode property was added to files. Check that existing files got - // assigned LANGUAGE_NOT_SPECIFIED. + // assigned Language::LANGUAGE_NOT_SPECIFIED. $file = db_query('SELECT * FROM {file_managed} WHERE fid = :fid', array(':fid' => 1))->fetchObject(); - $this->assertEqual($file->langcode, LANGUAGE_NOT_SPECIFIED); + $this->assertEqual($file->langcode, Language::LANGUAGE_NOT_SPECIFIED); // Check if language negotiation weights were renamed properly. This is a // reproduction of the previous weights from the dump. diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php index 04070c9..40896d8 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php @@ -7,6 +7,8 @@ namespace Drupal\system\Tests\Upgrade; +use Drupal\Core\Language\Language; + /** * Tests upgrading a filled database with user picture data. * @@ -44,7 +46,7 @@ public function testUserPictureUpgrade() { $this->assertIdentical($instance['settings']['default_image'], $file->id(), 'Default user picture has been migrated.'); $this->assertEqual($file->uri, 'public://user_pictures_dir/druplicon.png', 'File id matches the uri expected.'); $this->assertEqual($file->filename, 'druplicon.png'); - $this->assertEqual($file->langcode, LANGUAGE_NOT_SPECIFIED); + $this->assertEqual($file->langcode, Language::LANGUAGE_NOT_SPECIFIED); $this->assertEqual($file->filemime, 'image/png'); $this->assertFalse(empty($file->uuid)); @@ -67,7 +69,7 @@ public function testUserPictureUpgrade() { // Check the user picture and file usage record. $user = user_load(1); - $file = file_load($user->user_picture[LANGUAGE_NOT_SPECIFIED][0]['fid']); + $file = file_load($user->user_picture[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); $this->assertEqual('public://user_pictures_dir/faked_image.png', $file->uri); $usage = file_usage()->listUsage($file); $this->assertEqual(1, $usage['file']['user'][1]); diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index 07a5638..3604bfe 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -2000,7 +2000,7 @@ function hook_custom_theme() { */ function hook_watchdog(array $log_entry) { global $base_url; - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(\Drupal\Core\Language\Language::LANGUAGE_TYPE_INTERFACE); $severity_list = array( WATCHDOG_EMERGENCY => t('Emergency'), diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 8c7d72a..74494d8 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1,6 +1,7 @@ TRUE, - '#default_value' => LANGUAGE_NOT_SPECIFIED, + '#default_value' => Language::LANGUAGE_NOT_SPECIFIED, ); $types['weight'] = array( '#input' => TRUE, diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestAccessController.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestAccessController.php index c928587..8e257c5 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestAccessController.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestAccessController.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityAccessControllerInterface; +use Drupal\Core\Language\Language; use Drupal\user\Plugin\Core\Entity\User; /** @@ -19,8 +20,8 @@ class EntityTestAccessController implements EntityAccessControllerInterface { /** * Implements EntityAccessControllerInterface::viewAccess(). */ - public function viewAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAULT, User $account = NULL) { - if ($langcode != LANGUAGE_DEFAULT) { + public function viewAccess(EntityInterface $entity, $langcode = Language::LANGUAGE_DEFAULT, User $account = NULL) { + if ($langcode != Language::LANGUAGE_DEFAULT) { return user_access('view test entity translations', $account); } return user_access('view test entity', $account); @@ -29,21 +30,21 @@ public function viewAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAULT /** * Implements EntityAccessControllerInterface::createAccess(). */ - public function createAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAULT, User $account = NULL) { + public function createAccess(EntityInterface $entity, $langcode = Language::LANGUAGE_DEFAULT, User $account = NULL) { return TRUE; } /** * Implements EntityAccessControllerInterface::updateAccess(). */ - public function updateAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAULT, User $account = NULL) { + public function updateAccess(EntityInterface $entity, $langcode = Language::LANGUAGE_DEFAULT, User $account = NULL) { return TRUE; } /** * Implements EntityAccessControllerInterface::deleteAccess(). */ - public function deleteAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAULT, User $account = NULL) { + public function deleteAccess(EntityInterface $entity, $langcode = Language::LANGUAGE_DEFAULT, User $account = NULL) { return TRUE; } diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php index a65f06f..6cf4a18 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php @@ -8,6 +8,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityFormControllerNG; +use Drupal\Core\Language\Language; /** * Form controller for the test entity edit forms. @@ -47,7 +48,7 @@ public function form(array $form, array &$form_state, EntityInterface $entity) { '#title' => t('Language'), '#type' => 'language_select', '#default_value' => $entity->language()->langcode, - '#languages' => LANGUAGE_ALL, + '#languages' => Language::LANGUAGE_ALL, ); return $form; diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestStorageController.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestStorageController.php index e3b45fa..0ccb754 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestStorageController.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestStorageController.php @@ -7,6 +7,7 @@ namespace Drupal\entity_test; +use Drupal\Core\Language\Language; use PDO; use Drupal\Core\Entity\Query\QueryInterface; use Drupal\Core\Entity\EntityInterface; @@ -76,8 +77,8 @@ protected function attachPropertyData(&$queried_entities, $load_revision = FALSE foreach ($data as $values) { $id = $values['id']; // Field values in default language are stored with - // LANGUAGE_DEFAULT as key. - $langcode = empty($values['default_langcode']) ? $values['langcode'] : LANGUAGE_DEFAULT; + // Language::LANGUAGE_DEFAULT as key. + $langcode = empty($values['default_langcode']) ? $values['langcode'] : Language::LANGUAGE_DEFAULT; $queried_entities[$id]->name[$langcode][0]['value'] = $values['name']; $queried_entities[$id]->user_id[$langcode][0]['value'] = $values['user_id']; diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php index 9b4d368..4bf4780 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php @@ -10,6 +10,7 @@ use Drupal\Core\Entity\EntityNG; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; +use Drupal\Core\Language\Language; /** * Defines the test entity class. @@ -91,7 +92,7 @@ public function __construct(array $values, $entity_type) { /** * Overrides Drupal\entity\Entity::label(). */ - public function label($langcode = LANGUAGE_DEFAULT) { + public function label($langcode = Language::LANGUAGE_DEFAULT) { return $this->getTranslation($langcode)->name->value; } diff --git a/core/modules/system/tests/modules/form_test/form_test.module b/core/modules/system/tests/modules/form_test/form_test.module index 1801809..87fa162 100644 --- a/core/modules/system/tests/modules/form_test/form_test.module +++ b/core/modules/system/tests/modules/form_test/form_test.module @@ -5,6 +5,7 @@ * Helper module for the form API tests. */ +use Drupal\Core\Language\Language; use Drupal\form_test\Callbacks; /** @@ -1275,26 +1276,26 @@ function form_test_language_select() { $form['languages_all'] = array( '#type' => 'language_select', - '#languages' => LANGUAGE_ALL, + '#languages' => Language::LANGUAGE_ALL, '#default_value' => 'xx', ); $form['languages_configurable'] = array( '#type' => 'language_select', - '#languages' => LANGUAGE_CONFIGURABLE, + '#languages' => Language::LANGUAGE_CONFIGURABLE, '#default_value' => 'en', ); $form['languages_locked'] = array( '#type' => 'language_select', - '#languages' => LANGUAGE_LOCKED, + '#languages' => Language::LANGUAGE_LOCKED, ); $form['languages_config_and_locked'] = array( '#type' => 'language_select', - '#languages' => LANGUAGE_CONFIGURABLE | LANGUAGE_LOCKED, + '#languages' => Language::LANGUAGE_CONFIGURABLE | Language::LANGUAGE_LOCKED, '#default_value' => 'dummy_value', ); $form['language_custom_options'] = array( '#type' => 'language_select', - '#languages' => LANGUAGE_CONFIGURABLE | LANGUAGE_LOCKED, + '#languages' => Language::LANGUAGE_CONFIGURABLE | Language::LANGUAGE_LOCKED, '#options' => array('opt1' => 'First option', 'opt2' => 'Second option', 'opt3' => 'Third option'), '#default_value' => 'opt2', ); @@ -2209,7 +2210,7 @@ function form_test_two_instances() { 'uid' => $user->uid, 'name' => (isset($user->name) ? $user->name : ''), 'type' => 'page', - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, )); $node2 = clone($node1); $return['node_form_1'] = entity_get_form($node1); diff --git a/core/modules/system/tests/upgrade/drupal-7.language.database.php b/core/modules/system/tests/upgrade/drupal-7.language.database.php index 5687361..28fcd58 100644 --- a/core/modules/system/tests/upgrade/drupal-7.language.database.php +++ b/core/modules/system/tests/upgrade/drupal-7.language.database.php @@ -422,7 +422,7 @@ // Add sample nodes to test language assignment and translation functionality. // The first node is also used for testing comment language functionality. This -// is a simple node with LANGUAGE_NOT_SPECIFIED as language code. The second +// is a simple node with Language::LANGUAGE_NOT_SPECIFIED as language code. The second // node is a Catalan node (language code 'ca'). The third and fourth node are a // translation set with an English source translation (language code 'en') and // a Chuvash translation (language code 'cv'). @@ -545,7 +545,7 @@ 'vid' => '70', 'uid' => '6', 'title' => 'Node title 50', - 'log' => 'Added a LANGUAGE_NOT_SPECIFIED node to comment on.', + 'log' => 'Added a Language::LANGUAGE_NOT_SPECIFIED node to comment on.', 'timestamp' => '1314997642', 'status' => '1', 'comment' => '2', diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php index 6be04a9..06392a0 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityFormController; +use Drupal\Core\Language\Language; /** * Base for controller for taxonomy term edit forms. @@ -45,7 +46,7 @@ public function form(array $form, array &$form_state, EntityInterface $term) { $form['langcode'] = array( '#type' => 'language_select', '#title' => t('Language'), - '#languages' => LANGUAGE_ALL, + '#languages' => Language::LANGUAGE_ALL, '#default_value' => $term->langcode, '#access' => !is_null($language_configuration['language_hidden']) && !$language_configuration['language_hidden'], ); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php index d00f373..d5c7e4e 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php @@ -7,6 +7,8 @@ namespace Drupal\taxonomy\Tests; +use Drupal\Core\Language\Language; + /** * Test for legacy node bug. */ @@ -33,7 +35,7 @@ function setUp() { */ function testTaxonomyLegacyNode() { // Posts an article with a taxonomy term and a date prior to 1970. - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit = array(); $edit['title'] = $this->randomName(); $edit['date'] = '1969-01-01 00:00:00 -0500'; diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php index 278db90..2c620f0 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php @@ -7,6 +7,8 @@ namespace Drupal\taxonomy\Tests; +use Drupal\Core\Language\Language; + /** * Tests the rendering of term reference fields in RSS feeds. */ @@ -90,7 +92,7 @@ function testTaxonomyRss() { // Post an article. $edit = array(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit["title"] = $this->randomName(); $edit[$this->instance['field_name'] . '[' . $langcode . '][]'] = $term1->tid; $this->drupalPost('node/add/article', $edit, t('Save')); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php index 99258bc..faffe98 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php @@ -7,6 +7,7 @@ namespace Drupal\taxonomy\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; use Drupal\taxonomy\Type\TaxonomyTermReferenceItem; use Drupal\Core\Entity\Field\FieldItemInterface; @@ -37,7 +38,7 @@ public function setUp() { $vocabulary = entity_create('taxonomy_vocabulary', array( 'name' => $this->randomName(), 'vid' => drupal_strtolower($this->randomName()), - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, )); $vocabulary->save(); $field = array( @@ -66,7 +67,7 @@ public function setUp() { $this->term = entity_create('taxonomy_term', array( 'name' => $this->randomName(), 'vid' => $vocabulary->id(), - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, )); $this->term->save(); } @@ -102,7 +103,7 @@ public function testTaxonomyTermReferenceItem() { $term2 = entity_create('taxonomy_term', array( 'name' => $this->randomName(), 'vid' => $this->term->vid, - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, )); $term2->save(); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php index 0317ad6..9ec4b1b 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php @@ -7,6 +7,7 @@ namespace Drupal\taxonomy\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -39,7 +40,7 @@ function createVocabulary() { 'name' => $this->randomName(), 'description' => $this->randomName(), 'vid' => drupal_strtolower($this->randomName()), - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, 'help' => '', 'weight' => mt_rand(0, 10), )); @@ -57,7 +58,7 @@ function createTerm($vocabulary) { // Use the first available text format. 'format' => db_query_range('SELECT format FROM {filter_format}', 0, 1)->fetchField(), 'vid' => $vocabulary->id(), - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, )); taxonomy_term_save($term); return $term; diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php index 25bcc07..7912f6a 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php @@ -7,6 +7,8 @@ namespace Drupal\taxonomy\Tests; +use Drupal\Core\Language\Language; + /** * Tests a taxonomy term reference field that allows multiple vocabularies. */ @@ -84,7 +86,7 @@ function testTaxonomyTermFieldMultipleVocabularies() { $term2 = $this->createTerm($this->vocabulary2); // Submit an entity with both terms. - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $this->drupalGet('test-entity/add/test_bundle'); $this->assertFieldByName("{$this->field_name}[$langcode][]", '', 'Widget is displayed'); $edit = array( diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php index c20acf7..c092cd3 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php @@ -7,6 +7,7 @@ namespace Drupal\taxonomy\Tests; +use Drupal\Core\Language\Language; use Drupal\field\FieldValidationException; /** @@ -75,7 +76,7 @@ function setUp() { */ function testTaxonomyTermFieldValidation() { // Test valid and invalid values with field_attach_validate(). - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $entity = field_test_create_entity(); $term = $this->createTerm($this->vocabulary); $entity->{$this->field_name}[$langcode][0]['tid'] = $term->tid; @@ -107,7 +108,7 @@ function testTaxonomyTermFieldWidgets() { $term = $this->createTerm($this->vocabulary); // Display creation form. - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $this->drupalGet('test-entity/add/test_bundle'); $this->assertFieldByName("{$this->field_name}[$langcode]", '', 'Widget is displayed.'); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php index f9cba0d..fcda98a 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php @@ -7,6 +7,8 @@ namespace Drupal\taxonomy\Tests; +use Drupal\Core\Language\Language; + /** * Tests the hook implementations that maintain the taxonomy index. */ @@ -101,7 +103,7 @@ function testTaxonomyIndex() { // Post an article. $edit = array(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit["title"] = $this->randomName(); $edit["body[$langcode][0][value]"] = $this->randomName(); $edit["{$this->field_name_1}[$langcode][]"] = $term_1->tid; diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php index 93cc8d4..dfb8f18 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php @@ -7,6 +7,8 @@ namespace Drupal\taxonomy\Tests; +use Drupal\Core\Language\Language; + /** * Tests for taxonomy term functions. */ @@ -106,7 +108,7 @@ function testTaxonomyNode() { // Post an article. $edit = array(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit["title"] = $this->randomName(); $edit["body[$langcode][0][value]"] = $this->randomName(); $edit[$this->instance['field_name'] . '[' . $langcode . '][]'] = $term1->tid; @@ -157,7 +159,7 @@ function testNodeTermCreationAndDeletion() { ); $edit = array(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit["title"] = $this->randomName(); $edit["body[$langcode][0][value]"] = $this->randomName(); // Insert the terms in a comma separated list. Vocabulary 1 is a @@ -511,7 +513,7 @@ function testReSavingTags() { // Create a term and a node using it. $term = $this->createTerm($this->vocabulary); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit = array(); $edit["title"] = $this->randomName(8); $edit["body[$langcode][0][value]"] = $this->randomName(16); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php index dd2ed0c..8f0c0d5 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTranslationUITest.php @@ -7,6 +7,7 @@ namespace Drupal\taxonomy\Tests; +use Drupal\Core\Language\Language; use Drupal\translation_entity\Tests\EntityTranslationUITest; /** @@ -62,7 +63,7 @@ protected function setupBundle() { 'name' => $this->bundle, 'description' => $this->randomName(), 'vid' => $this->bundle, - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, 'help' => '', 'weight' => mt_rand(0, 10), )); @@ -112,7 +113,7 @@ function testTranslateLinkVocabularyAdminPage() { 'name' => 'untranslatable_voc', 'description' => $this->randomName(), 'vid' => 'untranslatable_voc', - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, 'help' => '', 'weight' => mt_rand(0, 10), )); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php index ea73152..3ae8c41 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php @@ -7,6 +7,8 @@ namespace Drupal\taxonomy\Tests; +use Drupal\Core\Language\Language; + /** * Test taxonomy token replacement in strings. */ @@ -25,7 +27,7 @@ function setUp() { $this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'bypass node access')); $this->drupalLogin($this->admin_user); $this->vocabulary = $this->createVocabulary(); - $this->langcode = LANGUAGE_NOT_SPECIFIED; + $this->langcode = Language::LANGUAGE_NOT_SPECIFIED; $field = array( 'field_name' => 'taxonomy_' . $this->vocabulary->id(), @@ -62,7 +64,7 @@ function setUp() { * Creates some terms and a node, then tests the tokens generated from them. */ function testTaxonomyTokenReplacement() { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); // Create two taxonomy terms. $term1 = $this->createTerm($this->vocabulary); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php index 67adc3a..f21556b 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php @@ -7,6 +7,7 @@ namespace Drupal\taxonomy\Tests\Views; +use Drupal\Core\Language\Language; use Drupal\views\Tests\ViewTestBase; use Drupal\views\Tests\ViewTestData; @@ -54,8 +55,8 @@ function setUp() { $node = array(); $node['type'] = 'article'; - $node['field_views_testing_tags'][LANGUAGE_NOT_SPECIFIED][]['tid'] = $this->term1->tid; - $node['field_views_testing_tags'][LANGUAGE_NOT_SPECIFIED][]['tid'] = $this->term2->tid; + $node['field_views_testing_tags'][Language::LANGUAGE_NOT_SPECIFIED][]['tid'] = $this->term1->tid; + $node['field_views_testing_tags'][Language::LANGUAGE_NOT_SPECIFIED][]['tid'] = $this->term2->tid; $this->nodes[] = $this->drupalCreateNode($node); $this->nodes[] = $this->drupalCreateNode($node); } @@ -134,7 +135,7 @@ protected function createTerm() { // Use the first available text format. 'format' => db_query_range('SELECT format FROM {filter_format}', 0, 1)->fetchField(), 'vid' => $this->vocabulary->id(), - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, )); $term->save(); return $term; diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php index 6785335..1641d8e 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityFormController; +use Drupal\Core\Language\Language; /** * Base form controller for vocabulary edit forms. @@ -53,7 +54,7 @@ public function form(array $form, array &$form_state, EntityInterface $vocabular $form['langcode'] = array( '#type' => 'language_select', '#title' => t('Vocabulary language'), - '#languages' => LANGUAGE_ALL, + '#languages' => Language::LANGUAGE_ALL, '#default_value' => $vocabulary->langcode, ); if (module_exists('language')) { diff --git a/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php b/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php index 6bf7fe4..8b2181a 100644 --- a/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php +++ b/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php @@ -7,6 +7,7 @@ namespace Drupal\text\Tests; +use Drupal\Core\Language\Language; use Drupal\field\FieldValidationException; use Drupal\simpletest\WebTestBase; @@ -73,7 +74,7 @@ function testTextFieldValidation() { // Test valid and invalid values with field_attach_validate(). $entity = field_test_create_entity(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; for ($i = 0; $i <= $max_length + 2; $i++) { $entity->{$this->field['field_name']}[$langcode][0]['value'] = str_repeat('x', $i); try { @@ -123,7 +124,7 @@ function _testTextfieldWidgets($field_type, $widget_type) { ->setComponent($this->field_name) ->save(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Display creation form. $this->drupalGet('test-entity/add/test_bundle'); @@ -183,7 +184,7 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) { ->setComponent($this->field_name) ->save(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; // Disable all text formats besides the plain text fallback format. $this->drupalLogin($this->admin_user); diff --git a/core/modules/text/lib/Drupal/text/Tests/TextTranslationTest.php b/core/modules/text/lib/Drupal/text/Tests/TextTranslationTest.php index 43340fb..8d7f250 100644 --- a/core/modules/text/lib/Drupal/text/Tests/TextTranslationTest.php +++ b/core/modules/text/lib/Drupal/text/Tests/TextTranslationTest.php @@ -7,6 +7,7 @@ namespace Drupal\text\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -68,7 +69,7 @@ function testTextField() { $this->drupalLogin($this->translator); // Create content. - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $body = $this->randomName(); $edit = array( 'title' => $this->randomName(), @@ -111,7 +112,7 @@ function testTextFieldFormatted() { // Populate the body field: the first item gets the "Full HTML" input // format, the second one "Filtered HTML". $formats = array('full_html', 'filtered_html'); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; foreach ($body as $delta => $value) { $edit = array( "body[$langcode][$delta][value]" => $value, diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module index e543326..f3b2a86 100644 --- a/core/modules/toolbar/toolbar.module +++ b/core/modules/toolbar/toolbar.module @@ -5,6 +5,7 @@ * Administration toolbar for quick access to top level administration items. */ +use Drupal\Core\Language\Language; use Symfony\Component\HttpFoundation\JsonResponse; use Drupal\Core\Template\Attribute; @@ -515,7 +516,7 @@ function toolbar_cache_flush() { */ function _toolbar_get_subtree_hash() { global $user; - $cid = $user->uid . ':' . language(LANGUAGE_TYPE_INTERFACE)->langcode; + $cid = $user->uid . ':' . language(Language::LANGUAGE_TYPE_INTERFACE)->langcode; if ($cache = cache('toolbar')->get($cid)) { $hash = $cache->data; } diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php index 0e7c429..e42c413 100644 --- a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php +++ b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php @@ -7,6 +7,7 @@ namespace Drupal\tracker\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -110,7 +111,7 @@ function testTrackerUser() { )); $comment = array( 'subject' => $this->randomName(), - 'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20), + 'comment_body[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20), ); $this->drupalPost('comment/reply/' . $other_published_my_comment->nid, $comment, t('Save')); @@ -170,7 +171,7 @@ function testTrackerNewComments() { // Add a comment to the page. $comment = array( 'subject' => $this->randomName(), - 'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20), + 'comment_body[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20), ); // The new comment is automatically viewed by the current user. $this->drupalPost('comment/reply/' . $node->nid, $comment, t('Save')); @@ -183,7 +184,7 @@ function testTrackerNewComments() { // Add another comment as other_user. $comment = array( 'subject' => $this->randomName(), - 'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20), + 'comment_body[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20), ); // If the comment is posted in the same second as the last one then Drupal // can't tell the difference, so we wait one second here. @@ -216,7 +217,7 @@ function testTrackerCronIndexing() { $this->drupalLogin($this->other_user); $comment = array( 'subject' => $this->randomName(), - 'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20), + 'comment_body[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20), ); $this->drupalPost('comment/reply/' . $nodes[3]->nid, $comment, t('Save')); diff --git a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php index bc9094d..e4e855d 100644 --- a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php +++ b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php @@ -7,6 +7,7 @@ namespace Drupal\translation\Tests; +use Drupal\Core\Language\Language; use Drupal\node\Plugin\Core\Entity\Node; use Drupal\simpletest\WebTestBase; @@ -56,7 +57,7 @@ function setUp() { $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), 'Basic page content type has been updated.'); // Enable the language switcher block. - $language_type = LANGUAGE_TYPE_INTERFACE; + $language_type = Language::LANGUAGE_TYPE_INTERFACE; $edit = array("blocks[language_$language_type][region]" => 'sidebar_first'); $this->drupalPost('admin/structure/block', $edit, t('Save blocks')); @@ -107,7 +108,7 @@ function testContentTranslation() { // Attempt a resubmission of the form - this emulates using the back button // to return to the page then resubmitting the form without a refresh. $edit = array(); - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit["title"] = $this->randomName(); $edit["body[$langcode][0][value]"] = $this->randomName(); $this->drupalPost('node/add/page', $edit, t('Save'), array('query' => array('translation' => $node->nid, 'language' => 'es'))); @@ -116,7 +117,7 @@ function testContentTranslation() { // Update original and mark translation as outdated. $node_body = $this->randomName(); - $node->body[LANGUAGE_NOT_SPECIFIED][0]['value'] = $node_body; + $node->body[Language::LANGUAGE_NOT_SPECIFIED][0]['value'] = $node_body; $edit = array(); $edit["body[$langcode][0][value]"] = $node_body; $edit['translation[retranslate]'] = TRUE; @@ -137,9 +138,9 @@ function testContentTranslation() { // Confirm that language neutral is an option for translators when there are // disabled languages. $this->drupalGet('node/add/page'); - $this->assertFieldByXPath('//select[@name="langcode"]//option', LANGUAGE_NOT_SPECIFIED, 'Language neutral is available in language selection with disabled languages.'); - $node2 = $this->createPage($this->randomName(), $this->randomName(), LANGUAGE_NOT_SPECIFIED); - $this->assertRaw($node2->body[LANGUAGE_NOT_SPECIFIED][0]['value'], 'Language neutral content created with disabled languages available.'); + $this->assertFieldByXPath('//select[@name="langcode"]//option', Language::LANGUAGE_NOT_SPECIFIED, 'Language neutral is available in language selection with disabled languages.'); + $node2 = $this->createPage($this->randomName(), $this->randomName(), Language::LANGUAGE_NOT_SPECIFIED); + $this->assertRaw($node2->body[Language::LANGUAGE_NOT_SPECIFIED][0]['value'], 'Language neutral content created with disabled languages available.'); // Leave just one language installed and check that the translation overview // page is still accessible. @@ -219,7 +220,7 @@ function testLanguageSwitcherBlockIntegration() { // Create a language neutral node and check that the language switcher is // left untouched. - $node2 = $this->createPage($this->randomName(), $this->randomName(), LANGUAGE_NOT_SPECIFIED); + $node2 = $this->createPage($this->randomName(), $this->randomName(), Language::LANGUAGE_NOT_SPECIFIED); $node2_en = (object) array('nid' => $node2->nid, 'langcode' => 'en'); $node2_es = (object) array('nid' => $node2->nid, 'langcode' => 'es'); $node2_it = (object) array('nid' => $node2->nid, 'langcode' => 'it'); @@ -328,7 +329,7 @@ function addLanguage($langcode) { } else { // It's installed. No need to do anything. - $this->assertTrue(true, 'Language [' . $langcode . '] already installed.'); + $this->assertTrue(TRUE, 'Language [' . $langcode . '] already installed.'); } } @@ -347,7 +348,7 @@ function addLanguage($langcode) { */ function createPage($title, $body, $langcode = NULL) { $edit = array(); - $field_langcode = LANGUAGE_NOT_SPECIFIED; + $field_langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit["title"] = $title; $edit["body[$field_langcode][0][value]"] = $body; if (!empty($langcode)) { @@ -381,10 +382,10 @@ function createPage($title, $body, $langcode = NULL) { function createTranslation(Node $node, $title, $body, $langcode) { $this->drupalGet('node/add/page', array('query' => array('translation' => $node->nid, 'target' => $langcode))); - $field_langcode = LANGUAGE_NOT_SPECIFIED; + $field_langcode = Language::LANGUAGE_NOT_SPECIFIED; $body_key = "body[$field_langcode][0][value]"; $this->assertFieldByXPath('//input[@id="edit-title"]', $node->label(), "Original title value correctly populated."); - $this->assertFieldByXPath("//textarea[@name='$body_key']", $node->body[LANGUAGE_NOT_SPECIFIED][0]['value'], "Original body value correctly populated."); + $this->assertFieldByXPath("//textarea[@name='$body_key']", $node->body[Language::LANGUAGE_NOT_SPECIFIED][0]['value'], "Original body value correctly populated."); $edit = array(); $edit["title"] = $title; diff --git a/core/modules/translation/translation.module b/core/modules/translation/translation.module index 69d01c3..6aef7ac 100644 --- a/core/modules/translation/translation.module +++ b/core/modules/translation/translation.module @@ -19,6 +19,7 @@ * date (0) or needs to be updated (1). */ +use Drupal\Core\Language\Language; use Drupal\node\Plugin\Core\Entity\Node; /** @@ -84,7 +85,7 @@ function translation_menu() { * @see translation_menu() */ function _translation_tab_access($node) { - if ($node->langcode != LANGUAGE_NOT_SPECIFIED && translation_supported_type($node->type) && node_access('view', $node)) { + if ($node->langcode != Language::LANGUAGE_NOT_SPECIFIED && translation_supported_type($node->type) && node_access('view', $node)) { return translation_user_can_translate_node($node); } return FALSE; @@ -175,7 +176,7 @@ function translation_form_node_type_form_alter(&$form, &$form_state) { */ function translation_node_type_language_translation_enabled_validate($element, &$form_state, $form) { if (language_is_locked($form_state['values']['language_configuration']['langcode']) && $form_state['values']['language_configuration']['language_hidden'] && $form_state['values']['node_type_language_translation_enabled']) { - foreach (language_list(LANGUAGE_LOCKED) as $language) { + foreach (language_list(Language::LANGUAGE_LOCKED) as $language) { $locked_languages[] = $language->name; } form_set_error('node_type_language_translation_enabled', t('Translation is not supported if language is always one of: @locked_languages', array('@locked_languages' => implode(", ", $locked_languages)))); @@ -202,7 +203,7 @@ function translation_form_node_form_alter(&$form, &$form_state) { // Disable languages for existing translations, so it is not possible // to switch this node to some language which is already in the // translation set. Also remove the language neutral option. - unset($form['langcode']['#options'][LANGUAGE_NOT_SPECIFIED]); + unset($form['langcode']['#options'][Language::LANGUAGE_NOT_SPECIFIED]); foreach (translation_node_get_translations($node->tnid) as $langcode => $translation) { if ($translation->nid != $node->nid) { unset($form['langcode']['#options'][$langcode]); @@ -252,7 +253,7 @@ function translation_node_view(Node $node, $view_mode) { // If the site has no translations or is not multilingual we have no content // translation links to display. if (isset($node->tnid) && language_multilingual() && $translations = translation_node_get_translations($node->tnid)) { - $languages = language_list(LANGUAGE_ALL); + $languages = language_list(Language::LANGUAGE_ALL); // There might be a language provider enabled defining custom language // switch links which need to be taken into account while generating the @@ -547,7 +548,7 @@ function translation_language_switch_links_alter(array &$links, $type, $path) { // have translations it might be a language neutral node, in which case we // must leave the language switch links unaltered. This is true also for // nodes not having translation support enabled. - if (empty($node) || $node->langcode == LANGUAGE_NOT_SPECIFIED || !translation_supported_type($node->type)) { + if (empty($node) || $node->langcode == Language::LANGUAGE_NOT_SPECIFIED || !translation_supported_type($node->type)) { return; } $translations = array($node->langcode => $node); diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationController.php b/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationController.php index b08518a..b4424a5 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationController.php +++ b/core/modules/translation_entity/lib/Drupal/translation_entity/EntityTranslationController.php @@ -8,6 +8,7 @@ namespace Drupal\translation_entity; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Language\Language; /** * Base class for entity translation controllers. @@ -164,7 +165,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac '#submit' => array(array($this, 'entityFormSourceChange')), ), ); - foreach (language_list(LANGUAGE_CONFIGURABLE) as $language) { + foreach (language_list(Language::LANGUAGE_CONFIGURABLE) as $language) { if (isset($translations[$language->langcode])) { $form['source_langcode']['source']['#options'][$language->langcode] = $language->name; } @@ -177,7 +178,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(LANGUAGE_CONFIGURABLE) as $language) { + foreach (language_list(Language::LANGUAGE_CONFIGURABLE) as $language) { if (empty($translations[$language->langcode]) || $language->langcode == $entity_langcode) { $form['langcode']['#options'][$language->langcode] = $language->name; } diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php index eac0b7f..b406ae4 100644 --- a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php +++ b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationUITest.php @@ -270,7 +270,7 @@ protected function getNewEntityValues($langcode) { */ protected function getEditValues($values, $langcode, $new = FALSE) { $edit = $values[$langcode]; - $langcode = $new ? LANGUAGE_NOT_SPECIFIED : $langcode; + $langcode = $new ? Language::LANGUAGE_NOT_SPECIFIED : $langcode; foreach ($values[$langcode] as $property => $value) { if (is_array($value)) { $edit["{$property}[$langcode][0][value]"] = $value[0]['value']; diff --git a/core/modules/translation_entity/translation_entity.admin.inc b/core/modules/translation_entity/translation_entity.admin.inc index bacba11..b7cf2ba 100644 --- a/core/modules/translation_entity/translation_entity.admin.inc +++ b/core/modules/translation_entity/translation_entity.admin.inc @@ -6,6 +6,7 @@ */ use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Language\Language; /** * Form constructor for the confirmation of translatability switching. @@ -42,7 +43,7 @@ function translation_entity_translatable_form(array $form, array &$form_state, $ * This submit handler maintains consistency between the translatability of an * entity and the language under which the field data is stored. When a field is * marked as translatable, all the data in - * $entity->{field_name}[LANGUAGE_NOT_SPECIFIED] is moved to + * $entity->{field_name}[Language::LANGUAGE_NOT_SPECIFIED] is moved to * $entity->{field_name}[$entity_language]. When a field is marked as * untranslatable the opposite process occurs. Note that marking a field as * untranslatable will cause all of its translations to be permanently removed, @@ -65,9 +66,9 @@ function translation_entity_translatable_form_submit(array $form, array $form_st } // If a field is untranslatable, it can have no data except under - // LANGUAGE_NOT_SPECIFIED. Thus we need a field to be translatable before we convert + // Language::LANGUAGE_NOT_SPECIFIED. Thus we need a field to be translatable before we convert // data to the entity language. Conversely we need to switch data back to - // LANGUAGE_NOT_SPECIFIED before making a field untranslatable lest we lose + // Language::LANGUAGE_NOT_SPECIFIED before making a field untranslatable lest we lose // information. $operations = array( array('translation_entity_translatable_batch', array(!$translatable, $field_name)), @@ -111,7 +112,7 @@ function translation_entity_translatable_switch($translatable, $field_name) { } /** - * Batch callback: Converts field data to or from LANGUAGE_NOT_SPECIFIED. + * Batch callback: Converts field data to or from Language::LANGUAGE_NOT_SPECIFIED. * * @param bool $translatable * Indicator of whether the field should be made translatable (TRUE) or @@ -179,7 +180,7 @@ function translation_entity_translatable_batch($translatable, $field_name, &$con $langcode = $entity->language()->langcode; // Skip process for language neutral entities. - if ($langcode == LANGUAGE_NOT_SPECIFIED) { + if ($langcode == Language::LANGUAGE_NOT_SPECIFIED) { continue; } @@ -189,27 +190,27 @@ function translation_entity_translatable_batch($translatable, $field_name, &$con // we need to store the new translations and only after we can remove the // old ones. Otherwise we might have data loss, since the removal of the // old translations might occur before the new ones are stored. - if ($translatable && isset($entity->{$field_name}[LANGUAGE_NOT_SPECIFIED])) { + if ($translatable && isset($entity->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED])) { // If the field is being switched to translatable and has data for - // LANGUAGE_NOT_SPECIFIED then we need to move the data to the right + // Language::LANGUAGE_NOT_SPECIFIED then we need to move the data to the right // language. - $entity->{$field_name}[$langcode] = $entity->{$field_name}[LANGUAGE_NOT_SPECIFIED]; + $entity->{$field_name}[$langcode] = $entity->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED]; // Store the original value. _translation_entity_update_field($entity_type, $entity, $field_name); - $entity->{$field_name}[LANGUAGE_NOT_SPECIFIED] = array(); + $entity->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED] = array(); // Remove the language neutral value. _translation_entity_update_field($entity_type, $entity, $field_name); } elseif (!$translatable && isset($entity->{$field_name}[$langcode])) { // The field has been marked untranslatable and has data in the entity - // language: we need to move it to LANGUAGE_NOT_SPECIFIED and drop the + // language: we need to move it to Language::LANGUAGE_NOT_SPECIFIED and drop the // other translations. - $entity->{$field_name}[LANGUAGE_NOT_SPECIFIED] = $entity->{$field_name}[$langcode]; + $entity->{$field_name}[Language::LANGUAGE_NOT_SPECIFIED] = $entity->{$field_name}[$langcode]; // Store the original value. _translation_entity_update_field($entity_type, $entity, $field_name); // Remove translations. foreach ($entity->{$field_name} as $langcode => $items) { - if ($langcode != LANGUAGE_NOT_SPECIFIED) { + if ($langcode != Language::LANGUAGE_NOT_SPECIFIED) { $entity->{$field_name}[$langcode] = array(); } } diff --git a/core/modules/translation_entity/translation_entity.install b/core/modules/translation_entity/translation_entity.install index e66e544..312e1be 100644 --- a/core/modules/translation_entity/translation_entity.install +++ b/core/modules/translation_entity/translation_entity.install @@ -5,6 +5,8 @@ * Installation functions for Entity Translation module. */ +use Drupal\Core\Language\Language; + /** * Implements hook_schema(). */ @@ -57,7 +59,7 @@ function translation_entity_schema() { */ function translation_entity_install() { language_negotiation_include(); - language_negotiation_set(LANGUAGE_TYPE_CONTENT, array(LANGUAGE_NEGOTIATION_URL => 0)); + language_negotiation_set(Language::LANGUAGE_TYPE_CONTENT, array(LANGUAGE_NEGOTIATION_URL => 0)); } /** diff --git a/core/modules/translation_entity/translation_entity.module b/core/modules/translation_entity/translation_entity.module index 91ee94c..bef317a 100644 --- a/core/modules/translation_entity/translation_entity.module +++ b/core/modules/translation_entity/translation_entity.module @@ -46,7 +46,7 @@ function translation_entity_help($path, $arg) { * Implements hook_language_type_info_alter(). */ function translation_entity_language_types_info_alter(array &$language_types) { - unset($language_types[LANGUAGE_TYPE_CONTENT]['fixed']); + unset($language_types[Language::LANGUAGE_TYPE_CONTENT]['fixed']); } /** @@ -246,7 +246,7 @@ function translation_entity_translate_access(EntityInterface $entity) { */ function translation_entity_add_access(EntityInterface $entity, Language $source = NULL, Language $target = NULL) { $source = !empty($source) ? $source : $entity->language(); - $target = !empty($target) ? $target : language(LANGUAGE_TYPE_CONTENT); + $target = !empty($target) ? $target : language(Language::LANGUAGE_TYPE_CONTENT); $translations = $entity->getTranslationLanguages(); $languages = language_list(); return $source->langcode != $target->langcode && isset($languages[$source->langcode]) && isset($languages[$target->langcode]) && !isset($translations[$target->langcode]) && translation_entity_access($entity, $target->langcode); @@ -682,7 +682,7 @@ function translation_entity_language_configuration_element_validate($element, ar $key = $form_state['translation_entity']['key']; $values = $form_state['values'][$key]; if (language_is_locked($values['langcode']) && $values['language_hidden'] && $values['translation_entity']) { - foreach (language_list(LANGUAGE_LOCKED) as $language) { + foreach (language_list(Language::LANGUAGE_LOCKED) as $language) { $locked_languages[] = $language->name; } // @todo Set the correct form element name as soon as the element parents diff --git a/core/modules/translation_entity/translation_entity.pages.inc b/core/modules/translation_entity/translation_entity.pages.inc index 294c97b..19be70f 100644 --- a/core/modules/translation_entity/translation_entity.pages.inc +++ b/core/modules/translation_entity/translation_entity.pages.inc @@ -153,12 +153,12 @@ function translation_entity_overview(EntityInterface $entity) { * A renderable array of language switch links. */ function _translation_entity_get_switch_links($path) { - $links = language_negotiation_get_switch_links(LANGUAGE_TYPE_CONTENT, $path); + $links = language_negotiation_get_switch_links(Language::LANGUAGE_TYPE_CONTENT, $path); if (empty($links)) { // If content language is set up to fall back to the interface language, - // then there will be no switch links for LANGUAGE_TYPE_CONTENT, ergo we + // then there will be no switch links for Language::LANGUAGE_TYPE_CONTENT, ergo we // also need to use interface switch links. - $links = language_negotiation_get_switch_links(LANGUAGE_TYPE_INTERFACE, $path); + $links = language_negotiation_get_switch_links(Language::LANGUAGE_TYPE_INTERFACE, $path); } return $links; } @@ -180,7 +180,7 @@ function _translation_entity_get_switch_links($path) { */ function translation_entity_add_page(EntityInterface $entity, Language $source = NULL, Language $target = NULL) { $source = !empty($source) ? $source : $entity->language(); - $target = !empty($target) ? $target : language(LANGUAGE_TYPE_CONTENT); + $target = !empty($target) ? $target : language(Language::LANGUAGE_TYPE_CONTENT); // @todo Exploit the upcoming hook_entity_prepare() when available. translation_entity_prepare_translation($entity, $source, $target); $info = $entity->entityInfo(); diff --git a/core/modules/user/lib/Drupal/user/AccountFormController.php b/core/modules/user/lib/Drupal/user/AccountFormController.php index 512f703..05fec20 100644 --- a/core/modules/user/lib/Drupal/user/AccountFormController.php +++ b/core/modules/user/lib/Drupal/user/AccountFormController.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityFormController; +use Drupal\Core\Language\Language; /** * Form controller for the user account forms. @@ -22,7 +23,7 @@ public function form(array $form, array &$form_state, EntityInterface $account) global $user; $config = config('user.settings'); - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); $register = empty($account->uid); $admin = user_access('administer users'); @@ -177,7 +178,7 @@ public function form(array $form, array &$form_state, EntityInterface $account) // Is default the interface language? include_once DRUPAL_ROOT . '/core/includes/language.inc'; - $interface_language_is_default = language_negotiation_method_get_first(LANGUAGE_TYPE_INTERFACE) != LANGUAGE_NEGOTIATION_SELECTED; + $interface_language_is_default = language_negotiation_method_get_first(Language::LANGUAGE_TYPE_INTERFACE) != LANGUAGE_NEGOTIATION_SELECTED; $form['language'] = array( '#type' => language_multilingual() ? 'details' : 'container', '#title' => t('Language settings'), @@ -189,7 +190,7 @@ public function form(array $form, array &$form_state, EntityInterface $account) $form['language']['preferred_langcode'] = array( '#type' => 'language_select', '#title' => t('Site language'), - '#languages' => LANGUAGE_CONFIGURABLE, + '#languages' => Language::LANGUAGE_CONFIGURABLE, '#default_value' => $user_preferred_langcode, '#description' => $interface_language_is_default ? t("This account's preferred language for e-mails and site presentation.") : t("This account's preferred language for e-mails."), ); @@ -197,7 +198,7 @@ public function form(array $form, array &$form_state, EntityInterface $account) $form['language']['preferred_admin_langcode'] = array( '#type' => 'language_select', '#title' => t('Administration pages language'), - '#languages' => LANGUAGE_CONFIGURABLE, + '#languages' => Language::LANGUAGE_CONFIGURABLE, '#default_value' => $user_preferred_admin_langcode, '#access' => user_access('access administration pages', $account), ); diff --git a/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php index f2312fe..ddb3023 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php +++ b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/User.php @@ -10,6 +10,7 @@ use Drupal\Core\Entity\Entity; use Drupal\Core\Annotation\Plugin; use Drupal\Core\Annotation\Translation; +use Drupal\Core\Language\Language; /** * Defines the user entity class. @@ -154,21 +155,21 @@ class User extends Entity { * * @var string */ - public $langcode = LANGUAGE_NOT_SPECIFIED; + public $langcode = Language::LANGUAGE_NOT_SPECIFIED; /** * The user's preferred langcode for receiving emails and viewing the site. * * @var string */ - public $preferred_langcode = LANGUAGE_NOT_SPECIFIED; + public $preferred_langcode = Language::LANGUAGE_NOT_SPECIFIED; /** * The user's preferred langcode for viewing administration pages. * * @var string */ - public $preferred_admin_langcode = LANGUAGE_NOT_SPECIFIED; + public $preferred_admin_langcode = Language::LANGUAGE_NOT_SPECIFIED; /** * The email address used for initial account creation. diff --git a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php index e9f3f6c..341922b 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php @@ -287,7 +287,7 @@ function testUserDelete() { $node = $this->drupalCreateNode(array('uid' => $account->uid)); // Create comment. - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit = array(); $edit['subject'] = $this->randomName(8); $edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php b/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php index 8447031..75138fa 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php @@ -7,6 +7,7 @@ namespace Drupal\user\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -107,7 +108,7 @@ function testPictureOnNodeComment() { variable_set('theme_settings', array('toggle_comment_user_picture' => TRUE)); $edit = array( - 'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomString(), + 'comment_body[' . Language::LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomString(), ); $this->drupalPost('comment/reply/' . $node->nid, $edit, t('Save')); $this->assertRaw(file_uri_target($file->uri), 'User picture found on comment.'); @@ -122,6 +123,6 @@ function saveUserPicture($image) { // Load actual user data from database. $account = user_load($this->web_user->uid, TRUE); - return file_load($account->user_picture[LANGUAGE_NOT_SPECIFIED][0]['fid']); + return file_load($account->user_picture[Language::LANGUAGE_NOT_SPECIFIED][0]['fid']); } } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php index 30164f0..235cb65 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php @@ -7,6 +7,7 @@ namespace Drupal\user\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; class UserRegistrationTest extends WebTestBase { @@ -240,7 +241,7 @@ function testRegistrationWithUserFields() { // Check user fields. $accounts = entity_load_multiple_by_properties('user', array('name' => $name, 'mail' => $mail)); $new_user = reset($accounts); - $this->assertEqual($new_user->test_user_field[LANGUAGE_NOT_SPECIFIED][0]['value'], $value, 'The field value was correclty saved.'); + $this->assertEqual($new_user->test_user_field[Language::LANGUAGE_NOT_SPECIFIED][0]['value'], $value, 'The field value was correclty saved.'); // Check that the 'add more' button works. $field['cardinality'] = FIELD_CARDINALITY_UNLIMITED; @@ -268,9 +269,9 @@ function testRegistrationWithUserFields() { // Check user fields. $accounts = entity_load_multiple_by_properties('user', array('name' => $name, 'mail' => $mail)); $new_user = reset($accounts); - $this->assertEqual($new_user->test_user_field[LANGUAGE_NOT_SPECIFIED][0]['value'], $value, format_string('@js : The field value was correclty saved.', array('@js' => $js))); - $this->assertEqual($new_user->test_user_field[LANGUAGE_NOT_SPECIFIED][1]['value'], $value + 1, format_string('@js : The field value was correclty saved.', array('@js' => $js))); - $this->assertEqual($new_user->test_user_field[LANGUAGE_NOT_SPECIFIED][2]['value'], $value + 2, format_string('@js : The field value was correclty saved.', array('@js' => $js))); + $this->assertEqual($new_user->test_user_field[Language::LANGUAGE_NOT_SPECIFIED][0]['value'], $value, format_string('@js : The field value was correclty saved.', array('@js' => $js))); + $this->assertEqual($new_user->test_user_field[Language::LANGUAGE_NOT_SPECIFIED][1]['value'], $value + 1, format_string('@js : The field value was correclty saved.', array('@js' => $js))); + $this->assertEqual($new_user->test_user_field[Language::LANGUAGE_NOT_SPECIFIED][2]['value'], $value + 2, format_string('@js : The field value was correclty saved.', array('@js' => $js))); } } } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php b/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php index 9ed88ca..e371008 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php @@ -7,6 +7,7 @@ namespace Drupal\user\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; /** @@ -96,7 +97,7 @@ function testUserSignature() { $this->assertFieldByName('signature[format]', $edit['signature[format]'], 'Submitted signature format found.'); // Create a comment. - $langcode = LANGUAGE_NOT_SPECIFIED; + $langcode = Language::LANGUAGE_NOT_SPECIFIED; $edit = array(); $edit['subject'] = $this->randomName(8); $edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php index d14e826..d80a096 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php @@ -42,7 +42,7 @@ public function setUp() { * Creates a user, then tests the tokens generated from it. */ function testUserTokenReplacement() { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); $url_options = array( 'absolute' => TRUE, 'language' => $language_interface, diff --git a/core/modules/user/user.install b/core/modules/user/user.install index cc0bfeb..193d4e4 100644 --- a/core/modules/user/user.install +++ b/core/modules/user/user.install @@ -6,6 +6,7 @@ */ use Drupal\Component\Uuid\Uuid; +use Drupal\Core\Language\Language; /** * Implements hook_schema(). @@ -731,7 +732,7 @@ function user_update_8011() { 'status' => FILE_STATUS_PERMANENT, 'filename' => drupal_basename($destination), 'uuid' => $uuid->generate(), - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, 'filesize' => filesize($destination), 'filemime' => file_get_mimetype($destination), 'timestamp' => REQUEST_TIME, @@ -877,7 +878,7 @@ function user_update_8012(&$sandbox) { 'bundle' => 'user', 'entity_id' => $uid, 'revision_id' => $uid, - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, 'delta' => 0, 'user_picture_fid' => $fid, )) @@ -888,7 +889,7 @@ function user_update_8012(&$sandbox) { 'bundle' => 'user', 'entity_id' => $uid, 'revision_id' => $uid, - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, 'delta' => 0, 'user_picture_fid' => $fid, )) diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc index a805258..e698697 100644 --- a/core/modules/user/user.pages.inc +++ b/core/modules/user/user.pages.inc @@ -5,6 +5,7 @@ * User page callback file for the user module. */ +use Drupal\Core\Language\Language; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -78,7 +79,7 @@ function user_pass_validate($form, &$form_state) { } function user_pass_submit($form, &$form_state) { - $language_interface = language(LANGUAGE_TYPE_INTERFACE); + $language_interface = language(Language::LANGUAGE_TYPE_INTERFACE); $account = $form_state['values']['account']; // Mail one time login URL and instructions using current language. diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php index ebae468..fee3c5c 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\cache; +use Drupal\Core\Language\Language; use Drupal\views\ViewExecutable; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\views\Plugin\views\PluginBase; @@ -286,7 +287,7 @@ public function generateResultsKey() { 'build_info' => $build_info, 'roles' => array_keys($user->roles), 'super-user' => $user->uid == 1, // special caching for super user. - 'langcode' => language(LANGUAGE_TYPE_INTERFACE)->langcode, + 'langcode' => language(Language::LANGUAGE_TYPE_INTERFACE)->langcode, 'base_url' => $GLOBALS['base_url'], ); foreach (array('exposed_info', 'page', 'sort', 'order', 'items_per_page', 'offset') as $key) { @@ -315,7 +316,7 @@ public function generateOutputKey() { 'roles' => array_keys($user->roles), 'super-user' => $user->uid == 1, // special caching for super user. 'theme' => $GLOBALS['theme'], - 'langcode' => language(LANGUAGE_TYPE_INTERFACE)->langcode, + 'langcode' => language(Language::LANGUAGE_TYPE_INTERFACE)->langcode, 'base_url' => $GLOBALS['base_url'], ); diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php index fa8207d..5933225 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php @@ -7,6 +7,7 @@ namespace Drupal\views\Plugin\views\display; +use Drupal\Core\Language\Language; use Drupal\views\ViewExecutable; use \Drupal\views\Plugin\views\PluginBase; @@ -1201,7 +1202,7 @@ public function optionsSummary(&$categories, &$options) { $languages = array( '***CURRENT_LANGUAGE***' => t("Current user's language"), '***DEFAULT_LANGUAGE***' => t("Default site language"), - LANGUAGE_NOT_SPECIFIED => t('Language neutral'), + Language::LANGUAGE_NOT_SPECIFIED => t('Language neutral'), ); if (module_exists('language')) { $languages = array_merge($languages, language_list()); @@ -1571,7 +1572,7 @@ public function buildOptionsForm(&$form, &$form_state) { $languages = array( '***CURRENT_LANGUAGE***' => t("Current user's language"), '***DEFAULT_LANGUAGE***' => t("Default site language"), - LANGUAGE_NOT_SPECIFIED => t('Language neutral'), + Language::LANGUAGE_NOT_SPECIFIED => t('Language neutral'), ); $languages = array_merge($languages, views_language_list()); diff --git a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php index 1e5b72f..d22a7db 100644 --- a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php @@ -7,6 +7,7 @@ namespace Drupal\views\Tests; +use Drupal\Core\Language\Language; use Drupal\simpletest\WebTestBase; use Drupal\views\ViewExecutable; @@ -48,7 +49,7 @@ protected function setUp() { 'name' => $this->randomName(), 'description' => $this->randomName(), 'vid' => drupal_strtolower($this->randomName()), - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, 'help' => '', 'nodes' => array('page' => 'page'), 'weight' => mt_rand(0, 10), @@ -93,17 +94,17 @@ protected function setUp() { $term = $this->createTerm($this->vocabulary); $values = array('created' => $time, 'type' => 'page'); - $values[$this->field_name][LANGUAGE_NOT_SPECIFIED][]['tid'] = $term->tid; + $values[$this->field_name][Language::LANGUAGE_NOT_SPECIFIED][]['tid'] = $term->tid; // Make every other node promoted. if ($i % 2) { $values['promote'] = TRUE; } - $values['body'][LANGUAGE_NOT_SPECIFIED][]['value'] = l('Node ' . 1, 'node/' . 1); + $values['body'][Language::LANGUAGE_NOT_SPECIFIED][]['value'] = l('Node ' . 1, 'node/' . 1); $node = $this->drupalCreateNode($values); - search_index($node->nid, 'node', $node->body[LANGUAGE_NOT_SPECIFIED][0]['value'], LANGUAGE_NOT_SPECIFIED); + search_index($node->nid, 'node', $node->body[Language::LANGUAGE_NOT_SPECIFIED][0]['value'], Language::LANGUAGE_NOT_SPECIFIED); $comment = array( 'uid' => $user->uid, @@ -155,7 +156,7 @@ function createTerm($vocabulary) { // Use the first available text format. 'format' => db_query_range('SELECT format FROM {filter_format}', 0, 1)->fetchField(), 'vid' => $vocabulary->id(), - 'langcode' => LANGUAGE_NOT_SPECIFIED, + 'langcode' => Language::LANGUAGE_NOT_SPECIFIED, )); taxonomy_term_save($term); return $term; diff --git a/core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php b/core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php index 693ed68..d406dde 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php @@ -7,6 +7,8 @@ namespace Drupal\views\Tests\Wizard; +use Drupal\Core\Language\Language; + /** * Tests the ability of the views wizard to create views filtered by taxonomy. */ @@ -103,7 +105,7 @@ function testTaggedWith() { $node_add_path = 'node/add/' . $this->node_type_with_tags->type; // Create three nodes, with different tags. - $tag_field = $this->tag_field['field_name'] . '[' . LANGUAGE_NOT_SPECIFIED . ']'; + $tag_field = $this->tag_field['field_name'] . '[' . Language::LANGUAGE_NOT_SPECIFIED . ']'; $edit = array(); $edit['title'] = $node_tag1_title = $this->randomName(); $edit[$tag_field] = 'tag1'; diff --git a/core/modules/views/lib/Drupal/views/ViewsDataCache.php b/core/modules/views/lib/Drupal/views/ViewsDataCache.php index 4df7ff5..2bc9ae1 100644 --- a/core/modules/views/lib/Drupal/views/ViewsDataCache.php +++ b/core/modules/views/lib/Drupal/views/ViewsDataCache.php @@ -9,6 +9,7 @@ use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Cache\CacheBackendInterface; +use Drupal\Core\Language\Language; /** * Class to manage and lazy load cached views data. @@ -75,7 +76,7 @@ public function __construct(CacheBackendInterface $cache_backend, ConfigFactory $this->config = $config; $this->cacheBackend = $cache_backend; - $this->langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode; + $this->langcode = language(Language::LANGUAGE_TYPE_INTERFACE)->langcode; $this->skipCache = $this->config->get('views.settings')->get('skip_cache'); } diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 22b5ca8..6b4e831 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -10,6 +10,7 @@ */ use Drupal\Core\Database\Query\AlterableInterface; +use Drupal\Core\Language\Language; use Drupal\views\ViewExecutable; use Drupal\Component\Plugin\Exception\PluginException; use Drupal\views\Plugin\Core\Entity\View; @@ -893,14 +894,14 @@ function views_add_contextual_links(&$render_element, $location, ViewExecutable * array. * @param int $flags * (optional) Specifies the state of the languages that have to be returned. - * It can be: LANGUAGE_CONFIGURABLE, LANGUAGE_LOCKED, LANGUAGE_ALL. + * It can be: Language::LANGUAGE_CONFIGURABLE, Language::LANGUAGE_LOCKED, Language::LANGUAGE_ALL. * * @return array * An array of language names (or $field) keyed by the langcode. * * @see locale_language_list() */ -function views_language_list($field = 'name', $flags = LANGUAGE_ALL) { +function views_language_list($field = 'name', $flags = Language::LANGUAGE_ALL) { $languages = language_list($flags); $list = array(); foreach ($languages as $language) { @@ -2184,7 +2185,7 @@ function views_cache_set($cid, $data, $use_language = FALSE) { return; } if ($use_language) { - $cid .= ':' . language(LANGUAGE_TYPE_INTERFACE)->langcode; + $cid .= ':' . language(Language::LANGUAGE_TYPE_INTERFACE)->langcode; } cache('views_info')->set($cid, $data); @@ -2208,7 +2209,7 @@ function views_cache_get($cid, $use_language = FALSE) { return FALSE; } if ($use_language) { - $cid .= ':' . language(LANGUAGE_TYPE_INTERFACE)->langcode; + $cid .= ':' . language(Language::LANGUAGE_TYPE_INTERFACE)->langcode; } return cache('views_info')->get($cid); diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index dea08db..37d5539 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -5,6 +5,7 @@ * Preprocessors and helper functions to make theming easier. */ +use Drupal\Core\Language\Language; use Drupal\Core\Template\Attribute; use Drupal\views\ViewExecutable; @@ -913,7 +914,7 @@ function template_preprocess_views_view_rss(&$vars) { $vars['link'] = check_url(url($path, $url_options)); } - $vars['langcode'] = check_plain(language(LANGUAGE_TYPE_INTERFACE)->langcode); + $vars['langcode'] = check_plain(language(Language::LANGUAGE_TYPE_INTERFACE)->langcode); $vars['namespaces'] = new Attribute($style->namespaces); $vars['items'] = $items; $vars['channel_elements'] = format_xml_elements($style->channel_elements);