Commit f2d710c6 authored by alexpott's avatar alexpott

Issue #1620010 by dawehner, ParisLiakos, plach, jibran: Move LANGUAGE...

Issue #1620010 by dawehner, ParisLiakos, plach, jibran: Move LANGUAGE constants to the Language class.
parent 8cc75202
......@@ -187,90 +187,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;
/**
* Time of the current request in seconds elapsed since the Unix Epoch.
*
......@@ -1465,7 +1381,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::TYPE_INTERFACE)->langcode;
}
if (empty($options['context'])) {
$options['context'] = '';
......@@ -1483,7 +1399,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::LANGCODE_SYSTEM && ($options['langcode'] != 'en' || variable_get('locale_translate_english', FALSE)) && function_exists('locale')) {
$string = locale($string, $options['context'], $options['langcode']);
}
if (empty($args)) {
......@@ -2571,7 +2487,7 @@ function drupal_language_initialize() {
* @see Drupal\Core\Language\LanguageManager
*
* @param string $type
* The type of language object needed, e.g. LANGUAGE_TYPE_INTERFACE.
* The type of language object needed, e.g. Language::TYPE_INTERFACE.
*/
function language($type) {
$container = drupal_container();
......@@ -2606,9 +2522,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::TYPE_INTERFACE => TRUE,
Language::TYPE_CONTENT => FALSE,
Language::TYPE_URL => FALSE,
);
}
......@@ -2630,13 +2546,14 @@ 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::STATE_CONFIGURABLE, Language::STATE_LOCKED,
* Language::STATE_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::STATE_CONFIGURABLE) {
$languages = &drupal_static(__FUNCTION__);
......@@ -2672,7 +2589,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::STATE_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));
......@@ -2680,7 +2597,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::STATE_LOCKED)) || (!$language->locked && !($flags & Language::STATE_CONFIGURABLE))) {
continue;
}
$filtered_languages[$langcode] = $language;
......@@ -2707,13 +2624,13 @@ function language_default_locked_languages($weight = 0) {
);
$languages = array();
$languages[LANGUAGE_NOT_SPECIFIED] = new Language(array(
'langcode' => LANGUAGE_NOT_SPECIFIED,
$languages[Language::LANGCODE_NOT_SPECIFIED] = new Language(array(
'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'name' => t('Not specified'),
'weight' => ++$weight,
) + $locked_language);
$languages[LANGUAGE_NOT_APPLICABLE] = new Language(array(
'langcode' => LANGUAGE_NOT_APPLICABLE,
$languages[Language::LANGCODE_NOT_APPLICABLE] = new Language(array(
'langcode' => Language::LANGCODE_NOT_APPLICABLE,
'name' => t('Not applicable'),
'weight' => ++$weight,
) + $locked_language);
......@@ -2730,7 +2647,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::STATE_ALL);
return isset($languages[$langcode]) ? $languages[$langcode] : FALSE;
}
......@@ -2744,7 +2661,7 @@ function language_load($langcode) {
* The printed name of the language.
*/
function language_name($langcode) {
if ($langcode == LANGUAGE_NOT_SPECIFIED) {
if ($langcode == Language::LANGCODE_NOT_SPECIFIED) {
return t('None');
}
......
......@@ -2,6 +2,7 @@
use Drupal\Component\Utility\Crypt;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Language\Language;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\Yaml\Parser;
use Drupal\Component\PhpStorage\PhpStorageFactory;
......@@ -1261,7 +1262,7 @@ function filter_xss_bad_protocol($string, $decode = TRUE) {
* Arbitrary elements may be added using the $args associative array.
*/
function format_rss_channel($title, $link, $description, $items, $langcode = NULL, $args = array()) {
$langcode = $langcode ? $langcode : language(LANGUAGE_TYPE_CONTENT)->langcode;
$langcode = $langcode ? $langcode : language(Language::TYPE_CONTENT)->langcode;
$output = "<channel>\n";
$output .= ' <title>' . check_plain($title) . "</title>\n";
......@@ -1563,7 +1564,7 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL
}
if (empty($langcode)) {
$langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode;
$langcode = language(Language::TYPE_INTERFACE)->langcode;
}
// Create a DrupalDateTime object from the timestamp and timezone.
......@@ -1711,7 +1712,7 @@ function datetime_default_format_type() {
* - '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::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
......@@ -1946,7 +1947,7 @@ function l($text, $path, array $options = array()) {
$active = array(
'path' => current_path(),
'front_page' => drupal_is_front_page(),
'language' => language(LANGUAGE_TYPE_URL)->langcode,
'language' => language(Language::TYPE_URL)->langcode,
'query' => Drupal::service('request')->query->all(),
);
}
......
......@@ -8,6 +8,7 @@
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Entity\EntityStorageException;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Language\Language;
/**
* Gets the entity definition for an entity type.
......@@ -58,7 +59,7 @@ function entity_info_cache_clear() {
function entity_get_bundles($entity_type = NULL) {
$bundles = &drupal_static(__FUNCTION__);
if (!$bundles) {
$langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode;
$langcode = language(Language::TYPE_INTERFACE)->langcode;
if ($cache = cache()->get("entity_bundle_info:$langcode")) {
$bundles = $cache->data;
}
......@@ -116,7 +117,7 @@ function entity_invoke_bundle_hook($hook, $entity_type, $bundle, $bundle_new = N
function entity_get_view_modes($entity_type = NULL) {
$view_modes = &drupal_static(__FUNCTION__);
if (!$view_modes) {
$langcode = language(LANGUAGE_TYPE_INTERFACE)->langcode;
$langcode = language(Language::TYPE_INTERFACE)->langcode;
if ($cache = cache()->get("entity_view_mode_info:$langcode")) {
$view_modes = $cache->data;
}
......
......@@ -10,6 +10,7 @@
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\BaseFormIdInterface;
use Drupal\Core\Database\Database;
use Drupal\Core\Language\Language;
use Drupal\Core\Template\Attribute;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Utility\Color;
......@@ -3761,7 +3762,7 @@ function form_validate_table($element, &$form_state) {
*/
function form_process_machine_name($element, &$form_state) {
// We need to pass the langcode to the client.
$language = language(LANGUAGE_TYPE_INTERFACE);
$language = language(Language::TYPE_INTERFACE);
// Apply default form element properties.
$element += array(
......
......@@ -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::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::TYPE_CONTENT.
*
* @return
* An array of language codes.
*/
function language_fallback_get_candidates($type = LANGUAGE_TYPE_CONTENT) {
function language_fallback_get_candidates($type = 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::LANGCODE_NOT_SPECIFIED at the end.
$fallback_candidates = array_keys(language_list());
$fallback_candidates[] = LANGUAGE_NOT_SPECIFIED;
$fallback_candidates[] = Language::LANGCODE_NOT_SPECIFIED;
// Let other modules hook in and add/change candidates.
drupal_alter('language_fallback_candidates', $fallback_candidates);
......
......@@ -7,6 +7,7 @@
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\Template\Attribute;
use Drupal\menu_link\Plugin\Core\Entity\MenuLink;
use Drupal\menu_link\MenuLinkStorageController;
......@@ -1109,7 +1110,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::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;
......@@ -1220,7 +1221,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::TYPE_INTERFACE);
// Check if the active trail has been overridden for this menu tree.
$active_path = menu_tree_get_path($menu_name);
......@@ -1371,7 +1372,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::TYPE_INTERFACE);
// Build the cache id; sort parents to prevent duplicate storage and remove
// default parameter values.
......
......@@ -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.
*
......@@ -306,7 +308,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::DIRECTION_RTL),
'ast' => array('Asturian', 'Asturianu'),
'az' => array('Azerbaijani', 'Azərbaycanca'),
'be' => array('Belarusian', 'Беларуская'),
......@@ -326,7 +328,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::DIRECTION_RTL),
'fi' => array('Finnish', 'Suomi'),
'fil' => array('Filipino', 'Filipino'),
'fo' => array('Faeroese', 'Føroyskt'),
......@@ -335,7 +337,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::DIRECTION_RTL),
'hi' => array('Hindi', 'हिन्दी'),
'hr' => array('Croatian', 'Hrvatski'),
'ht' => array('Haitian Creole', 'Kreyòl ayisyen'),
......@@ -387,7 +389,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::DIRECTION_RTL),
'vi' => array('Vietnamese', 'Tiếng Việt'),
'xx-lolspeak' => array('Lolspeak', 'Lolspeak'),
'zh-hans' => array('Chinese, Simplified', '简体中文'),
......
......@@ -10,6 +10,7 @@
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\Config;
use Drupal\Core\Language\Language;
use Drupal\Core\Template\Attribute;
use Drupal\Core\Utility\ThemeRegistry;
use Drupal\Core\Theme\ThemeSettings;
......@@ -1790,7 +1791,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::TYPE_URL);
$links = $variables['links'];
$attributes = $variables['attributes'];
......@@ -2736,7 +2737,7 @@ function _template_preprocess_default_variables() {
* @see system_elements()
*/
function template_preprocess_html(&$variables) {
$language_interface = language(LANGUAGE_TYPE_INTERFACE);
$language_interface = language(Language::TYPE_INTERFACE);
// Compile a list of classes that are going to be applied to the body element.
// This allows advanced theming based on context (home page, node of certain type, etc.).
......@@ -2870,7 +2871,7 @@ function template_preprocess_html(&$variables) {
* @see template_process_page()
*/
function template_preprocess_page(&$variables) {
$language_interface = language(LANGUAGE_TYPE_INTERFACE);
$language_interface = language(Language::TYPE_INTERFACE);
$site_config = config('system.site');
// Move some variables to the top level for themer convenience and template cleanliness.
......@@ -3085,7 +3086,7 @@ function theme_get_suggestions($args, $base, $delimiter = '__') {
*/
function template_preprocess_maintenance_page(&$variables) {
global $theme;
$language_interface = language(LANGUAGE_TYPE_INTERFACE);
$language_interface = language(Language::TYPE_INTERFACE);
// Retrieve the theme data to list all available regions.
$theme_data = list_themes();
$regions = $theme_data[$theme]->info['regions'];
......
......@@ -12,6 +12,7 @@
use Drupal\Core\Executable\ExecutableInterface;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator;
use Drupal\Core\Language\Language;
use Drupal\Core\Plugin\Discovery\AlterDecorator;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
......@@ -32,7 +33,7 @@ public function __construct(\Traversable $namespaces) {
$this->discovery = new AnnotatedClassDiscovery('Condition', $namespaces);
$this->discovery = new DerivativeDiscoveryDecorator($this->discovery);
$this->discovery = new AlterDecorator($this->discovery, 'condition_info');
$this->discovery = new CacheDecorator($this->discovery, 'condition:' . language(LANGUAGE_TYPE_INTERFACE)->langcode);
$this->discovery = new CacheDecorator($this->discovery, 'condition:' . language(Language::TYPE_INTERFACE)->langcode);
$this->factory = new DefaultFactory($this);
}
......
......@@ -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::TYPE_INTERFACE)->langcode;
$settings['country'] = !empty($settings['country']) ? $settings['country'] : config('system.date')->get('country.default');
// Instantiate the parent class.
......
......@@ -7,6 +7,7 @@
namespace Drupal\Core\Entity;
use Drupal\Core\Language\Language;
use PDO;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Entity\Query\QueryInterface;
......@@ -680,7 +681,7 @@ protected function invokeHook($hook, EntityInterface $entity) {
public function getFieldDefinitions(array $constraints) {
if (!isset($this->entityFieldInfo)) {
// First, try to load from cache.
$cid = 'entity_field_definitions:' . $this->entityType . ':' . language(LANGUAGE_TYPE_INTERFACE)->langcode;
$cid = 'entity_field_definitions:' . $this->entityType . ':' . language(Language::TYPE_INTERFACE)->langcode;
if ($cache = cache()->get($cid)) {
$this->entityFieldInfo = $cache->data;
}
......
......@@ -7,6 +7,7 @@
namespace Drupal\Core\Entity;
use Drupal\Core\Language\Language;
use PDO;
use Drupal\Core\Entity\Query\QueryInterface;
......@@ -202,7 +203,7 @@ protected function mapFromStorageRecords(array $records, $load_revision = FALSE)
// Skip the item delta and item value levels but let the field assign
// the value as suiting. This avoids unnecessary array hierarchies and
// saves memory here.
$values[$name][LANGUAGE_DEFAULT] = $value;
$values[$name][Language::LANGCODE_DEFAULT] = $value;
}
$bundle = $this->bundleKey ? $record->{$this->bundleKey} : FALSE;
// Turn the record into an entity class.
......@@ -242,9 +243,9 @@ protected function attachPropertyData(array &$entities, $load_revision = FALSE)
foreach ($data as $values) {
$id = $values[$this->idKey];
// Field values in default language are stored with LANGUAGE_DEFAULT as
// key.
$langcode = empty($values['default_langcode']) ? $values['langcode'] : LANGUAGE_DEFAULT;
// Field values in default language are stored with
// Language::LANGCODE_DEFAULT as key.
$langcode = empty($values['default_langcode']) ? $values['langcode'] : Language::LANGCODE_DEFAULT;
$translation = $entities[$id]->getTranslation($langcode);
foreach ($field_definition as $name => $definition) {
......
......@@ -27,7 +27,7 @@ class Entity implements IteratorAggregate, EntityInterface {
*
* @var string
*/
public $langcode = LANGUAGE_NOT_SPECIFIED;
public $langcode = Language::LANGCODE_NOT_SPECIFIED;
/**
* The entity type.
......@@ -260,7 +260,7 @@ public function getIterator() {
public function access($operation = 'view', \Drupal\user\Plugin\Core\Entity\User $account = NULL) {
return \Drupal::entityManager()
->getAccessController($this->entityType)
->access($this, $operation, LANGUAGE_DEFAULT, $account);
->access($this, $operation, Language::LANGCODE_DEFAULT, $account);
}
/**
......@@ -272,7 +272,7 @@ public function language() {
$language = language_load($this->langcode);
if (!$language) {
// Make sure we return a proper language object.
$language = new Language(array('langcode' => LANGUAGE_NOT_SPECIFIED));
$language = new Language(array('langcode' => Language::LANGCODE_NOT_SPECIFIED));
}
return $language;
}
......@@ -317,7 +317,7 @@ public function getTranslationLanguages($include_default = TRUE) {
}
}
}
$languages = array_intersect_key(language_list(LANGUAGE_ALL), $languages);
$languages = array_intersect_key(language_list(Language::STATE_ALL), $languages);
}
if (empty($include_default)) {
......
......@@ -7,6 +7,7 @@
namespace Drupal\Core\Entity;
use Drupal\Core\Language\Language;
use Drupal\user\Plugin\Core\Entity\User;
/**
......@@ -24,7 +25,7 @@ class EntityAccessController implements EntityAccessControllerInterface {
/**
* {@inheritdoc}
*/
public function access(EntityInterface $entity, $operation, $langcode = LANGUAGE_DEFAULT, User $account = NULL) {
public function access(EntityInterface $entity, $operation, $langcode = Language::LANGCODE_DEFAULT, User $account = NULL) {
// @todo Remove this once we can rely on $account.
if (!$account) {
......
......@@ -7,6 +7,7 @@
namespace Drupal\Core\Entity;
use Drupal\Core\Language\Language;
// @todo Don't depend on module level code.
use Drupal\user\Plugin\Core\Entity\User;
......@@ -25,7 +26,7 @@ interface EntityAccessControllerInterface {
* Usually one of "view", "create", "update" or "delete".
* @param string $langcode
* (optional) The language code for which to check access. Defaults to
* LANGUAGE_DEFAULT.
* Language::LANGCODE_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.
......@@ -33,7 +34,7 @@ interface EntityAccessControllerInterface {
* @return bool
* TRUE if access was granted, FALSE otherwise.
*/
public function access(EntityInterface $entity, $operation, $langcode = LANGUAGE_DEFAULT, User $account = NULL);
public function access(EntityInterface $entity, $operation, $langcode = Language::LANGCODE_DEFAULT, User $account = NULL);
/**