diff --git a/composer.json b/composer.json index 8fe2f28..37164c5 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "type": "drupal-core", "license": "GPL-2.0+", "require": { - "php": ">=5.4.5", + "php": ">5.4.4-13", "sdboyer/gliph": "0.1.*", "symfony/class-loader": "2.5.*", "symfony/css-selector": "2.5.*", diff --git a/core/includes/common.inc b/core/includes/common.inc index 8d69f34..9589aa1 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -752,7 +752,7 @@ function _l($text, $path, array $options = array()) { // Add a hreflang attribute if we know the language of this link's url and // hreflang has not already been set. if (!empty($variables['options']['language']) && !isset($variables['options']['attributes']['hreflang'])) { - $variables['options']['attributes']['hreflang'] = $variables['options']['language']->getId(); + $variables['options']['attributes']['hreflang'] = $variables['options']['language']->id; } // Set the "active" class if the 'set_active_class' option is not empty. @@ -1525,7 +1525,7 @@ function _drupal_add_js($data = NULL, $options = NULL) { 'currentPath' => $current_path, 'currentPathIsAdmin' => $current_path_is_admin, 'isFront' => drupal_is_front_page(), - 'currentLanguage' => \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId(), + 'currentLanguage' => \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_URL)->id, ); if (!empty($current_query)) { ksort($current_query); diff --git a/core/includes/file.inc b/core/includes/file.inc index 6030f14..78fdbfa 100644 --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -1032,14 +1032,14 @@ function file_delete_multiple(array $fids) { * @see file_unmanaged_delete_recursive() */ function file_unmanaged_delete($path) { - if (is_file($path)) { - return drupal_unlink($path); - } $logger = \Drupal::logger('file'); if (is_dir($path)) { $logger->error('%path is a directory and cannot be removed using file_unmanaged_delete().', array('%path' => $path)); return FALSE; } + if (is_file($path)) { + return drupal_unlink($path); + } // Return TRUE for non-existent file, but log that nothing was actually // deleted, as the current state is the intended result. if (!file_exists($path)) { diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index adb7d81..4997a23 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1303,10 +1303,11 @@ function install_check_localization_server($uri) { /** * Gets the core release version and release alternatives for localization. * - * In case core is a development version or the translation file for the - * release is not available, fall back to an earlier release. - * For example, 8.2.0-dev might fall back to 8.1.0 and 8.0.0-dev - * might fall back to 7.0. + * In case core is a development version or the translation file for the release + * is not available, fall back to the latest stable release. For example, + * 8.2-dev might fall back to 8.1 and 8.0-dev might fall back to 7.0. Fallback + * is required because the localization server only provides translation files + * for stable releases. * * @param string $version * (optional) Version of core trying to find translation files for. @@ -1314,87 +1315,90 @@ function install_check_localization_server($uri) { * @return array * Array of release data. Each array element is an associative array with: * - core: Core compatibility version (e.g., 8.x). - * - version: Release version (e.g., 8.1.0). + * - version: Release version (e.g., 8.1). */ function install_get_localization_release($version = \Drupal::VERSION) { $releases = array(); $alternatives = array(); + // The version string is broken up into: + // - major: Major version (e.g., "8"). + // - minor: Minor version (e.g., "0"). + // - extra: Extra version info (e.g., "alpha2"). + // - extra_text: The text part of "extra" (e.g., "alpha"). + // - extra_number: The number part of "extra" (e.g., "2"). $info = _install_get_version_info($version); - // This code assumes there is a first alpha available as "alpha1". For - // Drupal 8.0.0 that isn't the case. In addition the semantic versioning - // wasn't introduced before "alpha14". However, we have already gotten to - // "beta1" so we are ignoring this for now. - - // The fallback detection is relaxed - removing version duplicates at the end. - // Check if the version is a regular stable release (no 'rc', 'beta', 'alpha', // 'dev', etc.) if (!isset($info['extra_text'])) { // First version alternative: the current version. $alternatives[] = $version; - - // Patch-level: Previous and zero patch level (e.g., 8.2.4 falls back to - // 8.2.3 and 8.2.0). - if ($info['patch'] > 0) { - $alternatives[] = $info['major'] . '.' . $info['minor'] . '.' . ($info['patch'] - 1); - $alternatives[] = $info['major'] . '.' . $info['minor'] . '.0'; + // Point-releases: previous minor release (e.g., 8.2 falls back to 8.1). + if ($info['minor'] > 0) { + $alternatives[]= $info['major'] . '.' . ($info['minor'] - 1); } - // Zero patch: First release candidate (e.g., 8.0.0 falls back to - // 8.0.0-rc1). + // Zero release: first release candidate (e.g., 8.0 falls back to 8.0-rc1). else { - $alternatives[] = $info['major'] . '.' . $info['minor'] . '.0-rc1'; - } - // Point-releases: Previous and zero minor release (e.g., 8.2.x falls back - // to 8.1.0 and 8.0.0). - if ($info['minor'] > 0) { - $alternatives[] = $info['major'] . '.' . ($info['minor'] - 1) . '.0'; - $alternatives[] = $info['major'] . '.0.0'; + $alternatives[] = $info['major'] . '.0-rc1'; } } else { - // Below we assume that for all dev, alpha, beta or rc releases the patch - // level is 0. - - $release_levels = array('rc', 'beta', 'alpha'); - - if ($info['extra_text'] == 'dev') { - // Dev release: Any unstable release (e.g., 8.2.0-dev falls back to - // 8.2.0-rc1, 8.2.0-beta1 and 8.2.0-alpha1). - $alternatives[] = $info['major'] . '.' . $info['minor'] . '.0-rc1'; - $alternatives[] = $info['major'] . '.' . $info['minor'] . '.0-beta1'; - $alternatives[] = $info['major'] . '.' . $info['minor'] . '.0-alpha1'; - } - elseif (in_array($info['extra_text'], $release_levels)) { - // All other unstable release always includes the current version. - $alternatives[] = $version; - // Alpha release: Previous alpha release (e.g. 8.0.0-alpha2 falls back to - // 8.0.0-alpha1). - // Beta release: Previous beta release and first alpha release (e.g. - // 8.0.0-beta2 falls back to 8.0.0-beta1 and 8.0.0-alpha1). - // Release candidate: Previous release candidate and the first beta - // release (e.g. 8.0.0-rc2 falls back to 8.0.0-rc1 and 8.0.0-beta1). - $release_level_key = array_search($info['extra_text'], $release_levels); - if ($info['extra_number'] > 1) { - $alternatives[] = $info['major'] . '.' . $info['minor'] . '.0-' . $info['extra_text'] . ($info['extra_number'] - 1); - } - if ($info['extra_text'] != 'alpha') { - $alternatives[] = $info['major'] . '.' . $info['minor'] . '.0-' . $release_levels[$release_level_key + 1] . '1'; - } - } - else { - $alternatives[] = $info['major'] . '.' . $info['minor'] . '.0'; - } - // All unstable releases except the zero release: The previous minor release - // and the zero release. - if ($info['minor'] > 0) { - $alternatives[] = $info['major'] . '.' . ($info['minor'] - 1) . '.0'; - $alternatives[] = $info['major'] . '.0.0'; + switch ($info['extra_text']) { + // Alpha release: current alpha or previous alpha release (e.g. 8.0-alpha2 + // falls back to 8.0-alpha1). + case 'alpha': + $alternatives[] = $version; + if ($info['extra_number'] > 1) { + $alternatives[] = $info['major'] . '.0-alpha' . ($info['extra_number'] - 1); + } + break; + + // Beta release: current beta or previous beta release (e.g. 8.0-beta2 + // falls back to 8.0-beta1) or first alpha release. + case 'beta': + $alternatives[] = $version; + if ($info['extra_number'] > 1) { + $alternatives[] = $info['major'] . '.0-beta' . ($info['extra_number'] - 1); + } + else { + $alternatives[] = $info['major'] . '.0-alpha2'; + } + break; + + // Dev release: the previous point release (e.g., 8.2-dev falls back to + // 8.1) or any unstable release (e.g., 8.0-dev falls back to 8.0-rc1, + // 8.0-beta1 or 8.0-alpha12) + case 'dev': + if ($info['minor'] >= 1) { + $alternatives[] = $info['major'] . '.' . ($info['minor'] - 1); + } + else { + $alternatives[] = $info['major'] . '.0-rc1'; + $alternatives[] = $info['major'] . '.0-beta1'; + $alternatives[] = $info['major'] . '.0-alpha12'; + } + break; + + // Release candidate: the current or previous release candidate (e.g., + // 8.0-rc2 falls back to 8.0-rc1) or the first beta release. + case 'rc': + $alternatives[] = $version; + if ($info['extra_number'] >= 2) { + $alternatives[] = $info['major'] . '.0-rc' . ($info['extra_number'] - 1); + } + else { + $alternatives[] = $info['major'] . '.0-beta1'; + } + break; } } - $alternatives = array_unique($alternatives); + // All releases may fall back to the previous major release (e.g., 8.1 falls + // back to 7.0, 8.x-dev falls back to 7.0). This will probably only be used + // for early dev releases or languages with an inactive translation team. + $alternatives[] = $info['major'] - 1 . '.0'; + foreach ($alternatives as $alternative) { list($core) = explode('.', $alternative); $releases[] = array( @@ -1403,23 +1407,6 @@ function install_get_localization_release($version = \Drupal::VERSION) { ); } - // All releases may fall back to the previous major release (e.g., 8.1.0 - // may fall back to 7.0). This will probably only be used for early dev - // releases or languages with an inactive translation team. - if ($info['major'] == 8) { - $releases[] = array( - 'core' => '7.x', - 'version' => '7.0', - ); - } - else { - $prev_major = $info['major'] - 1; - $releases[] = array( - 'core' => $prev_major . '.x', - 'version' => $prev_major . '.0.0', - ); - } - return $releases; } @@ -1427,14 +1414,14 @@ function install_get_localization_release($version = \Drupal::VERSION) { * Extracts version information from a drupal core version string. * * @param string $version - * Version info string (e.g., 8.0.0, 8.1.0, 8.0.0-dev, 8.0.0-unstable1, - * 8.0.0-alpha2, 8.0.0-beta3, and 8.0.0-rc4). + * Version info string (e.g., 8.0, 8.1, 8.0-dev, 8.0-unstable1, 8.0-alpha2, + * 8.0-beta3, and 8.0-rc4). + * * * @return array * Associative array of version info: * - major: Major version (e.g., "8"). * - minor: Minor version (e.g., "0"). - * - patch: Patch version (e.g., "0"). * - extra: Extra version info (e.g., "alpha2"). * - extra_text: The text part of "extra" (e.g., "alpha"). * - extra_number: The number part of "extra" (e.g., "2"). @@ -1445,8 +1432,6 @@ function _install_get_version_info($version) { (?P[0-9]+) # Major release number. \. # . (?P[0-9]+) # Minor release number. - \. # . - (?P[0-9]+) # Patch release number. ) # ( # - # - separator for "extra" version information. @@ -2037,9 +2022,8 @@ function install_check_requirements($install_state) { // common configuration on shared hosting, and there is nothing Drupal // can do to prevent it. In this situation, having $file also owned by // the webserver does not introduce any additional security risk, so we - // keep the file in place. Additionally, this situation also occurs when - // the test runner is being run be different user than the webserver. - if (fileowner($default_file) === fileowner($file) || DRUPAL_TEST_IN_CHILD_SITE) { + // keep the file in place. + if (fileowner($default_file) === fileowner($file)) { $readable = drupal_verify_install_file($file, FILE_READABLE); $writable = drupal_verify_install_file($file, FILE_WRITABLE); $exists = TRUE; diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 8c947e2..1015f67 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1006,7 +1006,7 @@ function template_preprocess_links(&$variables) { $link_element['#options']['set_active_class'] = TRUE; if (!empty($link['language'])) { - $li_attributes['hreflang'] = $link['language']->getId(); + $li_attributes['hreflang'] = $link['language']->id; } // Add a "data-drupal-link-query" attribute to let the diff --git a/core/includes/update.inc b/core/includes/update.inc index aad19f2..22baff9 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -719,7 +719,7 @@ function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) { $langcode = substr($langcode_config_name, strlen('language.entity.')); $info = \Drupal::config($langcode_config_name)->get(); $languages[$langcode] = new Language(array( - 'default' => ($info['id'] == $default->getId()), + 'default' => ($info['id'] == $default->id), 'name' => $info['label'], 'id' => $info['id'], 'direction' => $info['direction'], @@ -731,7 +731,7 @@ function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) { } else { // No language module, so use the default language only. - $languages = array($default->getId() => $default); + $languages = array($default->id => $default); // Add the special languages, they will be filtered later if needed. $languages += \Drupal::languageManager()->getDefaultLockedLanguages($default->getWeight()); } diff --git a/core/lib/Drupal/Core/Cache/LanguageCacheContext.php b/core/lib/Drupal/Core/Cache/LanguageCacheContext.php index 0a3f16c..e2c1bd9 100644 --- a/core/lib/Drupal/Core/Cache/LanguageCacheContext.php +++ b/core/lib/Drupal/Core/Cache/LanguageCacheContext.php @@ -45,7 +45,7 @@ public function getContext() { $context_parts = array(); if ($this->languageManager->isMultilingual()) { foreach ($this->languageManager->getLanguageTypes() as $type) { - $context_parts[] = $this->languageManager->getCurrentLanguage($type)->getId(); + $context_parts[] = $this->languageManager->getCurrentLanguage($type)->id; } } return implode(':', $context_parts); diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php b/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php index f52aad0..14eac1d 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php @@ -14,37 +14,69 @@ * Provides a class to discover configuration entity dependencies. * * Configuration entities can depend on modules, themes and other configuration - * entities. The dependency system is used during configuration installation to - * ensure that configuration entities are imported in the correct order. For - * example, node types are created before their field storages and the field - * storages are created before their fields. + * entities. The dependency system is used during configuration installation, + * uninstallation and synchronization to ensure that configuration entities are + * handled in the correct order. For example, node types are created before + * their fields, and both are created before the view display configuration. * - * Dependencies are stored to the configuration entity's configuration object so - * that they can be checked without the module that provides the configuration - * entity class being installed. This is important for configuration - * synchronization which needs to be able to validate configuration in the - * staging directory before the synchronization has occurred. + * If a configuration entity is provided as default configuration by an + * extension (modules, themes, or profiles), the extension has to depend on any + * modules or themes that the configuration depends on. For example, if a view + * configuration entity is provided by an installation profile and the view will + * not work without a certain module, the profile must declare a dependency on + * this module in its info.yml file. If you do not want your extension to always + * depend on a particular module that one of the default configuration entities + * depends on, you can use a sub-module: move the configuration entity to the + * sub-module instead of including it in the main extension, and declare the + * module dependency in the sub-module only. * - * Configuration entities determine their dependencies by implementing - * \Drupal\Core\Config\Entity\ConfigEntityInterface::calculateDependencies(). - * This method should be called from the configuration entity's implementation - * of \Drupal\Core\Entity\EntityInterface::preSave(). Implementations should use - * the helper method + * Classes for configuration entities with dependencies normally extend + * \Drupal\Core\Config\Entity\ConfigEntityBase or at least use + * \Drupal\Core\Plugin\PluginDependencyTrait to manage dependencies. The class + * must implement + * \Drupal\Core\Config\Entity\ConfigEntityInterface::calculateDependencies(), + * which should calculate (and return) the dependencies. Use * \Drupal\Core\Config\Entity\ConfigEntityBase::addDependency() to add - * dependencies. All the implementations in core call the parent method - * \Drupal\Core\Config\Entity\ConfigEntityBase::calculateDependencies() which - * resets the dependencies and provides an implementation to determine the - * plugin providers for configuration entities that implement - * \Drupal\Core\Entity\EntityWithPluginBagsInterface. + * dependencies. Most implementations call + * \Drupal\Core\Config\Entity\ConfigEntityBase::calculateDependencies() since it + * provides a generic implementation that will discover dependencies due to + * plugins and third party settings. To get a configuration entities current + * dependencies without forcing a recalculation use + * \Drupal\Core\Config\Entity\ConfigEntityInterface::getDependencies(). * - * The configuration manager service provides methods to find dependencies for - * a specified module, theme or configuration entity. + * Classes for configurable plugins are a special case. They can either declare + * their configuration dependencies using the calculateDependencies() method + * described in the paragraph above, or if they have only static dependencies, + * these can be declared using the 'config_dependencies' annotation key. + * + * Once declared properly, dependencies are saved to the configuration entity's + * configuration object so that they can be checked without the module that + * provides the configuration entity class being installed. This is important + * for configuration synchronization, which needs to be able to validate + * configuration in the staging directory before the synchronization has + * occurred. + * + * When uninstalling a module or a theme, configuration entities that are + * dependent will also be removed. This default behavior can lead to undesirable + * side effects, such as a node view mode being entirely removed when the module + * defining a field or formatter it uses is uninstalled. To prevent this, + * configuration entity classes can implement + * \Drupal\Core\Config\Entity\ConfigEntityInterface::onDependencyRemoval(), + * which allows the entity class to remove dependencies instead of being deleted + * themselves. Implementations should save the entity if dependencies have been + * successfully removed, in order to register the newly cleaned-out dependency + * list. So, in the above example, the node view mode configuration entity class + * should implement this method to remove references to formatters if the plugin + * that supplies them depends on a module that is being uninstalled. * * @see \Drupal\Core\Config\Entity\ConfigEntityInterface::calculateDependencies() * @see \Drupal\Core\Config\Entity\ConfigEntityInterface::getConfigDependencyName() + * @see \Drupal\Core\Config\Entity\ConfigEntityInterface::onDependencyRemoval() * @see \Drupal\Core\Config\Entity\ConfigEntityBase::addDependency() - * @see \Drupal\Core\Config\ConfigInstaller::installDefaultConfig() + * @see \Drupal\Core\Config\ConfigInstallerInterface::installDefaultConfig() + * @see \Drupal\Core\Config\ConfigManagerInterface::uninstall() * @see \Drupal\Core\Config\Entity\ConfigEntityDependency + * @see \Drupal\Core\Plugin\PluginDependencyTrait */ class ConfigDependencyManager { diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index d226243..ea1c570 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -365,13 +365,18 @@ public function link($text = NULL, $rel = 'edit-form', array $options = []) { } /** - * {@inheritdoc} + * Overrides \Drupal\Core\Entity\DependencyTrait:addDependency(). + * + * Note that this function should only be called from implementation of + * \Drupal\Core\Config\Entity\ConfigEntityInterface::calculateDependencies() + * as dependencies are recalculated during every entity save. + * + * @see \Drupal\Core\Config\Entity\ConfigEntityDependency::hasDependency() */ protected function addDependency($type, $name) { // A config entity is always dependent on its provider. There is no need to // explicitly declare the dependency. An explicit dependency on Core, which // provides some plugins, is also not needed. - // @see \Drupal\Core\Config\Entity\ConfigEntityDependency::hasDependency() if ($type == 'module' && ($name == $this->getEntityType()->getProvider() || $name == 'core')) { return $this; } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php index b15498e..b83df5d 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php @@ -10,7 +10,7 @@ use Drupal\Core\Entity\EntityInterface; /** - * Defines the interface common for all configuration entities. + * Defines a common interface for configuration entities. * * @ingroup config_api * @ingroup entity_api @@ -146,6 +146,8 @@ public function set($property_name, $value); * * @return array * An array of dependencies grouped by type (module, theme, entity). + * + * @see \Drupal\Core\Config\Entity\ConfigDependencyManager */ public function calculateDependencies(); @@ -154,6 +156,8 @@ public function calculateDependencies(); * * @return string * The configuration dependency name. + * + * @see \Drupal\Core\Config\Entity\ConfigDependencyManager */ public function getConfigDependencyName(); @@ -176,6 +180,7 @@ public function getConfigDependencyName(); * An array of dependencies that will be deleted keyed by dependency type. * Dependency types are, for example, entity, module and theme. * + * @see \Drupal\Core\Config\Entity\ConfigDependencyManager * @see \Drupal\Core\Config\ConfigManager::uninstall() * @see \Drupal\Core\Entity\EntityDisplayBase::onDependencyRemoval() */ @@ -185,8 +190,9 @@ public function onDependencyRemoval(array $dependencies); * Gets the configuration dependencies. * * @return array - * An array of dependencies. If $type not set all dependencies will be - * returned keyed by $type. + * An array of dependencies, keyed by $type. + * + * @see \Drupal\Core\Config\Entity\ConfigDependencyManager */ public function getDependencies(); diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php index f7565d1..4cad074 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php @@ -189,7 +189,7 @@ protected function doLoadMultiple(array $ids = NULL) { */ protected function doCreate(array $values) { // Set default language to site default if not provided. - $values += array('langcode' => $this->languageManager->getDefaultLanguage()->getId()); + $values += array('langcode' => $this->languageManager->getDefaultLanguage()->id); $entity = new $this->entityClass($values, $this->entityTypeId); return $entity; diff --git a/core/lib/Drupal/Core/Datetime/DateFormatter.php b/core/lib/Drupal/Core/Datetime/DateFormatter.php index 0b4f817..b97f2e1 100644 --- a/core/lib/Drupal/Core/Datetime/DateFormatter.php +++ b/core/lib/Drupal/Core/Datetime/DateFormatter.php @@ -133,7 +133,7 @@ public function format($timestamp, $type = 'medium', $format = '', $timezone = N } if (empty($langcode)) { - $langcode = $this->languageManager->getCurrentLanguage()->getId(); + $langcode = $this->languageManager->getCurrentLanguage()->id; } // Create a DrupalDateTime object from the timestamp and timezone. diff --git a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php index 2f07108..78b3f1c 100644 --- a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php +++ b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php @@ -43,7 +43,7 @@ class DrupalDateTime extends DateTimePlus { */ public function __construct($time = 'now', $timezone = NULL, $settings = array()) { if (!isset($settings['langcode'])) { - $settings['langcode'] = \Drupal::languageManager()->getCurrentLanguage()->getId(); + $settings['langcode'] = \Drupal::languageManager()->getCurrentLanguage()->id; } // Instantiate the parent class. diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 76b8fd2..636c00b 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -475,7 +475,7 @@ public function language() { protected function setDefaultLangcode() { // Get the language code if the property exists. if ($this->hasField('langcode') && ($item = $this->get('langcode')) && isset($item->language)) { - $this->defaultLangcode = $item->language->getId(); + $this->defaultLangcode = $item->language->id; } if (empty($this->defaultLangcode)) { diff --git a/core/lib/Drupal/Core/Entity/ContentEntityForm.php b/core/lib/Drupal/Core/Entity/ContentEntityForm.php index 75c4927..64374cf 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityForm.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityForm.php @@ -91,7 +91,7 @@ public function getFormLangcode(FormStateInterface $form_state) { // Imply a 'view' operation to ensure users edit entities in the same // language they are displayed. This allows to keep contextual editing // working also for multilingual entities. - $form_state->set('langcode', $this->entityManager->getTranslationFromContext($this->entity)->language()->getId()); + $form_state->set('langcode', $this->entityManager->getTranslationFromContext($this->entity)->language()->id); } return $form_state->get('langcode'); } @@ -100,7 +100,7 @@ public function getFormLangcode(FormStateInterface $form_state) { * {@inheritdoc} */ public function isDefaultFormLangcode(FormStateInterface $form_state) { - return $this->getFormLangcode($form_state) == $this->entity->getUntranslated()->language()->getId(); + return $this->getFormLangcode($form_state) == $this->entity->getUntranslated()->language()->id; } /** diff --git a/core/lib/Drupal/Core/Entity/DependencyTrait.php b/core/lib/Drupal/Core/Entity/DependencyTrait.php index 2c77834..5815ab1 100644 --- a/core/lib/Drupal/Core/Entity/DependencyTrait.php +++ b/core/lib/Drupal/Core/Entity/DependencyTrait.php @@ -20,14 +20,13 @@ protected $dependencies = array(); /** - * Creates a dependency. + * Adds a dependency. * * @param string $type - * The type of dependency being checked. Either 'module', 'theme', 'entity'. + * The type of dependency being added: 'module', 'theme', or 'entity'. * @param string $name - * If $type equals 'module' or 'theme' then it should be the name of the - * module or theme. In the case of entity it should be the full - * configuration object name. + * If $type is 'module' or 'theme', the name of the module or theme. If + * $type is 'entity', the full configuration object name. * * @see \Drupal\Core\Config\Entity\ConfigEntityInterface::getConfigDependencyName() * @@ -54,17 +53,17 @@ protected function addDependency($type, $name) { * * @param array $dependencies. * An array of dependencies keyed by the type of dependency. One example: - * @code - * array( - * 'module' => array( - * 'node', - * 'field', - * 'image' - * ), - * ); - * @endcode + * @code + * array( + * 'module' => array( + * 'node', + * 'field', + * 'image', + * ), + * ); + * @endcode * - * @see ::addDependency + * @see \Drupal\Core\Entity\DependencyTrait::addDependency */ protected function addDependencies(array $dependencies) { foreach ($dependencies as $dependency_type => $list) { diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 3226239..9560c71 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -335,7 +335,7 @@ public function getBaseFieldDefinitions($entity_type_id) { // Check the static cache. if (!isset($this->baseFieldDefinitions[$entity_type_id])) { // Not prepared, try to load from cache. - $cid = 'entity_base_field_definitions:' . $entity_type_id . ':' . $this->languageManager->getCurrentLanguage()->getId(); + $cid = 'entity_base_field_definitions:' . $entity_type_id . ':' . $this->languageManager->getCurrentLanguage()->id; if ($cache = $this->cacheBackend->get($cid)) { $this->baseFieldDefinitions[$entity_type_id] = $cache->data; } @@ -433,7 +433,7 @@ public function getFieldDefinitions($entity_type_id, $bundle) { if (!isset($this->fieldDefinitions[$entity_type_id][$bundle])) { $base_field_definitions = $this->getBaseFieldDefinitions($entity_type_id); // Not prepared, try to load from cache. - $cid = 'entity_bundle_field_definitions:' . $entity_type_id . ':' . $bundle . ':' . $this->languageManager->getCurrentLanguage()->getId(); + $cid = 'entity_bundle_field_definitions:' . $entity_type_id . ':' . $bundle . ':' . $this->languageManager->getCurrentLanguage()->id; if ($cache = $this->cacheBackend->get($cid)) { $bundle_field_definitions = $cache->data; } @@ -541,7 +541,7 @@ public function getFieldStorageDefinitions($entity_type_id) { } } // Not prepared, try to load from cache. - $cid = 'entity_field_storage_definitions:' . $entity_type_id . ':' . $this->languageManager->getCurrentLanguage()->getId(); + $cid = 'entity_field_storage_definitions:' . $entity_type_id . ':' . $this->languageManager->getCurrentLanguage()->id; if ($cache = $this->cacheBackend->get($cid)) { $field_storage_definitions = $cache->data; } @@ -680,7 +680,7 @@ public function getBundleInfo($entity_type) { */ public function getAllBundleInfo() { if (empty($this->bundleInfo)) { - $langcode = $this->languageManager->getCurrentLanguage()->getId(); + $langcode = $this->languageManager->getCurrentLanguage()->id; if ($cache = $this->cacheBackend->get("entity_bundle_info:$langcode")) { $this->bundleInfo = $cache->data; } @@ -721,7 +721,7 @@ public function getExtraFields($entity_type_id, $bundle) { // Read from the persistent cache. Since hook_entity_extra_field_info() and // hook_entity_extra_field_info_alter() might contain t() calls, we cache // per language. - $cache_id = 'entity_bundle_extra_fields:' . $entity_type_id . ':' . $bundle . ':' . $this->languageManager->getCurrentLanguage()->getId(); + $cache_id = 'entity_bundle_extra_fields:' . $entity_type_id . ':' . $bundle . ':' . $this->languageManager->getCurrentLanguage()->id; $cached = $this->cacheBackend->get($cache_id); if ($cached) { $this->extraFields[$entity_type_id][$bundle] = $cached->data; @@ -783,7 +783,7 @@ public function getTranslationFromContext(EntityInterface $entity, $langcode = N if ($entity instanceof TranslatableInterface) { if (empty($langcode)) { - $langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(); + $langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->id; } // Retrieve language fallback candidates to perform the entity language @@ -794,7 +794,7 @@ public function getTranslationFromContext(EntityInterface $entity, $langcode = N // Ensure the default language has the proper language code. $default_language = $entity->getUntranslated()->language(); - $candidates[$default_language->getId()] = LanguageInterface::LANGCODE_DEFAULT; + $candidates[$default_language->id] = LanguageInterface::LANGCODE_DEFAULT; // Return the most fitting entity translation. foreach ($candidates as $candidate) { @@ -849,7 +849,7 @@ protected function getAllDisplayModesByEntityType($display_type) { if (!isset($this->displayModeInfo[$display_type])) { $key = 'entity_' . $display_type . '_info'; $entity_type_id = 'entity_' . $display_type; - $langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_INTERFACE)->getId(); + $langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_INTERFACE)->id; if ($cache = $this->cacheBackend->get("$key:$langcode")) { $this->displayModeInfo[$display_type] = $cache->data; } diff --git a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php index e31c133..91cfc34 100644 --- a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php @@ -109,7 +109,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 = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(); + $langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->id; } $build_list = array( diff --git a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php index 7faeccc..3d34f76 100644 --- a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php @@ -94,7 +94,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI */ public function doCreate(array $values = array()) { // Set default language to site default if not provided. - $values += array('langcode' => $this->languageManager->getDefaultLanguage()->getId()); + $values += array('langcode' => $this->languageManager->getDefaultLanguage()->id); $entity = new $this->entityClass($values, $this->entityTypeId); // @todo This is handled by ContentEntityStorageBase, which assumes diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php index 2aa5476..454944c 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -1112,8 +1112,8 @@ protected function mapToDataStorageRecord(EntityInterface $entity, $table_name = $table_name = $this->dataTable; } $record = $this->mapToStorageRecord($entity, $table_name); - $record->langcode = $entity->language()->getId(); - $record->default_langcode = intval($record->langcode == $entity->getUntranslated()->language()->getId()); + $record->langcode = $entity->language()->id; + $record->default_langcode = intval($record->langcode == $entity->getUntranslated()->language()->id); return $record; } @@ -1199,7 +1199,7 @@ protected function loadFieldItems(array $entities) { foreach ($entities as $key => $entity) { $bundles[$entity->bundle()] = TRUE; $ids[] = $load_current ? $key : $entity->getRevisionId(); - $default_langcodes[$key] = $entity->getUntranslated()->language()->getId(); + $default_langcodes[$key] = $entity->getUntranslated()->language()->id; } // Collect impacted fields. @@ -1275,7 +1275,7 @@ protected function saveFieldItems(EntityInterface $entity, $update = TRUE) { $id = $entity->id(); $bundle = $entity->bundle(); $entity_type = $entity->getEntityTypeId(); - $default_langcode = $entity->getUntranslated()->language()->getId(); + $default_langcode = $entity->getUntranslated()->language()->id; $translation_langcodes = array_keys($entity->getTranslationLanguages()); $table_mapping = $this->getTableMapping(); diff --git a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php index 42600fd..5533091 100644 --- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php @@ -94,7 +94,7 @@ public function onRespond(FilterResponseEvent $event) { $response->headers->set('X-UA-Compatible', 'IE=edge,chrome=1', FALSE); // Set the Content-language header. - $response->headers->set('Content-language', $this->languageManager->getCurrentLanguage()->getId()); + $response->headers->set('Content-language', $this->languageManager->getCurrentLanguage()->id); // Attach globally-declared headers to the response object so that Symfony // can send them for us correctly. diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php index 63c9a66..4665f1c 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Field\Plugin\Field\FieldType; -use Drupal\Core\Entity\Entity; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\TypedData\EntityDataDefinition; use Drupal\Core\Field\FieldDefinitionInterface; @@ -194,7 +193,8 @@ public function isEmpty() { if ($target_id !== NULL) { return FALSE; } - if ($this->entity && $this->entity instanceof Entity) { + // Allow auto-create entities. + if ($this->hasUnsavedEntity()) { return FALSE; } return TRUE; @@ -206,12 +206,6 @@ public function isEmpty() { public function preSave() { if ($this->hasUnsavedEntity()) { $this->entity->save(); - } - // Handle the case where an unsaved entity was directly set using the public - // 'entity' property and then saved before this entity. In this case - // ::hasUnsavedEntity() will return FALSE but $this->target_id will still be - // empty. - if (empty($this->target_id) && $this->entity) { $this->target_id = $this->entity->id(); } } diff --git a/core/lib/Drupal/Core/Language/Language.php b/core/lib/Drupal/Core/Language/Language.php index 175f9fb..84bf55a 100644 --- a/core/lib/Drupal/Core/Language/Language.php +++ b/core/lib/Drupal/Core/Language/Language.php @@ -41,7 +41,7 @@ class Language implements LanguageInterface { * * @var string */ - protected $id = ''; + public $id = ''; /** * The direction, left-to-right, or right-to-left. diff --git a/core/lib/Drupal/Core/Language/LanguageManager.php b/core/lib/Drupal/Core/Language/LanguageManager.php index 557faad..ee8bd2a 100644 --- a/core/lib/Drupal/Core/Language/LanguageManager.php +++ b/core/lib/Drupal/Core/Language/LanguageManager.php @@ -134,7 +134,7 @@ public function getLanguages($flags = LanguageInterface::STATE_CONFIGURABLE) { if (!isset($this->languages)) { // No language module, so use the default language only. $default = $this->getDefaultLanguage(); - $this->languages = array($default->getId() => $default); + $this->languages = array($default->id => $default); // Add the special languages, they will be filtered later if needed. $this->languages += $this->getDefaultLockedLanguages($default->getWeight()); } diff --git a/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php b/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php index 115edd6..d4f4970 100644 --- a/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php +++ b/core/lib/Drupal/Core/Page/DefaultHtmlFragmentRenderer.php @@ -100,7 +100,7 @@ public function preparePage(HtmlPage $page, &$page_array) { // HTML element attributes. $language_interface = $this->languageManager->getCurrentLanguage(); $html_attributes = $page->getHtmlAttributes(); - $html_attributes['lang'] = $language_interface->getId(); + $html_attributes['lang'] = $language_interface->id; $html_attributes['dir'] = $language_interface->getDirection(); $this->setDefaultMetaTags($page); diff --git a/core/lib/Drupal/Core/Path/AliasManager.php b/core/lib/Drupal/Core/Path/AliasManager.php index f09fd7c..bca2eea 100644 --- a/core/lib/Drupal/Core/Path/AliasManager.php +++ b/core/lib/Drupal/Core/Path/AliasManager.php @@ -157,7 +157,7 @@ public function getPathByAlias($alias, $langcode = NULL) { // language. If we used a language different from the one conveyed by the // requested URL, we might end up being unable to check if there is a path // alias matching the URL path. - $langcode = $langcode ?: $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId(); + $langcode = $langcode ?: $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_URL)->id; // If we already know that there are no paths for this alias simply return. if (empty($alias) || !empty($this->noPath[$langcode][$alias])) { @@ -191,7 +191,7 @@ public function getAliasByPath($path, $langcode = NULL) { // language. If we used a language different from the one conveyed by the // requested URL, we might end up being unable to check if there is a path // alias matching the URL path. - $langcode = $langcode ?: $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId(); + $langcode = $langcode ?: $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_URL)->id; // Check the path whitelist, if the top-level part before the first / // is not in the list, then there is no need to do anything further, diff --git a/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php b/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php index 67226ab..1c709a1 100644 --- a/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php +++ b/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php @@ -45,7 +45,7 @@ public function processInbound($path, Request $request) { */ public function processOutbound($path, &$options = array(), Request $request = NULL) { if (empty($options['alias'])) { - $langcode = isset($options['language']) ? $options['language']->getId() : NULL; + $langcode = isset($options['language']) ? $options['language']->id : NULL; $path = $this->aliasManager->getAliasByPath($path, $langcode); } return $path; diff --git a/core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php b/core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php index 21ec3ba..2114d38 100644 --- a/core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php +++ b/core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php @@ -19,7 +19,12 @@ use DependencyTrait; /** - * Calculates the dependencies of a specific plugin instance. + * Calculates and adds dependencies of a specific plugin instance. + * + * Dependencies are added for the module that provides the plugin, as well + * as any dependencies declared by the instance's calculateDependencies() + * method, if it implements + * \Drupal\Component\Plugin\ConfigurablePluginInterface. * * @param \Drupal\Component\Plugin\PluginInspectionInterface $instance * The plugin instance. diff --git a/core/lib/Drupal/Core/Render/Element/CompositeFormElementTrait.php b/core/lib/Drupal/Core/Render/Element/CompositeFormElementTrait.php index 1091442..4c1855a 100644 --- a/core/lib/Drupal/Core/Render/Element/CompositeFormElementTrait.php +++ b/core/lib/Drupal/Core/Render/Element/CompositeFormElementTrait.php @@ -32,7 +32,6 @@ public static function preRenderCompositeFormElement($element) { if (isset($element['#title']) || isset($element['#description'])) { // @see #type 'fieldgroup' - $element['#attributes']['id'] = $element['#id'] . '--wrapper'; $element['#theme_wrappers'][] = 'fieldset'; $element['#attributes']['class'][] = 'fieldgroup'; $element['#attributes']['class'][] = 'form-composite'; diff --git a/core/lib/Drupal/Core/Render/Element/MachineName.php b/core/lib/Drupal/Core/Render/Element/MachineName.php index 24ac3a4..f062a8c 100644 --- a/core/lib/Drupal/Core/Render/Element/MachineName.php +++ b/core/lib/Drupal/Core/Render/Element/MachineName.php @@ -170,7 +170,7 @@ public static function processMachineName(&$element, FormStateInterface $form_st 'machineName' => array( '#' . $source['#id'] => $element['#machine_name'], ), - 'langcode' => $language->getId(), + 'langcode' => $language->id, ), ); $element['#attached']['library'][] = 'core/drupal.machine-name'; diff --git a/core/lib/Drupal/Core/Session/UserSession.php b/core/lib/Drupal/Core/Session/UserSession.php index feb935c..7364da9 100644 --- a/core/lib/Drupal/Core/Session/UserSession.php +++ b/core/lib/Drupal/Core/Session/UserSession.php @@ -185,10 +185,10 @@ public function isAnonymous() { function getPreferredLangcode($fallback_to_default = TRUE) { $language_list = language_list(); if (!empty($this->preferred_langcode) && isset($language_list[$this->preferred_langcode])) { - return $language_list[$this->preferred_langcode]->getId(); + return $language_list[$this->preferred_langcode]->id; } else { - return $fallback_to_default ? language_default()->getId() : ''; + return $fallback_to_default ? language_default()->id : ''; } } @@ -198,10 +198,10 @@ function getPreferredLangcode($fallback_to_default = TRUE) { function getPreferredAdminLangcode($fallback_to_default = TRUE) { $language_list = language_list(); if (!empty($this->preferred_admin_langcode) && isset($language_list[$this->preferred_admin_langcode])) { - return $language_list[$this->preferred_admin_langcode]->getId(); + return $language_list[$this->preferred_admin_langcode]->id; } else { - return $fallback_to_default ? language_default()->getId() : ''; + return $fallback_to_default ? language_default()->id : ''; } } diff --git a/core/lib/Drupal/Core/StringTranslation/TranslationManager.php b/core/lib/Drupal/Core/StringTranslation/TranslationManager.php index cdfc2df..8080d4b 100644 --- a/core/lib/Drupal/Core/StringTranslation/TranslationManager.php +++ b/core/lib/Drupal/Core/StringTranslation/TranslationManager.php @@ -61,7 +61,7 @@ class TranslationManager implements TranslationInterface, TranslatorInterface { */ public function __construct(LanguageManagerInterface $language_manager) { $this->languageManager = $language_manager; - $this->defaultLangcode = $language_manager->getDefaultLanguage()->getId(); + $this->defaultLangcode = $language_manager->getDefaultLanguage()->id; } /** diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php index 61cdc73..3a0780f 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php @@ -56,7 +56,7 @@ public function getValue() { public function setValue($value, $notify = TRUE) { // Support passing language objects. if (is_object($value)) { - $this->id = $value->getId(); + $this->id = $value->id; $this->language = $value; } elseif (isset($value) && !is_scalar($value)) { @@ -88,7 +88,7 @@ public function id() { return $this->id; } elseif (isset($this->language)) { - return $this->language->getId(); + return $this->language->id; } } diff --git a/core/lib/Drupal/Core/Utility/LinkGenerator.php b/core/lib/Drupal/Core/Utility/LinkGenerator.php index 8578195..b029327 100644 --- a/core/lib/Drupal/Core/Utility/LinkGenerator.php +++ b/core/lib/Drupal/Core/Utility/LinkGenerator.php @@ -94,7 +94,7 @@ public function generate($text, Url $url) { // Add a hreflang attribute if we know the language of this link's url and // hreflang has not already been set. if (!empty($variables['options']['language']) && !isset($variables['options']['attributes']['hreflang'])) { - $variables['options']['attributes']['hreflang'] = $variables['options']['language']->getId(); + $variables['options']['attributes']['hreflang'] = $variables['options']['language']->id; } // Set the "active" class if the 'set_active_class' option is not empty. diff --git a/core/lib/Drupal/Core/Utility/Token.php b/core/lib/Drupal/Core/Utility/Token.php index 7c1a805..a59becb 100644 --- a/core/lib/Drupal/Core/Utility/Token.php +++ b/core/lib/Drupal/Core/Utility/Token.php @@ -311,7 +311,7 @@ public function findWithPrefix(array $tokens, $prefix, $delimiter = ':') { */ public function getInfo() { if (is_null($this->tokenInfo)) { - $cache_id = 'token_info:' . $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(); + $cache_id = 'token_info:' . $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->id; $cache = $this->cache->get($cache_id); if ($cache) { $this->tokenInfo = $cache->data; diff --git a/core/lib/Drupal/Core/Validation/DrupalTranslator.php b/core/lib/Drupal/Core/Validation/DrupalTranslator.php index 84847a5..01302ce 100644 --- a/core/lib/Drupal/Core/Validation/DrupalTranslator.php +++ b/core/lib/Drupal/Core/Validation/DrupalTranslator.php @@ -55,7 +55,7 @@ public function setLocale($locale) { * Implements \Symfony\Component\Translation\TranslatorInterface::getLocale(). */ public function getLocale() { - return $this->locale ? $this->locale : \Drupal::languageManager()->getCurrentLanguage()->getId(); + return $this->locale ? $this->locale : \Drupal::languageManager()->getCurrentLanguage()->id; } /** diff --git a/core/modules/action/src/Plugin/Action/EmailAction.php b/core/modules/action/src/Plugin/Action/EmailAction.php index 2a1e3a9..58409d1 100644 --- a/core/modules/action/src/Plugin/Action/EmailAction.php +++ b/core/modules/action/src/Plugin/Action/EmailAction.php @@ -101,7 +101,7 @@ public function execute($entity = NULL) { $langcode = $recipient_account->getPreferredLangcode(); } else { - $langcode = language_default()->getId(); + $langcode = language_default()->id; } $params = array('context' => $this->configuration); diff --git a/core/modules/aggregator/src/FeedForm.php b/core/modules/aggregator/src/FeedForm.php index 251bb44..f22de74 100644 --- a/core/modules/aggregator/src/FeedForm.php +++ b/core/modules/aggregator/src/FeedForm.php @@ -32,7 +32,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['langcode'] = array( '#title' => $this->t('Language'), '#type' => 'language_select', - '#default_value' => $feed->language()->getId(), + '#default_value' => $feed->language()->id, '#languages' => LanguageInterface::STATE_ALL, '#weight' => -4, ); diff --git a/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php b/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php index 199e224..fdc10dc 100644 --- a/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php +++ b/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php @@ -206,7 +206,7 @@ public function process(FeedInterface $feed) { $entry = reset($entry); } else { - $entry = entity_create('aggregator_item', array('langcode' => $feed->language()->getId())); + $entry = entity_create('aggregator_item', array('langcode' => $feed->language()->id)); } if ($item['timestamp']) { $entry->setPostedTime($item['timestamp']); diff --git a/core/modules/aggregator/src/Tests/FeedLanguageTest.php b/core/modules/aggregator/src/Tests/FeedLanguageTest.php index 09c608c..0d4e481 100644 --- a/core/modules/aggregator/src/Tests/FeedLanguageTest.php +++ b/core/modules/aggregator/src/Tests/FeedLanguageTest.php @@ -56,8 +56,8 @@ public function testFeedLanguage() { $feeds[2] = $this->createFeed(NULL, array('langcode' => $this->langcodes[2])); // Make sure that the language has been assigned. - $this->assertEqual($feeds[1]->language()->getId(), $this->langcodes[1]); - $this->assertEqual($feeds[2]->language()->getId(), $this->langcodes[2]); + $this->assertEqual($feeds[1]->language()->id, $this->langcodes[1]); + $this->assertEqual($feeds[2]->language()->id, $this->langcodes[2]); // Create example nodes to create feed items from and then update the feeds. $this->createSampleNodes(); @@ -70,7 +70,7 @@ public function testFeedLanguage() { $items = entity_load_multiple_by_properties('aggregator_item', array('fid' => $feed->id())); $this->assertTrue(count($items) > 0, 'Feed items were created.'); foreach ($items as $item) { - $this->assertEqual($item->language()->getId(), $feed->language()->getId()); + $this->assertEqual($item->language()->id, $feed->language()->id); } } } diff --git a/core/modules/block/src/Tests/BlockStorageUnitTest.php b/core/modules/block/src/Tests/BlockStorageUnitTest.php index 5fb4e8b..b063051 100644 --- a/core/modules/block/src/Tests/BlockStorageUnitTest.php +++ b/core/modules/block/src/Tests/BlockStorageUnitTest.php @@ -84,7 +84,7 @@ protected function createTests() { // Ensure that default values are filled in. $expected_properties = array( - 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(), + 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id, 'status' => TRUE, 'dependencies' => array('module' => array('block_test'), 'theme' => array('stark')), 'id' => 'test_block', diff --git a/core/modules/block_content/src/BlockContentForm.php b/core/modules/block_content/src/BlockContentForm.php index 769a7f3..df923ee 100644 --- a/core/modules/block_content/src/BlockContentForm.php +++ b/core/modules/block_content/src/BlockContentForm.php @@ -109,14 +109,14 @@ public function form(array $form, FormStateInterface $form_state) { // Set the correct default language. if ($block->isNew()) { $language_default = $this->languageManager->getCurrentLanguage($language_configuration['langcode']); - $block->langcode->value = $language_default->getId(); + $block->langcode->value = $language_default->id; } } $form['langcode'] = array( '#title' => $this->t('Language'), '#type' => 'language_select', - '#default_value' => $block->getUntranslated()->language()->getId(), + '#default_value' => $block->getUntranslated()->language()->id, '#languages' => LanguageInterface::STATE_ALL, '#access' => isset($language_configuration['language_show']) && $language_configuration['language_show'], ); diff --git a/core/modules/block_content/src/Tests/BlockContentTypeTest.php b/core/modules/block_content/src/Tests/BlockContentTypeTest.php index 76dfdb7..e08942b 100644 --- a/core/modules/block_content/src/Tests/BlockContentTypeTest.php +++ b/core/modules/block_content/src/Tests/BlockContentTypeTest.php @@ -57,7 +57,7 @@ public function testBlockContentTypeCreation() { $this->assertTrue($block_type, 'The new block type has been created.'); // Check that the block type was created in site default language. - $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; $this->assertEqual($block_type->language()->getId(), $default_langcode); } diff --git a/core/modules/book/book.links.task.yml b/core/modules/book/book.links.task.yml index 2f6765e..2ce18c6 100644 --- a/core/modules/book/book.links.task.yml +++ b/core/modules/book/book.links.task.yml @@ -8,8 +8,8 @@ book.settings: base_route: book.admin weight: 100 -entity.node.book_outline_form: - route_name: entity.node.book_outline_form +book.outline: + route_name: book.outline base_route: entity.node.canonical title: Outline weight: 2 diff --git a/core/modules/book/book.module b/core/modules/book/book.module index cea9627..2c936de 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -44,7 +44,7 @@ function book_help($route_name, RouteMatchInterface $route_match) { case 'book.admin': return '

' . t('The book module offers a means to organize a collection of related content pages, collectively known as a book. When viewed, this content automatically displays links to adjacent book pages, providing a simple navigation system for creating and reviewing structured content.') . '

'; - case 'entity.node.book_outline_form': + case 'book.outline': return '

' . t('The outline feature allows you to include pages in the Book hierarchy, as well as move them within the hierarchy or to reorder an entire book.', array('!book' => \Drupal::url('book.render'), '!book-admin' => \Drupal::url('book.admin'))) . '

'; } } @@ -88,8 +88,8 @@ function book_entity_type_build(array &$entity_types) { /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ $entity_types['node'] ->setFormClass('book_outline', 'Drupal\book\Form\BookOutlineForm') - ->setLinkTemplate('book-outline-form', 'entity.node.book_outline_form') - ->setLinkTemplate('book-remove-form', 'entity.node.book_remove_form'); + ->setLinkTemplate('book-outline-form', 'book.outline') + ->setLinkTemplate('book-remove-form', 'book.remove'); } /** @@ -478,7 +478,7 @@ function template_preprocess_book_export_html(&$variables) { // HTML element attributes. $attributes = array(); - $attributes['lang'] = $language_interface->getId(); + $attributes['lang'] = $language_interface->id; $attributes['dir'] = $language_interface->getDirection(); $variables['html_attributes'] = new Attribute($attributes); } diff --git a/core/modules/book/book.routing.yml b/core/modules/book/book.routing.yml index 13c0f10..c365d01 100644 --- a/core/modules/book/book.routing.yml +++ b/core/modules/book/book.routing.yml @@ -30,7 +30,7 @@ book.export: _permission: 'access printer-friendly version' _entity_access: 'node.view' -entity.node.book_outline_form: +book.outline: path: '/node/{node}/outline' defaults: _entity_form: 'node.book_outline' @@ -51,7 +51,7 @@ book.admin_edit: _entity_access: 'node.view' node: \d+ -entity.node.book_remove_form: +book.remove: path: '/node/{node}/outline/remove' defaults: _form: '\Drupal\book\Form\BookRemoveForm' diff --git a/core/modules/book/src/BookManager.php b/core/modules/book/src/BookManager.php index 8f2ab35..efab641 100644 --- a/core/modules/book/src/BookManager.php +++ b/core/modules/book/src/BookManager.php @@ -443,7 +443,7 @@ public function bookTreeAllData($bid, $link = NULL, $max_depth = NULL) { $nid = isset($link['nid']) ? $link['nid'] : 0; // Generate a cache ID (cid) specific for this $bid, $link, $language, and // depth. - $cid = 'book-links:' . $bid . ':all:' . $nid . ':' . $language_interface->getId() . ':' . (int) $max_depth; + $cid = 'book-links:' . $bid . ':all:' . $nid . ':' . $language_interface->id . ':' . (int) $max_depth; if (!isset($tree[$cid])) { // If the tree data was not in the static cache, build $tree_parameters. @@ -596,7 +596,7 @@ protected function doBookTreeBuild($bid, array $parameters = array()) { if (isset($parameters['expanded'])) { sort($parameters['expanded']); } - $tree_cid = 'book-links:' . $bid . ':tree-data:' . $language_interface->getId() . ':' . hash('sha256', serialize($parameters)); + $tree_cid = 'book-links:' . $bid . ':tree-data:' . $language_interface->id . ':' . hash('sha256', serialize($parameters)); // If we do not have this tree in the static cache, check {cache_data}. if (!isset($trees[$tree_cid])) { diff --git a/core/modules/book/tests/src/Unit/Menu/BookLocalTasksTest.php b/core/modules/book/tests/src/Unit/Menu/BookLocalTasksTest.php index 1702855..2e58f85 100644 --- a/core/modules/book/tests/src/Unit/Menu/BookLocalTasksTest.php +++ b/core/modules/book/tests/src/Unit/Menu/BookLocalTasksTest.php @@ -53,7 +53,7 @@ public function getBookAdminRoutes() { */ public function testBookNodeLocalTasks($route) { $this->assertLocalTasks($route, array( - 0 => array('entity.node.book_outline_form', 'entity.node.canonical', 'entity.node.edit_form', 'entity.node.delete_form', 'entity.node.version_history',), + 0 => array('book.outline', 'entity.node.canonical', 'entity.node.edit_form', 'entity.node.delete_form', 'entity.node.version_history',), )); } @@ -63,7 +63,7 @@ public function testBookNodeLocalTasks($route) { public function getBookNodeRoutes() { return array( array('entity.node.canonical'), - array('entity.node.book_outline_form'), + array('book.outline'), ); } diff --git a/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php index 0762728..6d92f98 100644 --- a/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php +++ b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php @@ -271,8 +271,8 @@ public function getJSSettings(EditorEntity $editor) { // Map the interface language code to a CKEditor translation. $ckeditor_langcodes = $this->getLangcodes(); $language_interface = $this->languageManager->getCurrentLanguage(); - if (isset($ckeditor_langcodes[$language_interface->getId()])) { - $display_langcode = $ckeditor_langcodes[$language_interface->getId()]; + if (isset($ckeditor_langcodes[$language_interface->id])) { + $display_langcode = $ckeditor_langcodes[$language_interface->id]; } // Next, set the most fundamental CKEditor settings. diff --git a/core/modules/comment/src/CommentForm.php b/core/modules/comment/src/CommentForm.php index 35e033d..5cf5d28 100644 --- a/core/modules/comment/src/CommentForm.php +++ b/core/modules/comment/src/CommentForm.php @@ -64,7 +64,7 @@ protected function init(FormStateInterface $form_state) { // set. if ($comment->isNew()) { $language_content = \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT); - $comment->langcode->value = $language_content->getId(); + $comment->langcode->value = $language_content->id; } parent::init($form_state); @@ -165,7 +165,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['langcode'] = array( '#title' => t('Language'), '#type' => 'language_select', - '#default_value' => $comment->getUntranslated()->language()->getId(), + '#default_value' => $comment->getUntranslated()->language()->id, '#languages' => Language::STATE_ALL, '#access' => isset($language_configuration['language_show']) && $language_configuration['language_show'], ); diff --git a/core/modules/comment/src/Tests/CommentTokenReplaceTest.php b/core/modules/comment/src/Tests/CommentTokenReplaceTest.php index c3699ae..76eca29 100644 --- a/core/modules/comment/src/Tests/CommentTokenReplaceTest.php +++ b/core/modules/comment/src/Tests/CommentTokenReplaceTest.php @@ -59,8 +59,8 @@ function testCommentTokenReplacement() { $tests['[comment:body]'] = $comment->comment_body->processed; $tests['[comment:url]'] = $comment->url('canonical', $url_options + array('fragment' => 'comment-' . $comment->id())); $tests['[comment:edit-url]'] = $comment->url('edit-form', $url_options); - $tests['[comment:created:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $comment->getCreatedTime(), 2, $language_interface->getId()); - $tests['[comment:changed:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $comment->getChangedTime(), 2, $language_interface->getId()); + $tests['[comment:created:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $comment->getCreatedTime(), 2, $language_interface->id); + $tests['[comment:changed:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $comment->getChangedTime(), 2, $language_interface->id); $tests['[comment:parent:cid]'] = $comment->hasParentComment() ? $comment->getParentComment()->id() : NULL; $tests['[comment:parent:title]'] = String::checkPlain($parent_comment->getSubject()); $tests['[comment:node:nid]'] = $comment->getCommentedEntityId(); @@ -72,7 +72,7 @@ function testCommentTokenReplacement() { $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->getId())); + $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->id)); $this->assertEqual($output, $expected, format_string('Sanitized comment token %token replaced.', array('%token' => $input))); } @@ -89,7 +89,7 @@ function testCommentTokenReplacement() { $tests['[comment:author:name]'] = $this->admin_user->getUsername(); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE)); + $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->id, 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized comment token %token replaced.', array('%token' => $input))); } @@ -105,7 +105,7 @@ function testCommentTokenReplacement() { $tests['[node:comment-count-new]'] = 2; foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('entity' => $node, 'node' => $node), array('langcode' => $language_interface->getId())); + $output = $token_service->replace($input, array('entity' => $node, 'node' => $node), array('langcode' => $language_interface->id)); $this->assertEqual($output, $expected, format_string('Node comment token %token replaced.', array('%token' => $input))); } } diff --git a/core/modules/comment/src/Tests/CommentTypeTest.php b/core/modules/comment/src/Tests/CommentTypeTest.php index 4a6d1b1..872d29b 100644 --- a/core/modules/comment/src/Tests/CommentTypeTest.php +++ b/core/modules/comment/src/Tests/CommentTypeTest.php @@ -74,7 +74,7 @@ public function testCommentTypeCreation() { $this->assertTrue($comment_type, 'The new comment type has been created.'); // Check that the comment type was created in site default language. - $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; $this->assertEqual($comment_type->language()->getId(), $default_langcode); // Edit the comment-type and ensure that we cannot change the entity-type. diff --git a/core/modules/config/src/Tests/ConfigEntityTest.php b/core/modules/config/src/Tests/ConfigEntityTest.php index 4bdbe25..0a896a0 100644 --- a/core/modules/config/src/Tests/ConfigEntityTest.php +++ b/core/modules/config/src/Tests/ConfigEntityTest.php @@ -37,7 +37,7 @@ class ConfigEntityTest extends WebTestBase { * Tests CRUD operations. */ function testCRUD() { - $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; // Verify default properties on a newly created empty entity. $empty = entity_create('config_test'); $this->assertTrue($empty->uuid()); diff --git a/core/modules/config/src/Tests/ConfigImportUITest.php b/core/modules/config/src/Tests/ConfigImportUITest.php index 2018716..d4c4c9d 100644 --- a/core/modules/config/src/Tests/ConfigImportUITest.php +++ b/core/modules/config/src/Tests/ConfigImportUITest.php @@ -51,7 +51,7 @@ function testImport() { // Create new config entity. $original_dynamic_data = array( 'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651', - 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(), + 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id, 'status' => TRUE, 'dependencies' => array(), 'id' => 'new', diff --git a/core/modules/config/src/Tests/ConfigImporterTest.php b/core/modules/config/src/Tests/ConfigImporterTest.php index eff180c..e5e760e 100644 --- a/core/modules/config/src/Tests/ConfigImporterTest.php +++ b/core/modules/config/src/Tests/ConfigImporterTest.php @@ -165,7 +165,7 @@ function testNew() { // Create new config entity. $original_dynamic_data = array( 'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651', - 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(), + 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id, 'status' => TRUE, 'dependencies' => array(), 'id' => 'new', diff --git a/core/modules/config/src/Tests/ConfigOverridesPriorityTest.php b/core/modules/config/src/Tests/ConfigOverridesPriorityTest.php index 3e6e288..71b3599 100644 --- a/core/modules/config/src/Tests/ConfigOverridesPriorityTest.php +++ b/core/modules/config/src/Tests/ConfigOverridesPriorityTest.php @@ -56,7 +56,7 @@ public function testOverridePriorities() { )); \Drupal::languageManager()->setConfigOverrideLanguage($language); \Drupal::languageManager() - ->getLanguageConfigOverride($language->getId(), 'system.site') + ->getLanguageConfigOverride($language->id, 'system.site') ->set('name', $language_overridden_name) ->set('mail', $language_overridden_mail) ->save(); diff --git a/core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php b/core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php index d7baae3..09f7fdc 100644 --- a/core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php +++ b/core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php @@ -33,7 +33,7 @@ public function access(Route $route, AccountInterface $account, $langcode = NULL $access = !empty($target_language) && !$target_language->isLocked() && - (empty($this->sourceLanguage) || ($target_language->getId() != $this->sourceLanguage->getId())); + (empty($this->sourceLanguage) || ($target_language->id != $this->sourceLanguage->id)); return $base_access->andIf(AccessResult::allowedIf($access)); } diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationController.php b/core/modules/config_translation/src/Controller/ConfigTranslationController.php index 73c87c3..b6b016c 100644 --- a/core/modules/config_translation/src/Controller/ConfigTranslationController.php +++ b/core/modules/config_translation/src/Controller/ConfigTranslationController.php @@ -153,7 +153,7 @@ public function itemPage(Request $request, RouteMatchInterface $route_match, $pl '#header' => array($this->t('Language'), $this->t('Operations')), ); foreach ($languages as $language) { - $langcode = $language->getId(); + $langcode = $language->id; // This is needed because // ConfigMapperInterface::getAddRouteParameters(), for example, diff --git a/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php b/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php index 217d219..d4c18a4 100644 --- a/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php +++ b/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php @@ -136,7 +136,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Request $ */ public function submitForm(array &$form, FormStateInterface $form_state) { foreach ($this->mapper->getConfigNames() as $name) { - $this->languageManager->getLanguageConfigOverride($this->language->getId(), $name)->delete(); + $this->languageManager->getLanguageConfigOverride($this->language->id, $name)->delete(); } // Flush all persistent caches. diff --git a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php index fefe5f8..d195d24 100644 --- a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php +++ b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php @@ -215,7 +215,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { foreach ($this->mapper->getConfigNames() as $name) { // Set configuration values based on form submission and source values. $base_config = $config_factory->get($name); - $config_translation = $this->languageManager->getLanguageConfigOverride($this->language->getId(), $name); + $config_translation = $this->languageManager->getLanguageConfigOverride($this->language->id, $name); $locations = $this->localeStorage->getLocations(array('type' => 'configuration', 'name' => $name)); $this->setConfig($this->language, $base_config, $config_translation, $form_values[$name], !empty($locations)); @@ -311,7 +311,7 @@ protected function buildConfigForm(Element $schema, $config_data, $base_config_d '#theme' => 'config_translation_manage_form_element', ); $build[$element_key]['source'] = array( - '#markup' => $base_config_data[$key] ? ('' . nl2br($base_config_data[$key] . '')) : t('(Empty)'), + '#markup' => $base_config_data[$key] ? ('' . nl2br($base_config_data[$key] . '')) : t('(Empty)'), '#title' => $this->t( '!label (!source_language)', array( @@ -377,7 +377,7 @@ protected function setConfig(LanguageInterface $language, Config $base_config, L // Get the translation for this original source string from locale. $conditions = array( 'lid' => $source_string->lid, - 'language' => $language->getId(), + 'language' => $language->id, ); $translations = $this->localeStorage->getTranslations($conditions + array('translated' => TRUE)); // If we got a translation, take that, otherwise create a new one. diff --git a/core/modules/config_translation/src/FormElement/DateFormat.php b/core/modules/config_translation/src/FormElement/DateFormat.php index 5b19e26..b19c66c 100644 --- a/core/modules/config_translation/src/FormElement/DateFormat.php +++ b/core/modules/config_translation/src/FormElement/DateFormat.php @@ -32,7 +32,7 @@ public function getFormElement(DataDefinitionInterface $definition, LanguageInte '#title' => $this->t($definition->getLabel()) . ' (' . $language->name . ')', '#description' => $description, '#default_value' => $value, - '#attributes' => array('lang' => $language->getId()), + '#attributes' => array('lang' => $language->id), '#field_suffix' => '
' . $format . '
', '#ajax' => array( 'callback' => 'Drupal\config_translation\FormElement\DateFormat::ajaxSample', diff --git a/core/modules/config_translation/src/FormElement/Textarea.php b/core/modules/config_translation/src/FormElement/Textarea.php index 05b18bb..e4692ec 100644 --- a/core/modules/config_translation/src/FormElement/Textarea.php +++ b/core/modules/config_translation/src/FormElement/Textarea.php @@ -31,7 +31,7 @@ public function getFormElement(DataDefinitionInterface $definition, LanguageInte '#default_value' => $value, '#title' => $this->t($definition->getLabel()) . ' (' . $language->name . ')', '#rows' => $rows, - '#attributes' => array('lang' => $language->getId()), + '#attributes' => array('lang' => $language->id), ); } diff --git a/core/modules/config_translation/src/FormElement/Textfield.php b/core/modules/config_translation/src/FormElement/Textfield.php index ccd7cc5..34759dc 100644 --- a/core/modules/config_translation/src/FormElement/Textfield.php +++ b/core/modules/config_translation/src/FormElement/Textfield.php @@ -25,7 +25,7 @@ public function getFormElement(DataDefinitionInterface $definition, LanguageInte '#type' => 'textfield', '#default_value' => $value, '#title' => $this->t($definition->getLabel()) . ' (' . $language->name . ')', - '#attributes' => array('lang' => $language->getId()), + '#attributes' => array('lang' => $language->id), ); } diff --git a/core/modules/contact/config/schema/contact.schema.yml b/core/modules/contact/config/schema/contact.schema.yml index 011ae37..7ebb6f4 100644 --- a/core/modules/contact/config/schema/contact.schema.yml +++ b/core/modules/contact/config/schema/contact.schema.yml @@ -22,11 +22,6 @@ contact.form.*: weight: type: integer label: 'Weight' - third_party_settings: - type: sequence - label: 'Third party settings' - sequence: - - type: contact_form.third_party.[%key] contact.settings: type: mapping diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index f6fc4cd..e9c3181 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -107,14 +107,14 @@ function contact_mail($key, &$message, $params) { $variables['!sender-url'] = $params['sender']->getEmail(); } - $options = array('langcode' => $language->getId()); + $options = array('langcode' => $language->id); switch ($key) { case 'page_mail': case 'page_copy': $message['subject'] .= t('[!form] !subject', $variables, $options); $message['body'][] = t("!sender-name (!sender-url) sent a message using the contact form at !form-url.", $variables, $options); - $build = entity_view($contact_message, 'mail', $language->getId()); + $build = entity_view($contact_message, 'mail', $language->id); $message['body'][] = drupal_render($build); break; @@ -133,7 +133,7 @@ function contact_mail($key, &$message, $params) { $message['body'][] = t('Hello !recipient-name,', $variables, $options); $message['body'][] = t("!sender-name (!sender-url) has sent you a message via your contact form at !site-name.", $variables, $options); $message['body'][] = t("If you don't want to receive such emails, you can change your settings at !recipient-edit-url.", $variables, $options); - $build = entity_view($contact_message, 'mail', $language->getId()); + $build = entity_view($contact_message, 'mail', $language->id); $message['body'][] = drupal_render($build); break; } diff --git a/core/modules/contact/src/ContactFormInterface.php b/core/modules/contact/src/ContactFormInterface.php index 6aeb6a6..abaea87 100644 --- a/core/modules/contact/src/ContactFormInterface.php +++ b/core/modules/contact/src/ContactFormInterface.php @@ -8,12 +8,11 @@ namespace Drupal\contact; use Drupal\Core\Config\Entity\ConfigEntityInterface; -use Drupal\Core\Config\Entity\ThirdPartySettingsInterface; /** * Provides an interface defining a contact form entity. */ -interface ContactFormInterface extends ConfigEntityInterface, ThirdPartySettingsInterface { +interface ContactFormInterface extends ConfigEntityInterface { /** * Returns list of recipient e-mail addresses. diff --git a/core/modules/contact/src/Entity/ContactForm.php b/core/modules/contact/src/Entity/ContactForm.php index 2dd7ce3..02abc13 100644 --- a/core/modules/contact/src/Entity/ContactForm.php +++ b/core/modules/contact/src/Entity/ContactForm.php @@ -9,7 +9,8 @@ use Drupal\Core\Config\Entity\ConfigEntityBundleBase; use Drupal\contact\ContactFormInterface; -use Drupal\Core\Config\Entity\ThirdPartySettingsTrait; +use Drupal\Core\Entity\EntityStorageControllerInterface; +use Drupal\contact\CategoryInterface; /** * Defines the contact form entity. @@ -41,8 +42,6 @@ */ class ContactForm extends ConfigEntityBundleBase implements ContactFormInterface { - use ThirdPartySettingsTrait; - /** * The form ID. * diff --git a/core/modules/contact/src/MessageForm.php b/core/modules/contact/src/MessageForm.php index 0e280cb..698fa8f 100644 --- a/core/modules/contact/src/MessageForm.php +++ b/core/modules/contact/src/MessageForm.php @@ -102,7 +102,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['langcode'] = array( '#title' => $this->t('Language'), '#type' => 'language_select', - '#default_value' => $message->getUntranslated()->language()->getId(), + '#default_value' => $message->getUntranslated()->language()->id, '#languages' => Language::STATE_ALL, '#access' => isset($language_configuration['language_show']) && $language_configuration['language_show'], ); @@ -217,7 +217,7 @@ protected function init(FormStateInterface $form_state) { // set. if ($message->isNew() && !$message->langcode->value) { $language_content = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT); - $message->langcode->value = $language_content->getId(); + $message->langcode->value = $language_content->id; } parent::init($form_state); diff --git a/core/modules/contact/src/Tests/ContactSitewideTest.php b/core/modules/contact/src/Tests/ContactSitewideTest.php index 7e6207f..4dd9a1e 100644 --- a/core/modules/contact/src/Tests/ContactSitewideTest.php +++ b/core/modules/contact/src/Tests/ContactSitewideTest.php @@ -118,7 +118,7 @@ function testSiteWideContact() { // Check that the form was created in site default language. $langcode = \Drupal::config('contact.form.' . $id)->get('langcode'); - $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; $this->assertEqual($langcode, $default_langcode); // Make sure the newly created form is included in the list of forms. @@ -331,17 +331,14 @@ function testAutoReply() { * form. * @param boolean $selected * A Boolean indicating whether the form should be selected by default. - * @param array $third_party_settings - * Array of third party settings to be added to the posted form data. */ - function addContactForm($id, $label, $recipients, $reply, $selected, $third_party_settings = []) { + function addContactForm($id, $label, $recipients, $reply, $selected) { $edit = array(); $edit['label'] = $label; $edit['id'] = $id; $edit['recipients'] = $recipients; $edit['reply'] = $reply; $edit['selected'] = ($selected ? TRUE : FALSE); - $edit += $third_party_settings; $this->drupalPostForm('admin/structure/contact/add', $edit, t('Save')); } diff --git a/core/modules/contact/src/Tests/ContactStorageTest.php b/core/modules/contact/src/Tests/ContactStorageTest.php index 4d1b73b..f444c0a 100644 --- a/core/modules/contact/src/Tests/ContactStorageTest.php +++ b/core/modules/contact/src/Tests/ContactStorageTest.php @@ -7,7 +7,6 @@ namespace Drupal\contact\Tests; -use Drupal\config\Tests\SchemaCheckTestTrait; use Drupal\contact\Entity\Message; /** @@ -15,8 +14,6 @@ */ class ContactStorageTest extends ContactSitewideTest { - use SchemaCheckTestTrait; - /** * Modules to enable. * @@ -52,9 +49,7 @@ public function testContactStorage() { $this->drupalLogin($admin_user); // Create first valid contact form. $mail = 'simpletest@example.com'; - $this->addContactForm($id = drupal_strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($mail)), '', TRUE, [ - 'send_a_pony' => 1, - ]); + $this->addContactForm($id = drupal_strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($mail)), '', TRUE); $this->assertRaw(t('Contact form %label has been added.', array('%label' => $label))); // Ensure that anonymous can submit site-wide contact form. @@ -70,14 +65,9 @@ public function testContactStorage() { /** @var \Drupal\contact\Entity\Message $message */ $message = reset($messages); $this->assertEqual($message->getContactForm()->id(), $id); - $this->assertTrue($message->getContactForm()->getThirdPartySetting('contact_storage_test', 'send_a_pony', FALSE)); $this->assertEqual($message->getSenderName(), $name); $this->assertEqual($message->getSubject(), $subject); $this->assertEqual($message->getSenderMail(), $mail); - - $config = \Drupal::config("contact.form.$id"); - $this->assertEqual($config->get('id'), $id); - $this->assertConfigSchema(\Drupal::service('config.typed'), $config->getName(), $config->get()); } } diff --git a/core/modules/contact/tests/modules/contact_storage_test/config/schema/contact_storage_test.schema.yml b/core/modules/contact/tests/modules/contact_storage_test/config/schema/contact_storage_test.schema.yml deleted file mode 100644 index e421214..0000000 --- a/core/modules/contact/tests/modules/contact_storage_test/config/schema/contact_storage_test.schema.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Schema for configuration files of the Contact Storage Test module. - -contact_form.third_party.contact_storage_test: - type: mapping - label: 'Per-contact form storage settings' - mapping: - send_a_pony: - type: boolean - label: 'Send a Pony' diff --git a/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module b/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module index 0ecfee5..116a326 100644 --- a/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module +++ b/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module @@ -5,9 +5,7 @@ * Contains custom contact message functionality for ContactStorageTest. */ -use Drupal\contact\ContactFormInterface; use Drupal\Core\Field\BaseFieldDefinition; -use Drupal\Core\Form\FormStateInterface; /** * Implements hook_entity_base_field_info(). @@ -40,26 +38,3 @@ function contact_storage_test_entity_type_alter(array &$entity_types) { $entity_types['contact_message']->set('entity_keys', $keys); $entity_types['contact_message']->set('base_table', 'contact_message'); } - -/** - * Implements hook_form_FORM_ID_alter() for contact_form_form(). - */ -function contact_storage_test_form_contact_form_form_alter(&$form, FormStateInterface $form_state) { - /** @var \Drupal\contact\ContactFormInterface $contact_form */ - $contact_form = $form_state->getFormObject()->getEntity(); - $form['send_a_pony'] = array( - '#type' => 'checkbox', - '#title' => t('Send submitters a voucher for a free pony.'), - '#description' => t('Enable to send an additional email with a free pony voucher to anyone who submits the form.'), - '#default_value' => $contact_form->getThirdPartySetting('contact_storage_test', 'send_a_pony', FALSE), - ); - $form['#entity_builders'][] = 'contact_storage_test_contact_form_form_builder'; -} -/** - * Entity builder for the contact form edit form with third party options. - * - * @see contact_storage_test_form_contact_form_edit_form_alter() - */ -function contact_storage_test_contact_form_form_builder($entity_type, ContactFormInterface $contact_form, &$form, FormStateInterface $form_state) { - $contact_form->setThirdPartySetting('contact_storage_test', 'send_a_pony', $form_state->getValue('send_a_pony')); -} diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 01f4221..f4e61a8 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -593,7 +593,7 @@ function content_translation_entity_presave(EntityInterface $entity) { // @todo Avoid using request attributes once translation metadata become // regular fields. $attributes = \Drupal::request()->attributes; - \Drupal::service('content_translation.synchronizer')->synchronizeFields($entity, $entity->language()->getId(), $attributes->get('source_langcode')); + \Drupal::service('content_translation.synchronizer')->synchronizeFields($entity, $entity->language()->id, $attributes->get('source_langcode')); } } @@ -749,7 +749,7 @@ function content_translation_page_alter(&$page) { $page['#attached']['html_head_link'][] = array( array( 'rel' => 'alternate', - 'hreflang' => $language->getId(), + 'hreflang' => $language->id, 'href' => $url, ), TRUE, diff --git a/core/modules/content_translation/src/ContentTranslationHandler.php b/core/modules/content_translation/src/ContentTranslationHandler.php index 90aa1c3..b619036 100644 --- a/core/modules/content_translation/src/ContentTranslationHandler.php +++ b/core/modules/content_translation/src/ContentTranslationHandler.php @@ -50,7 +50,7 @@ public function __construct(EntityTypeInterface $entity_type) { * {@inheritdoc} */ public function retranslate(EntityInterface $entity, $langcode = NULL) { - $updated_langcode = !empty($langcode) ? $langcode : $entity->language()->getId(); + $updated_langcode = !empty($langcode) ? $langcode : $entity->language()->id; $translations = $entity->getTranslationLanguages(); foreach ($translations as $langcode => $language) { $entity->translation[$langcode]['outdated'] = $langcode != $updated_langcode; @@ -79,7 +79,7 @@ public function getTranslationAccess(EntityInterface $entity, $op) { */ public function getSourceLangcode(FormStateInterface $form_state) { if ($source = $form_state->get(['content_translation', 'source'])) { - return $source->getId(); + return $source->id; } return FALSE; } @@ -90,7 +90,7 @@ public function getSourceLangcode(FormStateInterface $form_state) { public function entityFormAlter(array &$form, FormStateInterface $form_state, EntityInterface $entity) { $form_object = $form_state->getFormObject(); $form_langcode = $form_object->getFormLangcode($form_state); - $entity_langcode = $entity->getUntranslated()->language()->getId(); + $entity_langcode = $entity->getUntranslated()->language()->id; $source_langcode = $this->getSourceLangcode($form_state); $new_translation = !empty($source_langcode); @@ -138,8 +138,8 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En ), ); foreach (language_list(LanguageInterface::STATE_CONFIGURABLE) as $language) { - if (isset($translations[$language->getId()])) { - $form['source_langcode']['source']['#options'][$language->getId()] = $language->name; + if (isset($translations[$language->id])) { + $form['source_langcode']['source']['#options'][$language->id] = $language->name; } } } @@ -151,8 +151,8 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En if ($language_widget && $has_translations) { $form['langcode']['#options'] = array(); foreach (language_list(LanguageInterface::STATE_CONFIGURABLE) as $language) { - if (empty($translations[$language->getId()]) || $language->getId() == $entity_langcode) { - $form['langcode']['#options'][$language->getId()] = $language->name; + if (empty($translations[$language->id]) || $language->id == $entity_langcode) { + $form['langcode']['#options'][$language->id] = $language->name; } } } diff --git a/core/modules/content_translation/src/FieldTranslationSynchronizer.php b/core/modules/content_translation/src/FieldTranslationSynchronizer.php index 6b94671..6715577 100644 --- a/core/modules/content_translation/src/FieldTranslationSynchronizer.php +++ b/core/modules/content_translation/src/FieldTranslationSynchronizer.php @@ -51,7 +51,7 @@ public function synchronizeFields(ContentEntityInterface $entity, $sync_langcode // If the entity language is being changed there is nothing to synchronize. $entity_type = $entity->getEntityTypeId(); $entity_unchanged = isset($entity->original) ? $entity->original : $this->entityManager->getStorage($entity_type)->loadUnchanged($entity->id()); - if ($entity->getUntranslated()->language()->getId() != $entity_unchanged->getUntranslated()->language()->getId()) { + if ($entity->getUntranslated()->language()->id != $entity_unchanged->getUntranslated()->language()->id) { return; } diff --git a/core/modules/content_translation/src/Form/ContentTranslationDeleteForm.php b/core/modules/content_translation/src/Form/ContentTranslationDeleteForm.php index 9812a1a..b1a4580 100644 --- a/core/modules/content_translation/src/Form/ContentTranslationDeleteForm.php +++ b/core/modules/content_translation/src/Form/ContentTranslationDeleteForm.php @@ -73,14 +73,14 @@ public function getCancelUrl() { public function submitForm(array &$form, FormStateInterface $form_state) { // Remove the translated values. $this->entity = $this->entity->getUntranslated(); - $this->entity->removeTranslation($this->language->getId()); + $this->entity->removeTranslation($this->language->id); $this->entity->save(); // Remove any existing path alias for the removed translation. // @todo This should be taken care of by the Path module. if (\Drupal::moduleHandler()->moduleExists('path')) { $path = $this->entity->getSystemPath(); - $conditions = array('source' => $path, 'langcode' => $this->language->getId()); + $conditions = array('source' => $path, 'langcode' => $this->language->id); \Drupal::service('path.alias_storage')->delete($conditions); } diff --git a/core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php b/core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php index b8234b3..7aacd04 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php @@ -64,7 +64,7 @@ class ContentTranslationContextualLinksTest extends WebTestBase { protected function setUp() { parent::setUp(); // Set up an additional language. - $this->langcodes = array(language_default()->getId(), 'es'); + $this->langcodes = array(language_default()->id, 'es'); ConfigurableLanguage::createFromLangcode('es')->save(); // Create a content type. @@ -101,7 +101,7 @@ protected function setUp() { // Enable content translation. $configuration = array( - 'langcode' => language_default()->getId(), + 'langcode' => language_default()->id, 'language_show' => TRUE, ); language_save_default_configuration('node', $this->bundle, $configuration); diff --git a/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php b/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php index e52036b..3e14a6a 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php @@ -103,7 +103,7 @@ protected function setupLanguages() { foreach ($this->langcodes as $langcode) { ConfigurableLanguage::createFromLangcode($langcode)->save(); } - array_unshift($this->langcodes, \Drupal::languageManager()->getDefaultLanguage()->getId()); + array_unshift($this->langcodes, \Drupal::languageManager()->getDefaultLanguage()->id); } /** diff --git a/core/modules/entity_reference/src/Tests/EntityReferenceItemTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceItemTest.php index 4191d51..d34a6b2 100644 --- a/core/modules/entity_reference/src/Tests/EntityReferenceItemTest.php +++ b/core/modules/entity_reference/src/Tests/EntityReferenceItemTest.php @@ -168,25 +168,4 @@ public function testConfigEntityReferenceItem() { $entity->save(); } - /** - * Test saving order sequence doesn't matter. - */ - public function testEntitySaveOrder() { - // The term entity is unsaved here. - $term = entity_create('taxonomy_term', array( - 'name' => $this->randomMachineName(), - 'vid' => $this->term->bundle(), - 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, - )); - $entity = entity_create('entity_test'); - // Now assign the unsaved term to the field. - $entity->field_test_taxonomy_term->entity = $term; - $entity->name->value = $this->randomMachineName(); - // Now save the term. - $term->save(); - // And then the entity. - $entity->save(); - $this->assertEqual($entity->field_test_taxonomy_term->entity->id(), $term->id()); - } - } diff --git a/core/modules/field/src/Plugin/views/field/Field.php b/core/modules/field/src/Plugin/views/field/Field.php index 7c14b56..7780eff 100644 --- a/core/modules/field/src/Plugin/views/field/Field.php +++ b/core/modules/field/src/Plugin/views/field/Field.php @@ -930,7 +930,7 @@ function field_langcode(EntityInterface $entity) { // no data for the selected language. FieldItemListInterface::view() does // this as well, but since the returned language code is used before // calling it, the fallback needs to happen explicitly. - $langcode = $this->entityManager->getTranslationFromContext($entity, $langcode)->language()->getId(); + $langcode = $this->entityManager->getTranslationFromContext($entity, $langcode)->language()->id; return $langcode; } diff --git a/core/modules/field/src/Tests/TranslationTest.php b/core/modules/field/src/Tests/TranslationTest.php index 841ab39..6962155 100644 --- a/core/modules/field/src/Tests/TranslationTest.php +++ b/core/modules/field/src/Tests/TranslationTest.php @@ -167,7 +167,7 @@ function testTranslatableFieldSaveLoad() { // @todo Test every translation once the Entity Translation API allows for // multilingual defaults. - $langcode = $entity->language()->getId(); + $langcode = $entity->language()->id; $this->assertEqual($entity->getTranslation($langcode)->{$field_name_default}->getValue(), $field->default_value, format_string('Default value correctly populated for language %language.', array('%language' => $langcode))); // Check that explicit empty values are not overridden with default values. diff --git a/core/modules/field/tests/modules/field_test/field_test.module b/core/modules/field/tests/modules/field_test/field_test.module index d605ed0..1ee7755 100644 --- a/core/modules/field/tests/modules/field_test/field_test.module +++ b/core/modules/field/tests/modules/field_test/field_test.module @@ -92,7 +92,7 @@ function field_test_entity_display_build_alter(&$output, $context) { } if (isset($output['test_field'])) { - $output['test_field'][] = array('#markup' => 'entity language is ' . $context['entity']->language()->getId()); + $output['test_field'][] = array('#markup' => 'entity language is ' . $context['entity']->language()->id); } } diff --git a/core/modules/file/src/Tests/FileTokenReplaceTest.php b/core/modules/file/src/Tests/FileTokenReplaceTest.php index 450c778..36fe888 100644 --- a/core/modules/file/src/Tests/FileTokenReplaceTest.php +++ b/core/modules/file/src/Tests/FileTokenReplaceTest.php @@ -48,10 +48,10 @@ function testFileTokenReplacement() { $tests['[file:mime]'] = String::checkPlain($file->getMimeType()); $tests['[file:size]'] = format_size($file->getSize()); $tests['[file:url]'] = String::checkPlain(file_create_url($file->getFileUri())); - $tests['[file:created]'] = format_date($file->getCreatedTime(), 'medium', '', NULL, $language_interface->getId()); - $tests['[file:created:short]'] = format_date($file->getCreatedTime(), 'short', '', NULL, $language_interface->getId()); - $tests['[file:changed]'] = format_date($file->getChangedTime(), 'medium', '', NULL, $language_interface->getId()); - $tests['[file:changed:short]'] = format_date($file->getChangedTime(), 'short', '', NULL, $language_interface->getId()); + $tests['[file:created]'] = format_date($file->getCreatedTime(), 'medium', '', NULL, $language_interface->id); + $tests['[file:created:short]'] = format_date($file->getCreatedTime(), 'short', '', NULL, $language_interface->id); + $tests['[file:changed]'] = format_date($file->getChangedTime(), 'medium', '', NULL, $language_interface->id); + $tests['[file:changed:short]'] = format_date($file->getChangedTime(), 'short', '', NULL, $language_interface->id); $tests['[file:owner]'] = String::checkPlain(user_format_name($this->admin_user)); $tests['[file:owner:uid]'] = $file->getOwnerId(); @@ -59,7 +59,7 @@ function testFileTokenReplacement() { $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->getId())); + $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->id)); $this->assertEqual($output, $expected, format_string('Sanitized file token %token replaced.', array('%token' => $input))); } @@ -70,7 +70,7 @@ function testFileTokenReplacement() { $tests['[file:size]'] = format_size($file->getSize()); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE)); + $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->id, 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized file token %token replaced.', array('%token' => $input))); } } diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index d4a2253..cfce4fa 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -102,13 +102,13 @@ function filter_formats(AccountInterface $account = NULL) { // All available formats are cached for performance. if (!isset($formats['all'])) { $language_interface = \Drupal::languageManager()->getCurrentLanguage(); - if ($cache = \Drupal::cache()->get("filter_formats:{$language_interface->getId()}")) { + if ($cache = \Drupal::cache()->get("filter_formats:{$language_interface->id}")) { $formats['all'] = $cache->data; } else { $formats['all'] = \Drupal::entityManager()->getStorage('filter_format')->loadByProperties(array('status' => TRUE)); uasort($formats['all'], 'Drupal\Core\Config\Entity\ConfigEntityBase::sort'); - \Drupal::cache()->set("filter_formats:{$language_interface->getId()}", $formats['all'], Cache::PERMANENT, \Drupal::entityManager()->getDefinition('filter_format')->getListCacheTags()); + \Drupal::cache()->set("filter_formats:{$language_interface->id}", $formats['all'], Cache::PERMANENT, \Drupal::entityManager()->getDefinition('filter_format')->getListCacheTags()); } } diff --git a/core/modules/filter/src/Tests/FilterCrudTest.php b/core/modules/filter/src/Tests/FilterCrudTest.php index 37d1232..75bf568 100644 --- a/core/modules/filter/src/Tests/FilterCrudTest.php +++ b/core/modules/filter/src/Tests/FilterCrudTest.php @@ -78,7 +78,7 @@ function testTextFormatCrud() { */ function verifyTextFormat($format) { $t_args = array('%format' => $format->name); - $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; // Verify the loaded filter has all properties. $filter_format = entity_load('filter_format', $format->format); diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 0d36992..b744c0f 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -137,9 +137,8 @@ function forum_entity_type_build(array &$entity_types) { $entity_types['taxonomy_term'] ->setFormClass('forum', 'Drupal\forum\Form\ForumForm') ->setFormClass('container', 'Drupal\forum\Form\ContainerForm') - ->setLinkTemplate('forum-delete-form', 'entity.taxonomy_term.forum_delete_form') - ->setLinkTemplate('forum-edit-container-form', 'entity.taxonomy_term.forum_edit_container_form') - ->setLinkTemplate('forum-edit-form', 'entity.taxonomy_term.forum_edit_form'); + ->setLinkTemplate('forum-delete-form', 'forum.delete') + ->setLinkTemplate('forum-edit-form', 'forum.edit_forum'); } /** diff --git a/core/modules/forum/forum.routing.yml b/core/modules/forum/forum.routing.yml index c61184e..aa21336 100644 --- a/core/modules/forum/forum.routing.yml +++ b/core/modules/forum/forum.routing.yml @@ -1,4 +1,4 @@ -entity.taxonomy_term.forum_delete_form: +forum.delete: path: '/admin/structure/forum/delete/forum/{taxonomy_term}' defaults: _form: '\Drupal\forum\Form\DeleteForm' @@ -46,7 +46,7 @@ forum.add_forum: requirements: _permission: 'administer forums' -entity.taxonomy_term.forum_edit_container_form: +forum.edit_container: path: '/admin/structure/forum/edit/container/{taxonomy_term}' defaults: _entity_form: 'taxonomy_term.container' @@ -54,7 +54,7 @@ entity.taxonomy_term.forum_edit_container_form: requirements: _permission: 'administer forums' -entity.taxonomy_term.forum_edit_form: +forum.edit_forum: path: '/admin/structure/forum/edit/forum/{taxonomy_term}' defaults: _entity_form: 'taxonomy_term.forum' diff --git a/core/modules/forum/src/Form/ForumForm.php b/core/modules/forum/src/Form/ForumForm.php index 4641781..fc51a32 100644 --- a/core/modules/forum/src/Form/ForumForm.php +++ b/core/modules/forum/src/Form/ForumForm.php @@ -80,7 +80,7 @@ public function save(array $form, FormStateInterface $form_state) { $term_storage = $this->entityManager->getStorage('taxonomy_term'); $status = $term_storage->save($term); - $route_name = $this->urlStub == 'container' ? 'entity.taxonomy_term.forum_edit_container_form' : 'entity.taxonomy_term.forum_edit_form'; + $route_name = $this->urlStub == 'container' ? 'forum.edit_container' : 'forum.edit_forum'; $route_parameters = ['taxonomy_term' => $term->id()]; $link = $this->l($this->t('Edit'), new Url($route_name, $route_parameters)); switch ($status) { diff --git a/core/modules/forum/src/Form/Overview.php b/core/modules/forum/src/Form/Overview.php index 24f5142..8469f55 100644 --- a/core/modules/forum/src/Form/Overview.php +++ b/core/modules/forum/src/Form/Overview.php @@ -71,11 +71,11 @@ public function buildForm(array $form, FormStateInterface $form_state) { $route_parameters = $form['terms'][$key]['operations']['#links']['edit']['url']->getRouteParameters(); if (!empty($term->forum_container->value)) { $form['terms'][$key]['operations']['#links']['edit']['title'] = $this->t('edit container'); - $form['terms'][$key]['operations']['#links']['edit']['url'] = Url::fromRoute('entity.taxonomy_term.forum_edit_container_form', $route_parameters); + $form['terms'][$key]['operations']['#links']['edit']['url'] = Url::fromRoute('forum.edit_container', $route_parameters); } else { $form['terms'][$key]['operations']['#links']['edit']['title'] = $this->t('edit forum'); - $form['terms'][$key]['operations']['#links']['edit']['url'] = Url::fromRoute('entity.taxonomy_term.forum_edit_form', $route_parameters); + $form['terms'][$key]['operations']['#links']['edit']['url'] = Url::fromRoute('forum.edit_forum', $route_parameters); } // We don't want the redirect from the link so we can redirect the // delete action. diff --git a/core/modules/forum/src/Tests/ForumTest.php b/core/modules/forum/src/Tests/ForumTest.php index 8ebdb81..adbd2a4 100644 --- a/core/modules/forum/src/Tests/ForumTest.php +++ b/core/modules/forum/src/Tests/ForumTest.php @@ -297,7 +297,7 @@ private function doAdminTests($user) { 'name' => 'Tags', 'description' => $description, 'vid' => 'tags', - 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(), + 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id, 'help' => $help, )); $vocabulary->save(); diff --git a/core/modules/forum/src/Tests/ForumUninstallTest.php b/core/modules/forum/src/Tests/ForumUninstallTest.php index eb57a5d..388910c 100644 --- a/core/modules/forum/src/Tests/ForumUninstallTest.php +++ b/core/modules/forum/src/Tests/ForumUninstallTest.php @@ -37,7 +37,7 @@ function testForumUninstallWithField() { // Create a taxonomy term. $term = entity_create('taxonomy_term', array( 'name' => t('A term'), - 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(), + 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->id, 'description' => '', 'parent' => array(0), 'vid' => 'forums', diff --git a/core/modules/hal/src/Normalizer/FieldNormalizer.php b/core/modules/hal/src/Normalizer/FieldNormalizer.php index fd2851b..99a669c 100644 --- a/core/modules/hal/src/Normalizer/FieldNormalizer.php +++ b/core/modules/hal/src/Normalizer/FieldNormalizer.php @@ -43,8 +43,8 @@ public function normalize($field, $format = NULL, array $context = array()) { // to the field item values. else { foreach ($entity->getTranslationLanguages() as $language) { - $context['langcode'] = $language->getId(); - $translation = $entity->getTranslation($language->getId()); + $context['langcode'] = $language->id; + $translation = $entity->getTranslation($language->id); $translated_field = $translation->get($field_name); $normalized_field_items = array_merge($normalized_field_items, $this->normalizeFieldItems($translated_field, $format, $context)); } diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 55b9920..676dfb7 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -286,11 +286,11 @@ function language_get_default_langcode($entity_type, $bundle) { $language_interface = \Drupal::languageManager()->getCurrentLanguage(); switch ($configuration['langcode']) { case LanguageInterface::LANGCODE_SITE_DEFAULT: - $default_value = \Drupal::languageManager()->getDefaultLanguage()->getId(); + $default_value = \Drupal::languageManager()->getDefaultLanguage()->id; break; case 'current_interface': - $default_value = $language_interface->getId(); + $default_value = $language_interface->id; break; case 'authors_default': @@ -300,7 +300,7 @@ function language_get_default_langcode($entity_type, $bundle) { $default_value = $language_code; } else { - $default_value = $language_interface->getId(); + $default_value = $language_interface->id; } break; } @@ -365,7 +365,7 @@ function language_negotiation_url_prefixes_update() { if (empty($prefixes[$language->getId()])) { // For the default language, set the prefix to the empty string, // otherwise use the langcode. - $prefixes[$language->getId()] = $language->isDefault() ? '' : $language->getId(); + $prefixes[$language->getId()] = $language->isDefault() ? '' : $language->id; } // Otherwise we keep the configured prefix. } @@ -495,7 +495,7 @@ function language_form_system_regional_settings_alter(&$form, FormStateInterface $form['locale']['site_default_language'] = array( '#type' => 'select', '#title' => t('Default language'), - '#default_value' => $default->getId(), + '#default_value' => $default->id, '#options' => $language_options, '#description' => t('It is not recommended to change the default language on a working site. Configure the Selected language setting on the detection and selection page to change the fallback language for language selection.', array('@language-detection' => \Drupal::url('language.negotiation'))), '#weight' => -1, diff --git a/core/modules/language/src/Config/LanguageConfigFactoryOverride.php b/core/modules/language/src/Config/LanguageConfigFactoryOverride.php index a0fbbfe..24c4bf5 100644 --- a/core/modules/language/src/Config/LanguageConfigFactoryOverride.php +++ b/core/modules/language/src/Config/LanguageConfigFactoryOverride.php @@ -116,7 +116,7 @@ public function getStorage($langcode) { * {@inheritdoc} */ public function getCacheSuffix() { - return $this->language ? $this->language->getId() : NULL; + return $this->language ? $this->language->id : NULL; } /** diff --git a/core/modules/language/src/ConfigurableLanguageManager.php b/core/modules/language/src/ConfigurableLanguageManager.php index d6d5075..15c40ae 100644 --- a/core/modules/language/src/ConfigurableLanguageManager.php +++ b/core/modules/language/src/ConfigurableLanguageManager.php @@ -283,7 +283,7 @@ public function getLanguages($flags = LanguageInterface::STATE_CONFIGURABLE) { // Prepopulate the language list with the default language to keep things // working even if we have no configuration. $default = $this->getDefaultLanguage(); - $this->languages = array($default->getId() => $default); + $this->languages = array($default->id => $default); // Retrieve the list of languages defined in configuration. $prefix = 'language.entity.'; @@ -296,7 +296,7 @@ public function getLanguages($flags = LanguageInterface::STATE_CONFIGURABLE) { $langcode = $data['id']; // Initialize default property so callers have an easy reference and can // save the same object without data loss. - $data['default'] = ($langcode == $default->getId()); + $data['default'] = ($langcode == $default->id); $data['name'] = $data['label']; $this->languages[$langcode] = new Language($data); $weight = max(array($weight, $this->languages[$langcode]->getWeight())); @@ -338,14 +338,14 @@ public function updateLockedLanguageWeights() { // Get maximum weight to update the system languages to keep them on bottom. foreach ($this->getLanguages(LanguageInterface::STATE_CONFIGURABLE) as $language) { - if (!$language->isLocked()) { - $max_weight = max($max_weight, $language->getWeight()); + if (!$language->isLocked() && $language->getWeight() > $max_weight) { + $max_weight = $language->getWeight(); } } // Loop locked languages to maintain the existing order. $locked_languages = $this->getLanguages(LanguageInterface::STATE_LOCKED); - $config_ids = array_map(function($language) { return 'language.entity.' . $language->getId(); }, $locked_languages); + $config_ids = array_map(function($language) { return 'language.entity.' . $language->id; }, $locked_languages); foreach ($this->configFactory->loadMultiple($config_ids) as $config) { // Update system languages weight. $max_weight++; diff --git a/core/modules/language/src/Entity/ConfigurableLanguage.php b/core/modules/language/src/Entity/ConfigurableLanguage.php index 668a9aa..f6b0341 100644 --- a/core/modules/language/src/Entity/ConfigurableLanguage.php +++ b/core/modules/language/src/Entity/ConfigurableLanguage.php @@ -50,7 +50,7 @@ class ConfigurableLanguage extends ConfigEntityBase implements ConfigurableLangu * * @var string */ - protected $id; + public $id; /** * The human-readable label for the language. diff --git a/core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php b/core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php index c3218ff..c543fc7 100644 --- a/core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php +++ b/core/modules/language/src/EventSubscriber/LanguageRequestSubscriber.php @@ -85,7 +85,7 @@ public function onKernelRequestLanguage(GetResponseEvent $event) { } // After the language manager has initialized, set the default langcode // for the string translations. - $langcode = $this->languageManager->getCurrentLanguage()->getId(); + $langcode = $this->languageManager->getCurrentLanguage()->id; $this->translation->setDefaultLangcode($langcode); } } diff --git a/core/modules/language/src/Form/LanguageDeleteForm.php b/core/modules/language/src/Form/LanguageDeleteForm.php index 32fb889..5b1d2f6 100644 --- a/core/modules/language/src/Form/LanguageDeleteForm.php +++ b/core/modules/language/src/Form/LanguageDeleteForm.php @@ -89,7 +89,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $langcode = $this->entity->id(); // Warn and redirect user when attempting to delete the default language. - if (language_default()->getId() == $langcode) { + if (language_default()->id == $langcode) { drupal_set_message($this->t('The default language cannot be deleted.')); $url = $this->urlGenerator->generateFromPath('admin/config/regional/language', array('absolute' => TRUE)); return new RedirectResponse($url); diff --git a/core/modules/language/src/Form/LanguageFormBase.php b/core/modules/language/src/Form/LanguageFormBase.php index cfb3c3f..59ae4a2 100644 --- a/core/modules/language/src/Form/LanguageFormBase.php +++ b/core/modules/language/src/Form/LanguageFormBase.php @@ -51,7 +51,7 @@ public static function create(ContainerInterface $container) { public function commonForm(array &$form) { /* @var $language \Drupal\language\ConfigurableLanguageInterface */ $language = $this->entity; - if ($language->getId()) { + if ($language->id()) { $form['langcode_view'] = array( '#type' => 'item', '#title' => $this->t('Language code'), diff --git a/core/modules/language/src/Form/NegotiationUrlForm.php b/core/modules/language/src/Form/NegotiationUrlForm.php index 0b3735f..eed7a38 100644 --- a/core/modules/language/src/Form/NegotiationUrlForm.php +++ b/core/modules/language/src/Form/NegotiationUrlForm.php @@ -73,7 +73,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $prefixes = language_negotiation_url_prefixes(); $domains = language_negotiation_url_domains(); foreach ($languages as $langcode => $language) { - $t_args = array('%language' => $language->name, '%langcode' => $language->getId()); + $t_args = array('%language' => $language->name, '%langcode' => $language->id); $form['prefix'][$langcode] = array( '#type' => 'textfield', '#title' => $language->isDefault() ? $this->t('%language (%langcode) path prefix (Default language)', $t_args) : $this->t('%language (%langcode) path prefix', $t_args), @@ -83,7 +83,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ); $form['domain'][$langcode] = array( '#type' => 'textfield', - '#title' => $this->t('%language (%langcode) domain', array('%language' => $language->name, '%langcode' => $language->getId())), + '#title' => $this->t('%language (%langcode) domain', array('%language' => $language->name, '%langcode' => $language->id)), '#maxlength' => 128, '#default_value' => isset($domains[$langcode]) ? $domains[$langcode] : '', ); diff --git a/core/modules/language/src/LanguageListBuilder.php b/core/modules/language/src/LanguageListBuilder.php index 42ec9d3..c8dbe13 100644 --- a/core/modules/language/src/LanguageListBuilder.php +++ b/core/modules/language/src/LanguageListBuilder.php @@ -50,7 +50,7 @@ public function getDefaultOperations(EntityInterface $entity) { $default = language_default(); // Deleting the site default language is not allowed. - if ($entity->id() == $default->getId()) { + if ($entity->id() == $default->id) { unset($operations['delete']); } diff --git a/core/modules/language/src/LanguageNegotiatorInterface.php b/core/modules/language/src/LanguageNegotiatorInterface.php index dc4d1e5..fa46958 100644 --- a/core/modules/language/src/LanguageNegotiatorInterface.php +++ b/core/modules/language/src/LanguageNegotiatorInterface.php @@ -90,7 +90,7 @@ * // If we are on an administrative path, override with the default * language. * if ($request->query->has('q') && strtok($request->query->get('q'), '/') == 'admin') { - * return $this->languageManager->getDefaultLanguage()->getId(); + * return $this->languageManager->getDefaultLanguage()->id; * } * return $langcode; * } diff --git a/core/modules/language/src/Plugin/Condition/Language.php b/core/modules/language/src/Plugin/Condition/Language.php index 07095e1..523c3df 100644 --- a/core/modules/language/src/Plugin/Condition/Language.php +++ b/core/modules/language/src/Plugin/Condition/Language.php @@ -34,7 +34,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $languages = language_list(LanguageInterface::STATE_CONFIGURABLE); $langcodes_options = array(); foreach ($languages as $language) { - $langcodes_options[$language->getId()] = $language->getName(); + $langcodes_options[$language->id] = $language->getName(); } $form['langcodes'] = array( '#type' => 'checkboxes', @@ -71,8 +71,8 @@ public function summary() { $language_names = array_reduce($language_list, function(&$result, $item) use ($selected) { // If the current item of the $language_list array is one of the selected // languages, add it to the $results array. - if (!empty($selected[$item->getId()])) { - $result[$item->getId()] = $item->name; + if (!empty($selected[$item->id])) { + $result[$item->id] = $item->name; } return $result; }, array()); @@ -101,7 +101,7 @@ public function evaluate() { $language = $this->getContextValue('language'); // Language visibility settings. - return !empty($this->configuration['langcodes'][$language->getId()]); + return !empty($this->configuration['langcodes'][$language->id]); } /** diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php index a1547c0..7f0085d 100644 --- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php +++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php @@ -72,7 +72,7 @@ public function getLangcode(Request $request = NULL) { public function persist(LanguageInterface $language) { // We need to update the session parameter with the request value only if we // have an authenticated user. - $langcode = $language->getId(); + $langcode = $language->id; if ($langcode && $this->languageManager) { $languages = $this->languageManager->getLanguages(); if ($this->currentUser->isAuthenticated() && isset($languages[$langcode])) { @@ -126,12 +126,12 @@ public function getLanguageSwitchLinks(Request $request, $type, Url $url) { $links = array(); $config = $this->config->get('language.negotiation')->get('session'); $param = $config['parameter']; - $language_query = isset($_SESSION[$param]) ? $_SESSION[$param] : $this->languageManager->getCurrentLanguage($type)->getId(); + $language_query = isset($_SESSION[$param]) ? $_SESSION[$param] : $this->languageManager->getCurrentLanguage($type)->id; $query = array(); parse_str($request->getQueryString(), $query); foreach ($this->languageManager->getNativeLanguages() as $language) { - $langcode = $language->getId(); + $langcode = $language->id; $links[$langcode] = array( 'url' => $url, 'title' => $language->getName(), diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php index fd7eb75..a96dcbd 100644 --- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php +++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUI.php @@ -32,7 +32,7 @@ class LanguageNegotiationUI extends LanguageNegotiationMethodBase { * {@inheritdoc} */ public function getLangcode(Request $request = NULL) { - return $this->languageManager ? $this->languageManager->getCurrentLanguage()->getId() : NULL; + return $this->languageManager ? $this->languageManager->getCurrentLanguage()->id : NULL; } } diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php index d84bee4..0b467270 100644 --- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php +++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrl.php @@ -65,14 +65,14 @@ public function getLangcode(Request $request = NULL) { // Search prefix within added languages. $negotiated_language = FALSE; foreach ($languages as $language) { - if (isset($config['prefixes'][$language->getId()]) && $config['prefixes'][$language->getId()] == $prefix) { + if (isset($config['prefixes'][$language->id]) && $config['prefixes'][$language->id] == $prefix) { $negotiated_language = $language; break; } } if ($negotiated_language) { - $langcode = $negotiated_language->getId(); + $langcode = $negotiated_language->id; } break; @@ -81,13 +81,13 @@ public function getLangcode(Request $request = NULL) { $http_host = $request->getHost(); foreach ($languages as $language) { // Skip the check if the language doesn't have a domain. - if (!empty($config['domains'][$language->getId()])) { + if (!empty($config['domains'][$language->id])) { // Ensure that there is exactly one protocol in the URL when // checking the hostname. - $host = 'http://' . str_replace(array('http://', 'https://'), '', $config['domains'][$language->getId()]); + $host = 'http://' . str_replace(array('http://', 'https://'), '', $config['domains'][$language->id]); $host = parse_url($host, PHP_URL_HOST); if ($http_host == $host) { - $langcode = $language->getId(); + $langcode = $language->id; break; } } @@ -109,7 +109,7 @@ public function processInbound($path, Request $request) { // Search prefix within added languages. foreach ($this->languageManager->getLanguages() as $language) { - if (isset($config['prefixes'][$language->getId()]) && $config['prefixes'][$language->getId()] == $prefix) { + if (isset($config['prefixes'][$language->id]) && $config['prefixes'][$language->id] == $prefix) { // Rebuild $path with the language removed. $path = implode('/', $parts); break; @@ -136,17 +136,17 @@ public function processOutbound($path, &$options = array(), Request $request = N $options['language'] = $language_url; } // We allow only added languages here. - elseif (!is_object($options['language']) || !isset($languages[$options['language']->getId()])) { + elseif (!is_object($options['language']) || !isset($languages[$options['language']->id])) { return $path; } $config = $this->config->get('language.negotiation')->get('url'); if ($config['source'] == LanguageNegotiationUrl::CONFIG_PATH_PREFIX) { - if (is_object($options['language']) && !empty($config['prefixes'][$options['language']->getId()])) { - $options['prefix'] = $config['prefixes'][$options['language']->getId()] . '/'; + if (is_object($options['language']) && !empty($config['prefixes'][$options['language']->id])) { + $options['prefix'] = $config['prefixes'][$options['language']->id] . '/'; } } elseif ($config['source'] == LanguageNegotiationUrl::CONFIG_DOMAIN) { - if (is_object($options['language']) && !empty($config['domains'][$options['language']->getId()])) { + if (is_object($options['language']) && !empty($config['domains'][$options['language']->id])) { // Save the original base URL. If it contains a port, we need to // retain it below. @@ -157,7 +157,7 @@ public function processOutbound($path, &$options = array(), Request $request = N // Ask for an absolute URL with our modified base URL. $options['absolute'] = TRUE; - $options['base_url'] = $url_scheme . '://' . $config['domains'][$options['language']->getId()]; + $options['base_url'] = $url_scheme . '://' . $config['domains'][$options['language']->id]; // In case either the original base URL or the HTTP host contains a // port, retain it. @@ -192,7 +192,7 @@ public function getLanguageSwitchLinks(Request $request, $type, Url $url) { $links = array(); foreach ($this->languageManager->getNativeLanguages() as $language) { - $links[$language->getId()] = array( + $links[$language->id] = array( 'url' => $url, 'title' => $language->getName(), 'language' => $language, diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrlFallback.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrlFallback.php index abaa6e3..6f771e8 100644 --- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrlFallback.php +++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationUrlFallback.php @@ -62,11 +62,11 @@ public function getLangcode(Request $request = NULL) { // information, a missing URL language information indicates that URL // language should be the default one, otherwise we fall back to an // already detected language. - if (($prefix && empty($config['prefixes'][$default->getId()])) || (!$prefix && empty($config['domains'][$default->getId()]))) { - $langcode = $default->getId(); + if (($prefix && empty($config['prefixes'][$default->id])) || (!$prefix && empty($config['domains'][$default->id]))) { + $langcode = $default->id; } else { - $langcode = $this->languageManager->getCurrentLanguage()->getId(); + $langcode = $this->languageManager->getCurrentLanguage()->id; } } diff --git a/core/modules/language/src/Tests/LanguageConfigurationElementTest.php b/core/modules/language/src/Tests/LanguageConfigurationElementTest.php index 9b2d82d..f733bf8 100644 --- a/core/modules/language/src/Tests/LanguageConfigurationElementTest.php +++ b/core/modules/language/src/Tests/LanguageConfigurationElementTest.php @@ -78,7 +78,7 @@ public function testDefaultLangcode() { language_save_default_configuration('custom_type', 'custom_bundle', array('langcode' => 'current_interface', 'language_show' => TRUE)); $langcode = language_get_default_langcode('custom_type', 'custom_bundle'); $language_interface = \Drupal::languageManager()->getCurrentLanguage(); - $this->assertEqual($langcode, $language_interface->getId()); + $this->assertEqual($langcode, $language_interface->id); // Site's default. $old_default = \Drupal::languageManager()->getDefaultLanguage(); diff --git a/core/modules/language/src/Tests/LanguageConfigurationTest.php b/core/modules/language/src/Tests/LanguageConfigurationTest.php index 61edf4e..ce8c7cf 100644 --- a/core/modules/language/src/Tests/LanguageConfigurationTest.php +++ b/core/modules/language/src/Tests/LanguageConfigurationTest.php @@ -173,8 +173,8 @@ protected function getHighestConfigurableLanguageWeight(){ /* @var $languages \Drupal\Core\Language\LanguageInterface[] */ $languages = entity_load_multiple('configurable_language', NULL, TRUE); foreach ($languages as $language) { - if (!$language->isLocked()) { - $max_weight = max($max_weight, $language->getWeight()); + if (!$language->isLocked() && $language->getWeight() > $max_weight) { + $max_weight = $language->getWeight(); } } diff --git a/core/modules/language/src/Tests/LanguageDependencyInjectionTest.php b/core/modules/language/src/Tests/LanguageDependencyInjectionTest.php index b6fc729..70b0d69 100644 --- a/core/modules/language/src/Tests/LanguageDependencyInjectionTest.php +++ b/core/modules/language/src/Tests/LanguageDependencyInjectionTest.php @@ -48,7 +48,7 @@ function testDependencyInjectedNewDefaultLanguage() { // The language system creates a Language object which contains the // same properties as the new default language object. $result = \Drupal::languageManager()->getCurrentLanguage(); - $this->assertIdentical($result->getId(), 'fr'); + $this->assertIdentical($result->id, 'fr'); // Delete the language to check that we fallback to the default. try { @@ -64,7 +64,7 @@ function testDependencyInjectedNewDefaultLanguage() { entity_delete_multiple('configurable_language', array('fr')); $result = \Drupal::languageManager()->getCurrentLanguage(); - $this->assertIdentical($result->getId(), $default_language->getId()); + $this->assertIdentical($result->id, $default_language->id); } } diff --git a/core/modules/language/src/Tests/LanguagePathMonolingualTest.php b/core/modules/language/src/Tests/LanguagePathMonolingualTest.php index c574f91..d6342e5 100644 --- a/core/modules/language/src/Tests/LanguagePathMonolingualTest.php +++ b/core/modules/language/src/Tests/LanguagePathMonolingualTest.php @@ -51,7 +51,7 @@ protected function setUp() { // Verify that French is the only language. $this->container->get('language_manager')->reset(); $this->assertFalse(\Drupal::languageManager()->isMultilingual(), 'Site is mono-lingual'); - $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), 'fr', 'French is the default language'); + $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->id, 'fr', 'French is the default language'); // Set language detection to URL. $edit = array('language_interface[enabled][language-url]' => TRUE); diff --git a/core/modules/language/src/Tests/LanguageUrlRewritingTest.php b/core/modules/language/src/Tests/LanguageUrlRewritingTest.php index 434f864..2876ab6 100644 --- a/core/modules/language/src/Tests/LanguageUrlRewritingTest.php +++ b/core/modules/language/src/Tests/LanguageUrlRewritingTest.php @@ -85,7 +85,7 @@ private function checkUrl($language, $message1, $message2) { // If the rewritten URL has not a language prefix we pick a random prefix so // we can always check the prefixed URL. $prefixes = language_negotiation_url_prefixes(); - $stored_prefix = isset($prefixes[$language->getId()]) ? $prefixes[$language->getId()] : $this->randomMachineName(); + $stored_prefix = isset($prefixes[$language->id]) ? $prefixes[$language->id] : $this->randomMachineName(); if ($this->assertNotEqual($stored_prefix, $prefix, $message1)) { $prefix = $stored_prefix; } diff --git a/core/modules/language/tests/language_test/language_test.module b/core/modules/language/tests/language_test/language_test.module index aeb630e..6e81581 100644 --- a/core/modules/language/tests/language_test/language_test.module +++ b/core/modules/language/tests/language_test/language_test.module @@ -68,7 +68,7 @@ function language_test_language_negotiation_info_alter(array &$negotiation_info) function language_test_store_language_negotiation() { $last = array(); foreach (\Drupal::languageManager()->getDefinedLanguageTypes() as $type) { - $last[$type] = \Drupal::languageManager()->getCurrentLanguage($type)->getId(); + $last[$type] = \Drupal::languageManager()->getCurrentLanguage($type)->id; } \Drupal::state()->set('language_test.language_negotiation_last', $last); } diff --git a/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php b/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php index bf62cf7..7f2684b 100644 --- a/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php +++ b/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php @@ -27,17 +27,13 @@ class LanguageNegotiationUrlTest extends UnitTestCase { protected function setUp() { // Set up some languages to be used by the language-based path processor. - $language_de = $this->getMock('\Drupal\Core\Language\LanguageInterface'); - $language_de->expects($this->any()) - ->method('getId') - ->will($this->returnValue('de')); - $language_en = $this->getMock('\Drupal\Core\Language\LanguageInterface'); - $language_en->expects($this->any()) - ->method('getId') - ->will($this->returnValue('en')); $languages = array( - 'de' => $language_de, - 'en' => $language_en, + 'de' => (object) array( + 'id' => 'de', + ), + 'en' => (object) array( + 'id' => 'en', + ), ); // Create a language manager stub. diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 01ef781..e53d79e 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -295,7 +295,7 @@ function locale_get_plural($count, $langcode = NULL) { // individually for each language. $plural_indexes = &drupal_static(__FUNCTION__ . ':plurals', array()); - $langcode = $langcode ? $langcode : $language_interface->getId(); + $langcode = $langcode ? $langcode : $language_interface->id; if (!isset($plural_indexes[$langcode][$count])) { // Retrieve and statically cache the plural formulas for all languages. @@ -517,11 +517,11 @@ function locale_js_translate(array $files = array()) { } // If necessary, rebuild the translation file for the current language. - if (!empty($parsed['refresh:' . $language_interface->getId()])) { + if (!empty($parsed['refresh:' . $language_interface->id])) { // Don't clear the refresh flag on failure, so that another try will // be performed later. if (_locale_rebuild_js()) { - unset($parsed['refresh:' . $language_interface->getId()]); + unset($parsed['refresh:' . $language_interface->id]); } // Store any changes after refresh was attempted. \Drupal::state()->set('system.javascript_parsed', $parsed); @@ -535,9 +535,9 @@ function locale_js_translate(array $files = array()) { // Add the translation JavaScript file to the page. $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: array(); $translation_file = NULL; - if (!empty($files) && !empty($locale_javascripts[$language_interface->getId()])) { + if (!empty($files) && !empty($locale_javascripts[$language_interface->id])) { // Add the translation JavaScript file to the page. - $translation_file = $dir . '/' . $language_interface->getId() . '_' . $locale_javascripts[$language_interface->getId()] . '.js'; + $translation_file = $dir . '/' . $language_interface->id . '_' . $locale_javascripts[$language_interface->id] . '.js'; } return $translation_file; } @@ -727,18 +727,16 @@ function locale_system_file_system_settings_submit(&$form, FormStateInterface $f * Implements hook_preprocess_HOOK() for node templates. */ function locale_preprocess_node(&$variables) { - /* @var $node \Drupal\node\NodeInterface */ - $node = $variables['node']; - if ($node->language()->getId() != LanguageInterface::LANGCODE_NOT_SPECIFIED) { - $interface_language = \Drupal::languageManager()->getCurrentLanguage(); + if ($variables['node']->language()->id != LanguageInterface::LANGCODE_NOT_SPECIFIED) { + $language_interface = \Drupal::languageManager()->getCurrentLanguage(); - $node_language = $node->language(); - if ($node_language->getId() != $interface_language->getId()) { + $node_language = $variables['node']->language(); + if ($node_language->id != $language_interface->id) { // If the node language was different from the page language, we should // add markup to identify the language. Otherwise the page language is // inherited. - $variables['attributes']['lang'] = $node_language->getId(); - if ($node_language->getDirection() != $interface_language->getDirection()) { + $variables['attributes']['lang'] = $node_language->id; + if ($node_language->getDirection() != $language_interface->getDirection()) { // If text direction is different form the page's text direction, add // direction information as well. $variables['attributes']['dir'] = $node_language->getDirection(); @@ -1195,7 +1193,7 @@ function _locale_rebuild_js($langcode = NULL) { // Only add strings with a translation to the translations array. $conditions = array( 'type' => 'javascript', - 'language' => $language->getId(), + 'language' => $language->id, 'translated' => TRUE, ); $translations = array(); @@ -1212,8 +1210,8 @@ function _locale_rebuild_js($langcode = NULL) { ); $locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array(); - if (!empty($locale_plurals[$language->getId()]['formula'])) { - $data['pluralFormula'] = $locale_plurals[$language->getId()]['formula']; + if (!empty($locale_plurals[$language->id]['formula'])) { + $data['pluralFormula'] = $locale_plurals[$language->id]['formula']; } $data = 'Drupal.locale = ' . Json::encode($data) . ';'; @@ -1227,23 +1225,23 @@ function _locale_rebuild_js($langcode = NULL) { // Delete old file, if we have no translations anymore, or a different file to // be saved. $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: array(); - $changed_hash = !isset($locale_javascripts[$language->getId()]) || ($locale_javascripts[$language->getId()] != $data_hash); - if (!empty($locale_javascripts[$language->getId()]) && (!$data || $changed_hash)) { - file_unmanaged_delete($dir . '/' . $language->getId() . '_' . $locale_javascripts[$language->getId()] . '.js'); - $locale_javascripts[$language->getId()] = ''; + $changed_hash = !isset($locale_javascripts[$language->id]) || ($locale_javascripts[$language->id] != $data_hash); + if (!empty($locale_javascripts[$language->id]) && (!$data || $changed_hash)) { + file_unmanaged_delete($dir . '/' . $language->id . '_' . $locale_javascripts[$language->id] . '.js'); + $locale_javascripts[$language->id] = ''; $status = 'deleted'; } // Only create a new file if the content has changed or the original file got // lost. - $dest = $dir . '/' . $language->getId() . '_' . $data_hash . '.js'; + $dest = $dir . '/' . $language->id . '_' . $data_hash . '.js'; if ($data && ($changed_hash || !file_exists($dest))) { // Ensure that the directory exists and is writable, if possible. file_prepare_directory($dir, FILE_CREATE_DIRECTORY); // Save the file. if (file_unmanaged_save_data($data, $dest)) { - $locale_javascripts[$language->getId()] = $data_hash; + $locale_javascripts[$language->id] = $data_hash; // If we deleted a previous version of the file and we replace it with a // new one we have an update. if ($status == 'deleted') { @@ -1261,7 +1259,7 @@ function _locale_rebuild_js($langcode = NULL) { } } else { - $locale_javascripts[$language->getId()] = ''; + $locale_javascripts[$language->id] = ''; $status = 'error'; } } @@ -1281,7 +1279,7 @@ function _locale_rebuild_js($langcode = NULL) { return TRUE; case 'rebuilt': - $logger->warning('JavaScript translation file %file.js was lost.', array('%file' => $locale_javascripts[$language->getId()])); + $logger->warning('JavaScript translation file %file.js was lost.', array('%file' => $locale_javascripts[$language->id])); // Proceed to the 'created' case as the JavaScript translation file has // been created again. diff --git a/core/modules/locale/src/Form/ExportForm.php b/core/modules/locale/src/Form/ExportForm.php index 00a4be1..631c4aa 100644 --- a/core/modules/locale/src/Form/ExportForm.php +++ b/core/modules/locale/src/Form/ExportForm.php @@ -83,7 +83,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'select', '#title' => $this->t('Language'), '#options' => $language_options, - '#default_value' => $language_default->getId(), + '#default_value' => $language_default->id, '#empty_option' => $this->t('Source text only, no translations'), '#empty_value' => LanguageInterface::LANGCODE_SYSTEM, ); @@ -140,11 +140,11 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $reader = new PoDatabaseReader(); $language_name = ''; if ($language != NULL) { - $reader->setLangcode($language->getId()); + $reader->setLangcode($language->id); $reader->setOptions($content_options); $languages = $this->languageManager->getLanguages(); - $language_name = isset($languages[$language->getId()]) ? $languages[$language->getId()]->name : ''; - $filename = $language->getId() .'.po'; + $language_name = isset($languages[$language->id]) ? $languages[$language->id]->name : ''; + $filename = $language->id . '.po'; } else { // Template required. diff --git a/core/modules/locale/src/Form/TranslateFormBase.php b/core/modules/locale/src/Form/TranslateFormBase.php index 8ff3cd8..4599c44 100644 --- a/core/modules/locale/src/Form/TranslateFormBase.php +++ b/core/modules/locale/src/Form/TranslateFormBase.php @@ -170,7 +170,7 @@ protected function translateFilters() { } // Pick the current interface language code for the filter. - $default_langcode = $this->languageManager->getCurrentLanguage()->getId(); + $default_langcode = $this->languageManager->getCurrentLanguage()->id; if (!isset($language_options[$default_langcode])) { $available_langcodes = array_keys($language_options); $default_langcode = array_shift($available_langcodes); diff --git a/core/modules/locale/src/LocaleConfigManager.php b/core/modules/locale/src/LocaleConfigManager.php index e2f4452..73d653c 100644 --- a/core/modules/locale/src/LocaleConfigManager.php +++ b/core/modules/locale/src/LocaleConfigManager.php @@ -326,7 +326,7 @@ public function translateString($name, $langcode, $source, $context) { * A boolean indicating if a language has configuration translations. */ public function hasTranslation($name, LanguageInterface $language) { - $translation = $this->languageManager->getLanguageConfigOverride($language->getId(), $name); + $translation = $this->languageManager->getLanguageConfigOverride($language->id, $name); return !$translation->isNew(); } diff --git a/core/modules/locale/src/Tests/LocalePathTest.php b/core/modules/locale/src/Tests/LocalePathTest.php index d1678af..ae4b9db 100644 --- a/core/modules/locale/src/Tests/LocalePathTest.php +++ b/core/modules/locale/src/Tests/LocalePathTest.php @@ -121,7 +121,7 @@ public function testPathLanguageConfiguration() { $edit = array( 'source' => 'node/' . $first_node->id(), 'alias' => $custom_path, - 'langcode' => $first_node->language()->getId(), + 'langcode' => $first_node->language()->id, ); $this->container->get('path.alias_storage')->save($edit['source'], $edit['alias'], $edit['langcode']); @@ -130,7 +130,7 @@ public function testPathLanguageConfiguration() { $edit = array( 'source' => 'node/' . $second_node->id(), 'alias' => $custom_path, - 'langcode' => $second_node->language()->getId(), + 'langcode' => $second_node->language()->id, ); $this->container->get('path.alias_storage')->save($edit['source'], $edit['alias'], $edit['langcode']); diff --git a/core/modules/locale/src/Tests/LocaleStringTest.php b/core/modules/locale/src/Tests/LocaleStringTest.php index 430b024..c608d62 100644 --- a/core/modules/locale/src/Tests/LocaleStringTest.php +++ b/core/modules/locale/src/Tests/LocaleStringTest.php @@ -188,10 +188,8 @@ public function buildSourceString($values = array()) { */ public function createAllTranslations($source, $values = array()) { $list = array(); - /* @var $language_manager \Drupal\Core\Language\LanguageManagerInterface */ - $language_manager = $this->container->get('language_manager'); - foreach ($language_manager->getLanguages() as $language) { - $list[$language->getId()] = $this->createTranslation($source, $language->getId(), $values); + foreach ($this->container->get('language_manager')->getLanguages() as $language) { + $list[$language->id] = $this->createTranslation($source, $language->id, $values); } return $list; } diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module index 1669aea..0aa49d0 100644 --- a/core/modules/menu_ui/menu_ui.module +++ b/core/modules/menu_ui/menu_ui.module @@ -183,7 +183,7 @@ function menu_ui_node_save(EntityInterface $node) { 'parent' => $definition['parent'], 'weight' => isset($definition['weight']) ? $definition['weight'] : 0, 'enabled' => 1, - 'langcode' => $node->getUntranslated()->language()->getId(), + 'langcode' => $node->getUntranslated()->language()->id, )); } if (!$entity->save()) { diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_system_performance.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_system_performance.yml index 1455a8a..4486a7c 100644 --- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_system_performance.yml +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_system_performance.yml @@ -8,12 +8,10 @@ source: - preprocess_css - preprocess_js - cache_lifetime - - cache process: 'css/preprocess': preprocess_css 'js/preprocess': preprocess_js 'cache/page/max_age': cache_lifetime - 'cache/page/use_internal': cache destination: plugin: config config_name: system.performance diff --git a/core/modules/migrate_drupal/src/Tests/Dump/Drupal6SystemPerformance.php b/core/modules/migrate_drupal/src/Tests/Dump/Drupal6SystemPerformance.php index f491d39..b8bbf63 100644 --- a/core/modules/migrate_drupal/src/Tests/Dump/Drupal6SystemPerformance.php +++ b/core/modules/migrate_drupal/src/Tests/Dump/Drupal6SystemPerformance.php @@ -33,10 +33,6 @@ public function load() { 'name' => 'cache_lifetime', 'value' => 'i:0;', )) - ->values(array( - 'name' => 'cache', - 'value' => 'i:1;', - )) ->execute(); } diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorFeedTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorFeedTest.php index b8b503e..b8eab06 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorFeedTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorFeedTest.php @@ -42,7 +42,7 @@ public function testAggregatorFeedImport() { $feed = Feed::load(5); $this->assertNotNull($feed->uuid()); $this->assertEqual($feed->title->value, 'Know Your Meme'); - $this->assertEqual($feed->language()->getId(), 'en'); + $this->assertEqual($feed->language()->id, 'en'); $this->assertEqual($feed->url->value, 'http://knowyourmeme.com/newsfeed.rss'); $this->assertEqual($feed->refresh->value, 900); $this->assertEqual($feed->checked->value, 1387659487); diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorItemTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorItemTest.php index 93f1894..0b5a349 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorItemTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorItemTest.php @@ -67,7 +67,7 @@ public function testAggregatorItem() { $this->assertEqual($item->getDescription(), "

What's new with Drupal 8?

"); $this->assertEqual($item->getLink(), 'https://groups.drupal.org/node/395218'); $this->assertEqual($item->getPostedTime(), 1389297196); - $this->assertEqual($item->language()->getId(), 'en'); + $this->assertEqual($item->language()->id, 'en'); $this->assertEqual($item->getGuid(), '395218 at https://groups.drupal.org'); } diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockContentTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockContentTest.php index 9894bdd..0835650 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockContentTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockContentTest.php @@ -51,7 +51,7 @@ public function testBlockMigration() { $this->assertEqual('My block 1', $block->label()); $this->assertEqual(1, $block->getRevisionId()); $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time()); - $this->assertEqual('en', $block->language()->getId()); + $this->assertEqual('en', $block->language()->id); $this->assertEqual('

My first custom block body

', $block->body->value); $this->assertEqual('full_html', $block->body->format); @@ -59,7 +59,7 @@ public function testBlockMigration() { $this->assertEqual('My block 2', $block->label()); $this->assertEqual(2, $block->getRevisionId()); $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time()); - $this->assertEqual('en', $block->language()->getId()); + $this->assertEqual('en', $block->language()->id); $this->assertEqual('

My second custom block body

', $block->body->value); $this->assertEqual('full_html', $block->body->format); } diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentTest.php index 8206618..77980cd 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentTest.php @@ -81,7 +81,7 @@ public function testComments() { $this->assertEqual(0, $comment->pid->target_id); $this->assertEqual(1, $comment->getCommentedEntityId()); $this->assertEqual('node', $comment->getCommentedEntityTypeId()); - $this->assertEqual('en', $comment->language()->getId()); + $this->assertEqual('en', $comment->language()->id); $this->assertEqual('comment_no_subject', $comment->getTypeId()); $comment = entity_load('comment', 2); diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateSystemPerformanceTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateSystemPerformanceTest.php index b4ed817..777231b 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateSystemPerformanceTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateSystemPerformanceTest.php @@ -40,7 +40,6 @@ public function testSystemPerformance() { $this->assertIdentical($config->get('css.preprocess'), FALSE); $this->assertIdentical($config->get('js.preprocess'), FALSE); $this->assertIdentical($config->get('cache.page.max_age'), 0); - $this->assertIdentical($config->get('cache.page.use_internal'), TRUE); } } diff --git a/core/modules/node/node.tokens.inc b/core/modules/node/node.tokens.inc index 33461c9..7109d30 100644 --- a/core/modules/node/node.tokens.inc +++ b/core/modules/node/node.tokens.inc @@ -161,7 +161,7 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr break; case 'langcode': - $replacements[$original] = $sanitize ? String::checkPlain($node->language()->getId()) : $node->language()->getId(); + $replacements[$original] = $sanitize ? String::checkPlain($node->language()->id) : $node->language()->id; break; case 'url': diff --git a/core/modules/node/src/Access/NodeRevisionAccessCheck.php b/core/modules/node/src/Access/NodeRevisionAccessCheck.php index f7309d7..0fdc115 100644 --- a/core/modules/node/src/Access/NodeRevisionAccessCheck.php +++ b/core/modules/node/src/Access/NodeRevisionAccessCheck.php @@ -128,7 +128,7 @@ public function checkAccess(NodeInterface $node, AccountInterface $account, $op // If no language code was provided, default to the node revision's langcode. if (empty($langcode)) { - $langcode = $node->language()->getId(); + $langcode = $node->language()->id; } // Statically cache access by revision ID, language code, user account ID, diff --git a/core/modules/node/src/Entity/Node.php b/core/modules/node/src/Entity/Node.php index 5948103..b5bb8f8 100644 --- a/core/modules/node/src/Entity/Node.php +++ b/core/modules/node/src/Entity/Node.php @@ -160,14 +160,14 @@ public function access($operation = 'view', AccountInterface $account = NULL, $r * {@inheritdoc} */ public function prepareLangcode() { - $langcode = $this->language()->getId(); + $langcode = $this->language()->id; // If the Language module is enabled, try to use the language from content // negotiation. if (\Drupal::moduleHandler()->moduleExists('language')) { // Load languages the node exists in. $node_translations = $this->getTranslationLanguages(); // Load the language from content negotiation. - $content_negotiation_langcode = \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(); + $content_negotiation_langcode = \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->id; // If there is a translation available, use it. if (isset($node_translations[$content_negotiation_langcode])) { $langcode = $content_negotiation_langcode; diff --git a/core/modules/node/src/NodeForm.php b/core/modules/node/src/NodeForm.php index 7f9ef84..a214282 100644 --- a/core/modules/node/src/NodeForm.php +++ b/core/modules/node/src/NodeForm.php @@ -112,7 +112,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['langcode'] = array( '#title' => t('Language'), '#type' => 'language_select', - '#default_value' => $node->getUntranslated()->language()->getId(), + '#default_value' => $node->getUntranslated()->language()->id, '#languages' => LanguageInterface::STATE_ALL, '#access' => isset($language_configuration['language_show']) && $language_configuration['language_show'], ); diff --git a/core/modules/node/src/NodeGrantDatabaseStorage.php b/core/modules/node/src/NodeGrantDatabaseStorage.php index 9cddb2e..7ea3307 100644 --- a/core/modules/node/src/NodeGrantDatabaseStorage.php +++ b/core/modules/node/src/NodeGrantDatabaseStorage.php @@ -202,7 +202,7 @@ public function write(NodeInterface $node, array $grants, $realm = NULL, $delete $grant['nid'] = $node->id(); $grant['langcode'] = $grant_langcode; // The record with the original langcode is used as the fallback. - if ($grant['langcode'] == $node->language()->getId()) { + if ($grant['langcode'] == $node->language()->id) { $grant['fallback'] = 1; } else { diff --git a/core/modules/node/src/NodeListBuilder.php b/core/modules/node/src/NodeListBuilder.php index f2011c0..606da79 100644 --- a/core/modules/node/src/NodeListBuilder.php +++ b/core/modules/node/src/NodeListBuilder.php @@ -96,7 +96,7 @@ public function buildRow(EntityInterface $entity) { '#theme' => 'mark', '#mark_type' => node_mark($entity->id(), $entity->getChangedTime()), ); - $langcode = $entity->language()->getId(); + $langcode = $entity->language()->id; $uri = $entity->urlInfo(); $options = $uri->getOptions(); $options += ($langcode != LanguageInterface::LANGCODE_NOT_SPECIFIED && isset($languages[$langcode]) ? array('language' => $languages[$langcode]) : array()); diff --git a/core/modules/node/src/NodeStorage.php b/core/modules/node/src/NodeStorage.php index f3c97e4..f851c94 100644 --- a/core/modules/node/src/NodeStorage.php +++ b/core/modules/node/src/NodeStorage.php @@ -55,7 +55,7 @@ public function updateType($old_type, $new_type) { public function clearRevisionsLanguage($language) { return $this->database->update('node_revision') ->fields(array('langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED)) - ->condition('langcode', $language->getId()) + ->condition('langcode', $language->id) ->execute(); } diff --git a/core/modules/node/src/Plugin/Search/NodeSearch.php b/core/modules/node/src/Plugin/Search/NodeSearch.php index c5ad990..5d13e7d 100644 --- a/core/modules/node/src/Plugin/Search/NodeSearch.php +++ b/core/modules/node/src/Plugin/Search/NodeSearch.php @@ -282,7 +282,7 @@ public function execute() { 'extra' => $extra, 'score' => $item->calculated_score, 'snippet' => search_excerpt($keys, $node->rendered, $item->langcode), - 'langcode' => $node->language()->getId(), + 'langcode' => $node->language()->id, ); } return $results; @@ -342,23 +342,23 @@ protected function indexNode(NodeInterface $node) { $node_render = $this->entityManager->getViewBuilder('node'); foreach ($languages as $language) { - $node = $node->getTranslation($language->getId()); + $node = $node->getTranslation($language->id); // Render the node. - $build = $node_render->view($node, 'search_index', $language->getId()); + $build = $node_render->view($node, 'search_index', $language->id); unset($build['#theme']); $node->rendered = drupal_render($build); - $text = '

' . String::checkPlain($node->label($language->getId())) . '

' . $node->rendered; + $text = '

' . String::checkPlain($node->label($language->id)) . '

' . $node->rendered; // Fetch extra data normally not visible. - $extra = $this->moduleHandler->invokeAll('node_update_index', array($node, $language->getId())); + $extra = $this->moduleHandler->invokeAll('node_update_index', array($node, $language->id)); foreach ($extra as $t) { $text .= $t; } // Update index. - search_index($node->id(), $this->getPluginId(), $text, $language->getId()); + search_index($node->id(), $this->getPluginId(), $text, $language->id); } } diff --git a/core/modules/node/src/Tests/NodeAccessLanguageTest.php b/core/modules/node/src/Tests/NodeAccessLanguageTest.php index c97dc07..aa29d40 100644 --- a/core/modules/node/src/Tests/NodeAccessLanguageTest.php +++ b/core/modules/node/src/Tests/NodeAccessLanguageTest.php @@ -54,7 +54,7 @@ function testNodeAccess() { // Creating a public node with langcode Hungarian, will be saved as the // fallback in node access table. $node_public_hu = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'private' => FALSE)); - $this->assertTrue($node_public_hu->language()->getId() == 'hu', 'Node created as Hungarian.'); + $this->assertTrue($node_public_hu->language()->id == 'hu', 'Node created as Hungarian.'); // Tests the default access is provided for the public Hungarian node. $this->assertNodeAccess($expected_node_access, $node_public_hu, $web_user); @@ -74,7 +74,7 @@ function testNodeAccess() { 'private' => FALSE, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); - $this->assertTrue($node_public_no_language->language()->getId() == LanguageInterface::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); + $this->assertTrue($node_public_no_language->language()->id == LanguageInterface::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); // Tests that access is granted if requested with no language. $this->assertNodeAccess($expected_node_access, $node_public_no_language, $web_user); @@ -92,7 +92,7 @@ function testNodeAccess() { \Drupal::entityManager()->getAccessControlHandler('node')->resetCache(); \Drupal::state()->set('node_access_test_secret_catalan', 1); $node_public_ca = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'ca', 'private' => FALSE)); - $this->assertTrue($node_public_ca->language()->getId() == 'ca', 'Node created as Catalan.'); + $this->assertTrue($node_public_ca->language()->id == 'ca', 'Node created as Catalan.'); // Tests that access is granted if requested with no language. $this->assertNodeAccess($expected_node_access, $node_public_no_language, $web_user); @@ -147,7 +147,7 @@ function testNodeAccessPrivate() { // Creating a private node with langcode Hungarian, will be saved as the // fallback in node access table. $node_private_hu = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'private' => TRUE)); - $this->assertTrue($node_private_hu->language()->getId() == 'hu', 'Node created as Hungarian.'); + $this->assertTrue($node_private_hu->language()->id == 'hu', 'Node created as Hungarian.'); // Tests the default access is not provided for the private Hungarian node. $this->assertNodeAccess($expected_node_access_no_access, $node_private_hu, $web_user); @@ -167,7 +167,7 @@ function testNodeAccessPrivate() { 'private' => TRUE, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); - $this->assertTrue($node_private_no_language->language()->getId() == LanguageInterface::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); + $this->assertTrue($node_private_no_language->language()->id == LanguageInterface::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); // Tests that access is not granted if requested with no language. $this->assertNodeAccess($expected_node_access_no_access, $node_private_no_language, $web_user); @@ -198,7 +198,7 @@ function testNodeAccessPrivate() { // node_access_test_secret_catalan flag works. $private_ca_user = $this->drupalCreateUser(array('access content', 'node test view')); $node_private_ca = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'ca', 'private' => TRUE)); - $this->assertTrue($node_private_ca->language()->getId() == 'ca', 'Node created as Catalan.'); + $this->assertTrue($node_private_ca->language()->id == 'ca', 'Node created as Catalan.'); // Tests that Catalan is still not accessible to either user. $this->assertNodeAccess($expected_node_access_no_access, $node_private_ca, $web_user, 'ca'); @@ -230,12 +230,12 @@ function testNodeAccessQueryTag() { // Creating a private node with langcode Hungarian, will be saved as // the fallback in node access table. $node_private = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'private' => TRUE)); - $this->assertTrue($node_private->language()->getId() == 'hu', 'Node created as Hungarian.'); + $this->assertTrue($node_private->language()->id == 'hu', 'Node created as Hungarian.'); // Creating a public node with langcode Hungarian, will be saved as // the fallback in node access table. $node_public = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'private' => FALSE)); - $this->assertTrue($node_public->language()->getId() == 'hu', 'Node created as Hungarian.'); + $this->assertTrue($node_public->language()->id == 'hu', 'Node created as Hungarian.'); // Creating a public node with no special langcode, like when no language // module enabled. @@ -243,7 +243,7 @@ function testNodeAccessQueryTag() { 'private' => FALSE, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); - $this->assertTrue($node_no_language->language()->getId() == LanguageInterface::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); + $this->assertTrue($node_no_language->language()->id == LanguageInterface::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); // Query the nodes table as the web user with the node access tag and no // specific langcode. diff --git a/core/modules/node/src/Tests/NodeFieldMultilingualTest.php b/core/modules/node/src/Tests/NodeFieldMultilingualTest.php index d00ffcd..8649a35 100644 --- a/core/modules/node/src/Tests/NodeFieldMultilingualTest.php +++ b/core/modules/node/src/Tests/NodeFieldMultilingualTest.php @@ -77,7 +77,7 @@ function testMultilingualNodeForm() { // Check that the node exists in the database. $node = $this->drupalGetNodeByTitle($edit[$title_key]); $this->assertTrue($node, 'Node found in database.'); - $this->assertTrue($node->language()->getId() == $langcode && $node->body->value == $body_value, 'Field language correctly set.'); + $this->assertTrue($node->language()->id == $langcode && $node->body->value == $body_value, 'Field language correctly set.'); // Change node language. $langcode = 'it'; @@ -89,7 +89,7 @@ function testMultilingualNodeForm() { $this->drupalPostForm(NULL, $edit, t('Save')); $node = $this->drupalGetNodeByTitle($edit[$title_key], TRUE); $this->assertTrue($node, 'Node found in database.'); - $this->assertTrue($node->language()->getId() == $langcode && $node->body->value == $body_value, 'Field language correctly changed.'); + $this->assertTrue($node->language()->id == $langcode && $node->body->value == $body_value, 'Field language correctly changed.'); // Enable content language URL detection. $this->container->get('language_negotiator')->saveConfiguration(LanguageInterface::TYPE_CONTENT, array(LanguageNegotiationUrl::METHOD_ID => 0)); diff --git a/core/modules/node/src/Tests/NodeLastChangedTest.php b/core/modules/node/src/Tests/NodeLastChangedTest.php index ae5dc27..16ea74c 100644 --- a/core/modules/node/src/Tests/NodeLastChangedTest.php +++ b/core/modules/node/src/Tests/NodeLastChangedTest.php @@ -40,7 +40,7 @@ function testNodeLastChanged() { $changed_timestamp = node_last_changed($node->id()); $this->assertEqual($changed_timestamp, $node->getChangedTime(), 'Expected last changed timestamp returned.'); - $changed_timestamp = node_last_changed($node->id(), $node->language()->getId()); + $changed_timestamp = node_last_changed($node->id(), $node->language()->id); $this->assertEqual($changed_timestamp, $node->getChangedTime(), 'Expected last changed timestamp returned.'); } } diff --git a/core/modules/node/src/Tests/NodeTokenReplaceTest.php b/core/modules/node/src/Tests/NodeTokenReplaceTest.php index 8103866..98d1e9b 100644 --- a/core/modules/node/src/Tests/NodeTokenReplaceTest.php +++ b/core/modules/node/src/Tests/NodeTokenReplaceTest.php @@ -68,20 +68,20 @@ function testNodeTokenReplacement() { $tests['[node:title]'] = String::checkPlain($node->getTitle()); $tests['[node:body]'] = $node->body->processed; $tests['[node:summary]'] = $node->body->summary_processed; - $tests['[node:langcode]'] = String::checkPlain($node->language()->getId()); + $tests['[node:langcode]'] = String::checkPlain($node->language()->id); $tests['[node:url]'] = $node->url('canonical', $url_options); $tests['[node:edit-url]'] = $node->url('edit-form', $url_options); $tests['[node:author]'] = String::checkPlain($account->getUsername()); $tests['[node:author:uid]'] = $node->getOwnerId(); $tests['[node:author:name]'] = String::checkPlain($account->getUsername()); - $tests['[node:created:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $node->getCreatedTime(), 2, $this->interfaceLanguage->getId()); - $tests['[node:changed:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $node->getChangedTime(), 2, $this->interfaceLanguage->getId()); + $tests['[node:created:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $node->getCreatedTime(), 2, $this->interfaceLanguage->id); + $tests['[node:changed:since]'] = \Drupal::service('date.formatter')->formatInterval(REQUEST_TIME - $node->getChangedTime(), 2, $this->interfaceLanguage->id); // Test to make sure that we generated something for each token. $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $this->tokenService->replace($input, array('node' => $node), array('langcode' => $this->interfaceLanguage->getId())); + $output = $this->tokenService->replace($input, array('node' => $node), array('langcode' => $this->interfaceLanguage->id)); $this->assertEqual($output, $expected, format_string('Sanitized node token %token replaced.', array('%token' => $input))); } @@ -89,11 +89,11 @@ function testNodeTokenReplacement() { $tests['[node:title]'] = $node->getTitle(); $tests['[node:body]'] = $node->body->value; $tests['[node:summary]'] = $node->body->summary; - $tests['[node:langcode]'] = $node->language()->getId(); + $tests['[node:langcode]'] = $node->language()->id; $tests['[node:author:name]'] = $account->getUsername(); foreach ($tests as $input => $expected) { - $output = $this->tokenService->replace($input, array('node' => $node), array('langcode' => $this->interfaceLanguage->getId(), 'sanitize' => FALSE)); + $output = $this->tokenService->replace($input, array('node' => $node), array('langcode' => $this->interfaceLanguage->id, 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized node token %token replaced.', array('%token' => $input))); } diff --git a/core/modules/search/search.pages.inc b/core/modules/search/search.pages.inc index 4c84c84..6590b90 100644 --- a/core/modules/search/search.pages.inc +++ b/core/modules/search/search.pages.inc @@ -37,7 +37,7 @@ function template_preprocess_search_result(&$variables) { $result = $variables['result']; $variables['url'] = check_url($result['link']); $variables['title'] = String::checkPlain($result['title']); - if (isset($result['language']) && $result['language'] != $language_interface->getId() && $result['language'] != LanguageInterface::LANGCODE_NOT_SPECIFIED) { + if (isset($result['language']) && $result['language'] != $language_interface->id && $result['language'] != LanguageInterface::LANGCODE_NOT_SPECIFIED) { $variables['title_attributes']['lang'] = $result['language']; $variables['content_attributes']['lang'] = $result['language']; } diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module index e0b11ea..f21d00f 100644 --- a/core/modules/shortcut/shortcut.module +++ b/core/modules/shortcut/shortcut.module @@ -258,7 +258,7 @@ function shortcut_renderable_links($shortcut_set = NULL) { $shortcut = \Drupal::entityManager()->getTranslationFromContext($shortcut); $links[] = array( 'title' => $shortcut->label(), - 'url' => Url::fromRoute($shortcut->getRouteName(), $shortcut->getRouteParameters()), + 'url' => Url::fromRoute($shortcut->getRouteName(), $shortcut->getRouteParams()), ); $cache_tags = Cache::mergeTags($cache_tags, $shortcut->getCacheTag()); } @@ -314,7 +314,7 @@ function shortcut_preprocess_page(&$variables) { // Check if $link is already a shortcut and set $link_mode accordingly. $shortcuts = \Drupal::entityManager()->getStorage('shortcut')->loadByProperties(array('shortcut_set' => $shortcut_set->id())); foreach ($shortcuts as $shortcut) { - if ($shortcut->getRouteName() == $url->getRouteName() && $shortcut->getRouteParameters() == $url->getRouteParameters()) { + if ($shortcut->getRouteName() == $url->getRouteName() && $shortcut->getRouteParams() == $url->getRouteParameters()) { $shortcut_id = $shortcut->id(); break; } diff --git a/core/modules/shortcut/src/Entity/Shortcut.php b/core/modules/shortcut/src/Entity/Shortcut.php index 087b650..9734109 100644 --- a/core/modules/shortcut/src/Entity/Shortcut.php +++ b/core/modules/shortcut/src/Entity/Shortcut.php @@ -86,7 +86,7 @@ public function setWeight($weight) { * {@inheritdoc} */ public function getUrl() { - return new Url($this->getRouteName(), $this->getRouteParameters()); + return new Url($this->getRouteName(), $this->getRouteParams()); } /** @@ -107,14 +107,14 @@ public function setRouteName($route_name) { /** * {@inheritdoc} */ - public function getRouteParameters() { + public function getRouteParams() { return $this->get('route_parameters')->first()->getValue(); } /** * {@inheritdoc} */ - public function setRouteParameters($route_parameters) { + public function setRouteParams($route_parameters) { $this->set('route_parameters', $route_parameters); return $this; } @@ -146,7 +146,7 @@ public function preSave(EntityStorageInterface $storage) { $url = Url::createFromRequest(Request::create("/{$this->path->value}")); } $this->setRouteName($url->getRouteName()); - $this->setRouteParameters($url->getRouteParameters()); + $this->setRouteParams($url->getRouteParameters()); } /** diff --git a/core/modules/shortcut/src/ShortcutForm.php b/core/modules/shortcut/src/ShortcutForm.php index 86c022e..c9f5d3d 100644 --- a/core/modules/shortcut/src/ShortcutForm.php +++ b/core/modules/shortcut/src/ShortcutForm.php @@ -72,7 +72,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['langcode'] = array( '#title' => t('Language'), '#type' => 'language_select', - '#default_value' => $this->entity->getUntranslated()->language()->getId(), + '#default_value' => $this->entity->getUntranslated()->language()->id, '#languages' => LanguageInterface::STATE_ALL, ); diff --git a/core/modules/shortcut/src/ShortcutInterface.php b/core/modules/shortcut/src/ShortcutInterface.php index c074b83..90d90f9 100644 --- a/core/modules/shortcut/src/ShortcutInterface.php +++ b/core/modules/shortcut/src/ShortcutInterface.php @@ -85,7 +85,7 @@ public function setRouteName($route_name); * @return array * The route parameters of this shortcut. */ - public function getRouteParameters(); + public function getRouteParams(); /** * Sets the route parameters associated with this shortcut. @@ -96,6 +96,6 @@ public function getRouteParameters(); * @return \Drupal\shortcut\ShortcutInterface * The called shortcut entity. */ - public function setRouteParameters($route_parameters); + public function setRouteParams($route_parameters); } diff --git a/core/modules/shortcut/src/ShortcutPathValue.php b/core/modules/shortcut/src/ShortcutPathValue.php index 8d05b7d..3d88d9b 100644 --- a/core/modules/shortcut/src/ShortcutPathValue.php +++ b/core/modules/shortcut/src/ShortcutPathValue.php @@ -25,7 +25,7 @@ public function getValue() { $entity = $this->parent->getEntity(); if ($route_name = $entity->getRouteName()) { - $path = \Drupal::urlGenerator()->getPathFromRoute($route_name, $entity->getRouteParameters()); + $path = \Drupal::urlGenerator()->getPathFromRoute($route_name, $entity->getRouteParams()); $this->value = trim($path, '/'); } else { diff --git a/core/modules/statistics/src/Tests/StatisticsTokenReplaceTest.php b/core/modules/statistics/src/Tests/StatisticsTokenReplaceTest.php index d481f01..05b6aab 100644 --- a/core/modules/statistics/src/Tests/StatisticsTokenReplaceTest.php +++ b/core/modules/statistics/src/Tests/StatisticsTokenReplaceTest.php @@ -49,7 +49,7 @@ function testStatisticsTokenReplacement() { $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = \Drupal::token()->replace($input, array('node' => $node), array('langcode' => $language_interface->getId())); + $output = \Drupal::token()->replace($input, array('node' => $node), array('langcode' => $language_interface->id)); $this->assertEqual($output, $expected, format_string('Statistics token %token replaced.', array('%token' => $input))); } } diff --git a/core/modules/system/core.api.php b/core/modules/system/core.api.php index 3edb6c4..a863baa 100644 --- a/core/modules/system/core.api.php +++ b/core/modules/system/core.api.php @@ -356,7 +356,7 @@ * * Example: * @code - * $cid = 'mymodule_example:' . \Drupal::languageManager()->getCurrentLanguage()->getId(); + * $cid = 'mymodule_example:' . \Drupal::languageManager()->getCurrentLanguage()->id(); * * $data = NULL; * if ($cache = \Drupal::cache()->get($cid)) { diff --git a/core/modules/system/entity.api.php b/core/modules/system/entity.api.php index 5974440..534b7b8 100644 --- a/core/modules/system/entity.api.php +++ b/core/modules/system/entity.api.php @@ -186,7 +186,7 @@ * To make a render array for a loaded entity: * @code * // You can omit the language ID if the default language is being used. - * $build = $view_builder->view($entity, 'view_mode_name', $language->getId()); + * $build = $view_builder->view($entity, 'view_mode_name', $language->id); * @endcode * You can also use the viewMultiple() method to view multiple entities. * @@ -469,7 +469,7 @@ * Then, to build and render the entity: * @code * // You can omit the language ID if the default language is being used. - * $build = $view_builder->view($entity, 'view_mode_name', $language->getId()); + * $build = $view_builder->view($entity, 'view_mode_name', $language->id); * // $build is a render array. * $rendered = drupal_render($build); * @endcode @@ -893,7 +893,7 @@ function hook_ENTITY_TYPE_storage_load(array $entities) { function hook_entity_presave(Drupal\Core\Entity\EntityInterface $entity) { if ($entity instanceof ContentEntityInterface && $entity->isTranslatable()) { $attributes = \Drupal::request()->attributes; - \Drupal::service('content_translation.synchronizer')->synchronizeFields($entity, $entity->language()->getId(), $attributes->get('source_langcode')); + \Drupal::service('content_translation.synchronizer')->synchronizeFields($entity, $entity->language()->id, $attributes->get('source_langcode')); } } @@ -909,7 +909,7 @@ function hook_entity_presave(Drupal\Core\Entity\EntityInterface $entity) { function hook_ENTITY_TYPE_presave(Drupal\Core\Entity\EntityInterface $entity) { if ($entity->isTranslatable()) { $attributes = \Drupal::request()->attributes; - \Drupal::service('content_translation.synchronizer')->synchronizeFields($entity, $entity->language()->getId(), $attributes->get('source_langcode')); + \Drupal::service('content_translation.synchronizer')->synchronizeFields($entity, $entity->language()->id, $attributes->get('source_langcode')); } } diff --git a/core/modules/system/language.api.php b/core/modules/system/language.api.php index d0ab879..f52e22d 100644 --- a/core/modules/system/language.api.php +++ b/core/modules/system/language.api.php @@ -108,8 +108,8 @@ function hook_language_switch_links_alter(array &$links, $type, $path) { $language_interface = \Drupal::languageManager()->getCurrentLanguage(); - if ($type == LanguageInterface::TYPE_CONTENT && isset($links[$language_interface->getId()])) { - foreach ($links[$language_interface->getId()] as $link) { + if ($type == LanguageInterface::TYPE_CONTENT && isset($links[$language_interface->id])) { + foreach ($links[$language_interface->id] as $link) { $link['attributes']['class'][] = 'active-language'; } } @@ -150,7 +150,7 @@ function hook_language_switch_links_alter(array &$links, $type, $path) { * Here is a code snippet to transliterate some text: * @code * // Use the current default interface language. - * $langcode = \Drupal::languageManager()->getCurrentLanguage()->getId(); + * $langcode = \Drupal::languageManager()->getCurrentLanguage()->id; * // Instantiate the transliteration class. * $trans = \Drupal::transliteration(); * // Use this to transliterate some text. diff --git a/core/modules/system/src/Tests/Common/UrlTest.php b/core/modules/system/src/Tests/Common/UrlTest.php index e01a7da..e316eaa 100644 --- a/core/modules/system/src/Tests/Common/UrlTest.php +++ b/core/modules/system/src/Tests/Common/UrlTest.php @@ -59,7 +59,7 @@ function testLinkAttributes() { '#url' => Url::fromUri('http://drupal.org'), '#title' => 'bar', ); - $langcode = $language->getId(); + $langcode = $language->id; // Test that the default hreflang handling for links does not override a // hreflang attribute explicitly set in the render array. diff --git a/core/modules/system/src/Tests/Entity/EntityFieldDefaultValueTest.php b/core/modules/system/src/Tests/Entity/EntityFieldDefaultValueTest.php index a44f509..cd7f237 100644 --- a/core/modules/system/src/Tests/Entity/EntityFieldDefaultValueTest.php +++ b/core/modules/system/src/Tests/Entity/EntityFieldDefaultValueTest.php @@ -61,7 +61,7 @@ public function testDefaultValueCallback() { $entity = $this->entityManager->getStorage('entity_test_default_value')->create(); // The description field has a default value callback for testing, see // entity_test_field_default_value(). - $this->assertEqual($entity->description->value, 'description_' . $entity->language()->getId()); + $this->assertEqual($entity->description->value, 'description_' . $entity->language()->id); } } diff --git a/core/modules/system/src/Tests/Entity/EntityFieldTest.php b/core/modules/system/src/Tests/Entity/EntityFieldTest.php index bdd7937..e17ab70 100644 --- a/core/modules/system/src/Tests/Entity/EntityFieldTest.php +++ b/core/modules/system/src/Tests/Entity/EntityFieldTest.php @@ -200,14 +200,14 @@ protected function assertReadWrite($entity_type) { $this->assertEqual(\Drupal::languageManager()->getLanguage($langcode), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); // Change the language by code. - $entity->langcode->value = \Drupal::languageManager()->getDefaultLanguage()->getId(); - $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); + $entity->langcode->value = \Drupal::languageManager()->getDefaultLanguage()->id; + $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->id, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage(), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); // Revert language by code then try setting it by language object. $entity->langcode->value = $langcode; $entity->langcode->language = \Drupal::languageManager()->getDefaultLanguage(); - $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->id, $entity->langcode->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage(), $entity->langcode->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); // Access the text field and test updating. diff --git a/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php b/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php index 28c4f71..ca5d29e 100644 --- a/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php +++ b/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php @@ -109,7 +109,7 @@ protected function setUp() { 'label' => $this->randomString(), 'weight' => $i, )); - $this->langcodes[$i] = $language->getId(); + $this->langcodes[$i] = $language->id(); $language->save(); } } diff --git a/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php index 59da34d..53ad96b 100644 --- a/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php +++ b/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php @@ -64,12 +64,12 @@ function testEntityFormLanguage() { $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); - $this->assertTrue($node->language()->getId() == $form_langcode, 'Form language is the same as the entity language.'); + $this->assertTrue($node->language()->id == $form_langcode, 'Form language is the same as the entity language.'); // Edit the node and test the form language. $this->drupalGet($this->langcodes[0] . '/node/' . $node->id() . '/edit'); $form_langcode = \Drupal::state()->get('entity_test.form_langcode'); - $this->assertTrue($node->language()->getId() == $form_langcode, 'Form language is the same as the entity language.'); + $this->assertTrue($node->language()->id == $form_langcode, 'Form language is the same as the entity language.'); // Explicitly set form langcode. $langcode = $this->langcodes[0]; diff --git a/core/modules/system/src/Tests/Entity/EntityTranslationTest.php b/core/modules/system/src/Tests/Entity/EntityTranslationTest.php index 6d6b4a3..efb96c7 100644 --- a/core/modules/system/src/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/src/Tests/Entity/EntityTranslationTest.php @@ -39,7 +39,7 @@ protected function _testEntityLanguageMethods($entity_type) { 'name' => 'test', 'user_id' => $this->container->get('current_user')->id(), )); - $this->assertEqual($entity->language()->getId(), $this->languageManager->getDefaultLanguage()->getId(), format_string('%entity_type: Entity created with API has default language.', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->language()->getId(), $this->languageManager->getDefaultLanguage()->id, format_string('%entity_type: Entity created with API has default language.', array('%entity_type' => $entity_type))); $entity = entity_create($entity_type, array( 'name' => 'test', 'user_id' => \Drupal::currentUser()->id(), @@ -153,7 +153,7 @@ protected function _testMultilingualProperties($entity_type) { $entity = entity_create($entity_type, array('name' => $name, 'user_id' => $uid, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED)); $entity->save(); $entity = entity_load($entity_type, $entity->id()); - $default_langcode = $entity->language()->getId(); + $default_langcode = $entity->language()->id; $this->assertEqual($default_langcode, LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity created as language neutral.', array('%entity_type' => $entity_type))); $field = $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT)->get('name'); $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name has been correctly stored as language neutral.', array('%entity_type' => $entity_type))); @@ -173,7 +173,7 @@ protected function _testMultilingualProperties($entity_type) { $entity = entity_create($entity_type, array('name' => $name, 'user_id' => $uid, 'langcode' => $langcode)); $entity->save(); $entity = entity_load($entity_type, $entity->id()); - $default_langcode = $entity->language()->getId(); + $default_langcode = $entity->language()->id; $this->assertEqual($default_langcode, $langcode, format_string('%entity_type: Entity created as language specific.', array('%entity_type' => $entity_type))); $field = $entity->getTranslation($langcode)->get('name'); $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name has been correctly stored as a language-aware property.', array('%entity_type' => $entity_type))); @@ -222,7 +222,7 @@ protected function _testMultilingualProperties($entity_type) { ); $field = $entity->getTranslation($langcode)->get('name'); $this->assertEqual($properties[$langcode]['name'][0], $field->value, format_string('%entity_type: The entity name has been correctly stored for language %langcode.', $args)); - $field_langcode = ($langcode == $entity->language()->getId()) ? $default_langcode : $langcode; + $field_langcode = ($langcode == $entity->language()->id) ? $default_langcode : $langcode; $this->assertEqual($field_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expected langcode %langcode.', $args)); $this->assertEqual($properties[$langcode]['user_id'][0], $entity->getTranslation($langcode)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored for language %langcode.', $args)); } @@ -322,8 +322,8 @@ function testEntityTranslationAPI() { $translation = $entity->addTranslation($langcode); $this->assertNotIdentical($entity, $translation, 'The entity and the translation object differ from one another.'); $this->assertTrue($entity->hasTranslation($langcode), 'The new translation exists.'); - $this->assertEqual($translation->language()->getId(), $langcode, 'The translation language matches the specified one.'); - $this->assertEqual($translation->getUntranslated()->language()->getId(), $default_langcode, 'The original language can still be retrieved.'); + $this->assertEqual($translation->language()->id, $langcode, 'The translation language matches the specified one.'); + $this->assertEqual($translation->getUntranslated()->language()->id, $default_langcode, 'The original language can still be retrieved.'); $translation->name->value = $name_translated; $this->assertEqual($entity->name->value, $name, 'The original name is retained after setting a translated value.'); $entity->name->value = $name; @@ -337,16 +337,16 @@ function testEntityTranslationAPI() { // Check that after loading an entity the language is the default one. $entity = $this->reloadEntity($entity); - $this->assertEqual($entity->language()->getId(), $default_langcode, 'The loaded entity is the original one.'); + $this->assertEqual($entity->language()->id, $default_langcode, 'The loaded entity is the original one.'); // Add another translation and check that everything works as expected. A // new translation object can be obtained also by just specifying a valid // language. $langcode2 = $this->langcodes[2]; $translation = $entity->getTranslation($langcode2); - $value = $entity !== $translation && $translation->language()->getId() == $langcode2 && $entity->hasTranslation($langcode2); + $value = $entity !== $translation && $translation->language()->id == $langcode2 && $entity->hasTranslation($langcode2); $this->assertTrue($value, 'A new translation object can be obtained also by specifying a valid language.'); - $this->assertEqual($entity->language()->getId(), $default_langcode, 'The original language has been preserved.'); + $this->assertEqual($entity->language()->id, $default_langcode, 'The original language has been preserved.'); $translation->save(); $hooks = $this->getHooksInfo(); $this->assertEqual($hooks['entity_translation_insert'], $langcode2, 'The generic entity translation insertion hook has fired.'); @@ -450,7 +450,7 @@ function testEntityTranslationAPI() { * Tests language fallback applied to field and entity translations. */ function testLanguageFallback() { - $current_langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(); + $current_langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->id; $this->langcodes[] = $current_langcode; $values = array(); @@ -474,7 +474,7 @@ function testLanguageFallback() { // Check that retrieveing the current translation works as expected. $entity = $this->reloadEntity($entity); $translation = $this->entityManager->getTranslationFromContext($entity, $langcode2); - $this->assertEqual($translation->language()->getId(), $default_langcode, 'The current translation language matches the expected one.'); + $this->assertEqual($translation->language()->id, $default_langcode, 'The current translation language matches the expected one.'); // Check that language fallback respects language weight by default. $languages = $this->languageManager->getLanguages(); @@ -482,14 +482,14 @@ function testLanguageFallback() { $language->set('weight', -1); $language->save(); $translation = $this->entityManager->getTranslationFromContext($entity, $langcode2); - $this->assertEqual($translation->language()->getId(), $langcode, 'The current translation language matches the expected one.'); + $this->assertEqual($translation->language()->id, $langcode, 'The current translation language matches the expected one.'); // Check that the current translation is properly returned. $translation = $this->entityManager->getTranslationFromContext($entity); - $this->assertEqual($langcode, $translation->language()->getId(), 'The current translation language matches the topmost language fallback candidate.'); + $this->assertEqual($langcode, $translation->language()->id, 'The current translation language matches the topmost language fallback candidate.'); $entity->addTranslation($current_langcode, $values[$current_langcode]); $translation = $this->entityManager->getTranslationFromContext($entity); - $this->assertEqual($current_langcode, $translation->language()->getId(), 'The current translation language matches the current language.'); + $this->assertEqual($current_langcode, $translation->language()->id, 'The current translation language matches the current language.'); // Check that if the entity has no translation no fallback is applied. $entity2 = $controller->create(array('langcode' => $default_langcode)); diff --git a/core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php b/core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php index 6d487be..037d707 100644 --- a/core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php +++ b/core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php @@ -131,13 +131,13 @@ function testFieldLoad() { for ($delta = 0; $delta <= $this->field_cardinality; $delta++) { $value = mt_rand(1, 127); $values[$revision_id][] = $value; - $query->values(array($bundle, 0, $entity->id(), $revision_id, $delta, $entity->language()->getId(), $value)); + $query->values(array($bundle, 0, $entity->id(), $revision_id, $delta, $entity->language()->id, $value)); } $query->execute(); } $query = db_insert($this->table)->fields($columns); foreach ($values[$revision_id] as $delta => $value) { - $query->values(array($bundle, 0, $entity->id(), $revision_id, $delta, $entity->language()->getId(), $value)); + $query->values(array($bundle, 0, $entity->id(), $revision_id, $delta, $entity->language()->id, $value)); } $query->execute(); @@ -201,7 +201,7 @@ function testFieldWrite() { 'deleted' => 0, 'entity_id' => $entity->id(), 'revision_id' => $entity->getRevisionId(), - 'langcode' => $entity->language()->getId(), + 'langcode' => $entity->language()->id, 'delta' => $delta, $this->field_name . '_value' => $values[$delta]['value'], ); @@ -224,7 +224,7 @@ function testFieldWrite() { 'deleted' => 0, 'entity_id' => $entity->id(), 'revision_id' => $entity->getRevisionId(), - 'langcode' => $entity->language()->getId(), + 'langcode' => $entity->language()->id, 'delta' => $delta, $this->field_name . '_value' => $values[$delta]['value'], ); @@ -252,7 +252,7 @@ function testFieldWrite() { 'deleted' => 0, 'entity_id' => $entity->id(), 'revision_id' => $revision_id, - 'langcode' => $entity->language()->getId(), + 'langcode' => $entity->language()->id, 'delta' => $delta, $this->field_name . '_value' => $values[$delta]['value'], ); diff --git a/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php b/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php index 68c5063..4222b8f 100644 --- a/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php +++ b/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php @@ -80,7 +80,7 @@ protected function assertFieldStorageLangcode(FieldableEntityInterface $entity, $status = TRUE; $entity_type = $entity->getEntityTypeId(); $id = $entity->id(); - $langcode = $entity->getUntranslated()->language()->getId(); + $langcode = $entity->getUntranslated()->language()->id; $fields = array($this->field_name, $this->untranslatable_field_name); /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ $table_mapping = \Drupal::entityManager()->getStorage($entity_type)->getTableMapping(); diff --git a/core/modules/system/src/Tests/Form/ElementTest.php b/core/modules/system/src/Tests/Form/ElementTest.php index 9fa7eca..f24eb4a 100644 --- a/core/modules/system/src/Tests/Form/ElementTest.php +++ b/core/modules/system/src/Tests/Form/ElementTest.php @@ -88,21 +88,6 @@ function testOptions() { } /** - * Tests wrapper ids for checkboxes and radios. - */ - function testWrapperIds() { - $this->drupalGet('form-test/checkboxes-radios'); - - // Verify that wrapper id is different from element id. - foreach (array('checkboxes', 'radios') as $type) { - $element_ids = $this->xpath('//div[@id=:id]', array(':id' => 'edit-' . $type)); - $wrapper_ids = $this->xpath('//fieldset[@id=:id]', array(':id' => 'edit-' . $type . '--wrapper')); - $this->assertTrue(count($element_ids) == 1, format_string('A single element id found for type %type', array('%type' => $type))); - $this->assertTrue(count($wrapper_ids) == 1, format_string('A single wrapper id found for type %type', array('%type' => $type))); - } - } - - /** * Tests button classes. */ function testButtonClasses() { diff --git a/core/modules/system/src/Tests/Form/ElementsVerticalTabsTest.php b/core/modules/system/src/Tests/Form/ElementsVerticalTabsTest.php index 44a47c2..ac74da8 100644 --- a/core/modules/system/src/Tests/Form/ElementsVerticalTabsTest.php +++ b/core/modules/system/src/Tests/Form/ElementsVerticalTabsTest.php @@ -58,12 +58,4 @@ function testWrapperNotShownWhenEmpty() { $wrapper = $this->xpath("//div[@data-vertical-tabs-panes]"); $this->assertFalse(isset($wrapper[0]), 'Vertical tab wrappers are not displayed to unprivileged users.'); } - - /** - * Ensures that default vertical tab is correctly selected. - */ - function testDefaultTab() { - $this->drupalGet('form_test/vertical-tabs'); - $this->assertFieldByName('vertical_tabs__active_tab', 'edit-tab3', t('The default vertical tab is correctly selected.')); - } } diff --git a/core/modules/system/src/Tests/Installer/InstallerTranslationVersionUnitTest.php b/core/modules/system/src/Tests/Installer/InstallerTranslationVersionUnitTest.php index 882af17..031a79d 100644 --- a/core/modules/system/src/Tests/Installer/InstallerTranslationVersionUnitTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerTranslationVersionUnitTest.php @@ -62,84 +62,56 @@ protected function assertVersionFallback($version, $fallback, $message = '', $gr * Tests version fallback of install_get_localization_release(). */ public function testVersionFallback() { - $version = '8.0.0'; - $fallback = array('8.0.0', '8.0.0-rc1', '7.0'); + $version = '8.0'; + $fallback = array('8.0', '8.0-rc1', '7.0'); $this->assertVersionFallback($version, $fallback); - $version = '8.1.0'; - $fallback = array('8.1.0', '8.1.0-rc1', '8.0.0', '7.0'); + $version = '8.1'; + $fallback = array('8.1', '8.0', '7.0'); $this->assertVersionFallback($version, $fallback); - $version = '8.12.0'; - $fallback = array('8.12.0', '8.12.0-rc1', '8.11.0', '8.0.0', '7.0'); + $version = '8.12'; + $fallback = array('8.12', '8.11', '7.0'); $this->assertVersionFallback($version, $fallback); - $version = '8.0.0-dev'; - $fallback = array('8.0.0-rc1', '8.0.0-beta1', '8.0.0-alpha1', '7.0'); + $version = '8.0-dev'; + $fallback = array('8.0-rc1', '8.0-beta1', '8.0-alpha12', '7.0'); $this->assertVersionFallback($version, $fallback); - $version = '8.9.0-dev'; - $fallback = array('8.9.0-rc1', '8.9.0-beta1', '8.9.0-alpha1', '8.8.0', '8.0.0', '7.0'); + $version = '8.9-dev'; + $fallback = array('8.8', '7.0'); $this->assertVersionFallback($version, $fallback); - $version = '8.0.0-alpha3'; - $fallback = array('8.0.0-alpha3', '8.0.0-alpha2', '7.0'); + $version = '8.0-alpha3'; + $fallback = array('8.0-alpha3', '8.0-alpha2', '7.0'); $this->assertVersionFallback($version, $fallback); - $version = '8.0.0-alpha1'; - $fallback = array('8.0.0-alpha1', '7.0'); + $version = '8.0-alpha1'; + $fallback = array('8.0-alpha1', '7.0'); $this->assertVersionFallback($version, $fallback); - $version = '8.0.0-beta2'; - $fallback = array('8.0.0-beta2', '8.0.0-beta1', '8.0.0-alpha1', '7.0'); + $version = '8.0-beta2'; + $fallback = array('8.0-beta2', '8.0-beta1', '7.0'); $this->assertVersionFallback($version, $fallback); - $version = '8.0.0-beta1'; - $fallback = array('8.0.0-beta1', '8.0.0-alpha1', '7.0'); + $version = '8.0-beta1'; + $fallback = array('8.0-beta1', '8.0-alpha2', '7.0'); $this->assertVersionFallback($version, $fallback); - $version = '8.0.0-rc8'; - $fallback = array('8.0.0-rc8', '8.0.0-rc7', '8.0.0-beta1', '7.0'); + $version = '8.0-rc8'; + $fallback = array('8.0-rc8', '8.0-rc7', '7.0'); $this->assertVersionFallback($version, $fallback); - $version = '8.0.0-rc1'; - $fallback = array('8.0.0-rc1', '8.0.0-beta1', '7.0'); + $version = '8.0-rc1'; + $fallback = array('8.0-rc1', '8.0-beta1', '7.0'); $this->assertVersionFallback($version, $fallback); - $version = '8.2.0-beta1'; - $fallback = array('8.2.0-beta1', '8.2.0-alpha1', '8.1.0', '8.0.0', '7.0'); + $version = '8.0-foo2'; + $fallback = array('7.0'); $this->assertVersionFallback($version, $fallback); - $version = '8.2.0-beta7'; - $fallback = array('8.2.0-beta7', '8.2.0-beta6', '8.2.0-alpha1', '8.1.0', '8.0.0', '7.0'); - $this->assertVersionFallback($version, $fallback); - - $version = '8.2.0-rc1'; - $fallback = array('8.2.0-rc1', '8.2.0-beta1', '8.1.0', '8.0.0', '7.0'); - $this->assertVersionFallback($version, $fallback); - - $version = '8.2.0-rc2'; - $fallback = array('8.2.0-rc2', '8.2.0-rc1', '8.2.0-beta1', '8.1.0', '8.0.0', '7.0'); - $this->assertVersionFallback($version, $fallback); - - $version = '8.0.0-foo2'; - $fallback = array('8.0.0', '7.0'); - $this->assertVersionFallback($version, $fallback); - - $version = '8.0.4'; - $fallback = array('8.0.4', '8.0.3', '8.0.0', '7.0'); - $this->assertVersionFallback($version, $fallback); - - $version = '8.3.5'; - $fallback = array('8.3.5', '8.3.4', '8.3.0', '8.2.0', '8.0.0', '7.0'); - $this->assertVersionFallback($version, $fallback); - - $version = '99.0.1'; - $fallback = array('99.0.1', '99.0.0' ,'98.0.0'); - $this->assertVersionFallback($version, $fallback); - - $version = '99.7.1'; - $fallback = array('99.7.1', '99.7.0', '99.6.0', '99.0.0' ,'98.0.0'); + $version = '99.2'; + $fallback = array('99.2', '99.1', '98.0'); $this->assertVersionFallback($version, $fallback); } } diff --git a/core/modules/system/src/Tests/KeyValueStore/KeyValueContentEntityStorageTest.php b/core/modules/system/src/Tests/KeyValueStore/KeyValueContentEntityStorageTest.php index 679fe71..721b8d3 100644 --- a/core/modules/system/src/Tests/KeyValueStore/KeyValueContentEntityStorageTest.php +++ b/core/modules/system/src/Tests/KeyValueStore/KeyValueContentEntityStorageTest.php @@ -37,7 +37,7 @@ protected function setUp() { * Tests CRUD operations. */ function testCRUD() { - $default_langcode = language_default()->getId(); + $default_langcode = language_default()->id; // Verify default properties on a newly created empty entity. $empty = entity_create('entity_test_label'); $this->assertIdentical($empty->id->value, NULL); diff --git a/core/modules/system/src/Tests/Mail/MailTest.php b/core/modules/system/src/Tests/Mail/MailTest.php index 78ebf24..a4dcf5f 100644 --- a/core/modules/system/src/Tests/Mail/MailTest.php +++ b/core/modules/system/src/Tests/Mail/MailTest.php @@ -60,7 +60,7 @@ public function testCancelMessage() { \Drupal::state()->set('system.test_mail_collector', array()); // Send a test message that simpletest_mail_alter should cancel. - drupal_mail('simpletest', 'cancel_test', 'cancel@example.com', $language_interface->getId()); + drupal_mail('simpletest', 'cancel_test', 'cancel@example.com', $language_interface->id); // Retrieve sent message. $captured_emails = \Drupal::state()->get('system.test_mail_collector'); $sent_message = end($captured_emails); diff --git a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php index c512364..eaed0a6 100644 --- a/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php +++ b/core/modules/system/src/Tests/System/TokenReplaceUnitTest.php @@ -40,7 +40,7 @@ public function testSystemTokenRecognition() { foreach ($tests as $test) { $input = $test['prefix'] . '[site:name]' . $test['suffix']; $expected = $test['prefix'] . 'Drupal' . $test['suffix']; - $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId())); + $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->id)); $this->assertTrue($output == $expected, format_string('Token recognized in string %string', array('%string' => $input))); } @@ -61,12 +61,12 @@ public function testClear() { // Replace with with the clear parameter, only the valid token should remain. $target = String::checkPlain(\Drupal::config('system.site')->get('name')); - $result = $this->tokenService->replace($source, array(), array('langcode' => $this->interfaceLanguage->getId(), 'clear' => TRUE)); + $result = $this->tokenService->replace($source, array(), array('langcode' => $this->interfaceLanguage->id, 'clear' => TRUE)); $this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.'); $target .= '[user:name]'; $target .= '[bogus:token]'; - $result = $this->tokenService->replace($source, array(), array('langcode' => $this->interfaceLanguage->getId())); + $result = $this->tokenService->replace($source, array(), array('langcode' => $this->interfaceLanguage->id)); $this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.'); } @@ -106,7 +106,7 @@ public function testSystemSiteTokenReplacement() { $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId())); + $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->id)); $this->assertEqual($output, $expected, format_string('Sanitized system site information token %token replaced.', array('%token' => $input))); } @@ -115,7 +115,7 @@ public function testSystemSiteTokenReplacement() { $tests['[site:slogan]'] = $config->get('slogan'); foreach ($tests as $input => $expected) { - $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId(), 'sanitize' => FALSE)); + $output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->id, 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized system site information token %token replaced.', array('%token' => $input))); } @@ -141,18 +141,18 @@ public function testSystemDateTokenReplacement() { // Generate and test tokens. $tests = array(); $date_formatter = \Drupal::service('date.formatter'); - $tests['[date:short]'] = $date_formatter->format($date, 'short', '', NULL, $this->interfaceLanguage->getId()); - $tests['[date:medium]'] = $date_formatter->format($date, 'medium', '', NULL, $this->interfaceLanguage->getId()); - $tests['[date:long]'] = $date_formatter->format($date, 'long', '', NULL, $this->interfaceLanguage->getId()); - $tests['[date:custom:m/j/Y]'] = $date_formatter->format($date, 'custom', 'm/j/Y', NULL, $this->interfaceLanguage->getId()); - $tests['[date:since]'] = $date_formatter->formatInterval(REQUEST_TIME - $date, 2, $this->interfaceLanguage->getId()); + $tests['[date:short]'] = $date_formatter->format($date, 'short', '', NULL, $this->interfaceLanguage->id); + $tests['[date:medium]'] = $date_formatter->format($date, 'medium', '', NULL, $this->interfaceLanguage->id); + $tests['[date:long]'] = $date_formatter->format($date, 'long', '', NULL, $this->interfaceLanguage->id); + $tests['[date:custom:m/j/Y]'] = $date_formatter->format($date, 'custom', 'm/j/Y', NULL, $this->interfaceLanguage->id); + $tests['[date:since]'] = $date_formatter->formatInterval(REQUEST_TIME - $date, 2, $this->interfaceLanguage->id); $tests['[date:raw]'] = Xss::filter($date); // Test to make sure that we generated something for each token. $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $this->tokenService->replace($input, array('date' => $date), array('langcode' => $this->interfaceLanguage->getId())); + $output = $this->tokenService->replace($input, array('date' => $date), array('langcode' => $this->interfaceLanguage->id)); $this->assertEqual($output, $expected, format_string('Date token %token replaced.', array('%token' => $input))); } } diff --git a/core/modules/system/src/Tests/Theme/TwigTransTest.php b/core/modules/system/src/Tests/Theme/TwigTransTest.php index 956e7be..942a6dc 100644 --- a/core/modules/system/src/Tests/Theme/TwigTransTest.php +++ b/core/modules/system/src/Tests/Theme/TwigTransTest.php @@ -74,7 +74,7 @@ protected function setUp() { $this->rebuildContainer(); // Check that lolspeak is the default language for the site. - $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), 'xx', 'Lolspeak is the default language'); + $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->id, 'xx', 'Lolspeak is the default language'); } /** diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 26a6e90..1c930f7 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -569,7 +569,7 @@ function system_page_build(&$page) { array( 'path' => current_path(), 'front' => drupal_is_front_page(), - 'language' => \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId(), + 'language' => \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_URL)->id, 'query' => \Drupal::request()->query->all(), ) ); diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module index 12950bc..41906a1 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -404,28 +404,28 @@ function entity_test_entity_operation_alter(array &$operations, EntityInterface * Implements hook_entity_translation_insert(). */ function entity_test_entity_translation_insert(EntityInterface $translation) { - _entity_test_record_hooks('entity_translation_insert', $translation->language()->getId()); + _entity_test_record_hooks('entity_translation_insert', $translation->language()->id); } /** * Implements hook_entity_translation_delete(). */ function entity_test_entity_translation_delete(EntityInterface $translation) { - _entity_test_record_hooks('entity_translation_delete', $translation->language()->getId()); + _entity_test_record_hooks('entity_translation_delete', $translation->language()->id); } /** * Implements hook_ENTITY_TYPE_translation_insert(). */ function entity_test_entity_test_mul_translation_insert(EntityInterface $translation) { - _entity_test_record_hooks('entity_test_mul_translation_insert', $translation->language()->getId()); + _entity_test_record_hooks('entity_test_mul_translation_insert', $translation->language()->id); } /** * Implements hook_ENTITY_TYPE_translation_delete(). */ function entity_test_entity_test_mul_translation_delete(EntityInterface $translation) { - _entity_test_record_hooks('entity_test_mul_translation_delete', $translation->language()->getId()); + _entity_test_record_hooks('entity_test_mul_translation_delete', $translation->language()->id); } /** @@ -443,7 +443,7 @@ function entity_test_entity_test_mul_translation_delete(EntityInterface $transla * @see \Drupal\field\Entity\FieldConfig::$default_value */ function entity_test_field_default_value(FieldableEntityInterface $entity, FieldDefinitionInterface $definition) { - return array(array('value' => $definition->getName() . '_' . $entity->language()->getId())); + return array(array('value' => $definition->getName() . '_' . $entity->language()->id)); } /** diff --git a/core/modules/system/tests/modules/entity_test/src/EntityTestForm.php b/core/modules/system/tests/modules/entity_test/src/EntityTestForm.php index 8a60fef..1db41d4 100644 --- a/core/modules/system/tests/modules/entity_test/src/EntityTestForm.php +++ b/core/modules/system/tests/modules/entity_test/src/EntityTestForm.php @@ -38,7 +38,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['langcode'] = array( '#title' => t('Language'), '#type' => 'language_select', - '#default_value' => $entity->getUntranslated()->language()->getId(), + '#default_value' => $entity->getUntranslated()->language()->id, '#languages' => LanguageInterface::STATE_ALL, ); diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsForm.php index b9dc7d8..4a69660 100644 --- a/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsForm.php +++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestVerticalTabsForm.php @@ -23,26 +23,29 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { - $tab_count = 3; - $form['vertical_tabs'] = array( '#type' => 'vertical_tabs', - '#default_tab' => 'edit-tab' . $tab_count, ); - - for ($i = 1; $i <= $tab_count; $i++) { - $form['tab' . $i] = array( - '#type' => 'fieldset', - '#title' => t('Tab !num', array('!num' => $i)), - '#group' => 'vertical_tabs', - '#access' => \Drupal::currentUser()->hasPermission('access vertical_tab_test tabs'), - ); - $form['tab' . $i]['field' . $i] = array( - '#title' => t('Field !num', array('!num' => $i)), - '#type' => 'textfield', - - ); - } + $form['tab1'] = array( + '#type' => 'details', + '#title' => t('Tab 1'), + '#group' => 'vertical_tabs', + '#access' => \Drupal::currentUser()->hasPermission('access vertical_tab_test tabs'), + ); + $form['tab1']['field1'] = array( + '#title' => t('Field 1'), + '#type' => 'textfield', + ); + $form['tab2'] = array( + '#type' => 'details', + '#title' => t('Tab 2'), + '#group' => 'vertical_tabs', + '#access' => \Drupal::currentUser()->hasPermission('access vertical_tab_test tabs'), + ); + $form['tab2']['field2'] = array( + '#title' => t('Field 2'), + '#type' => 'textfield', + ); return $form; } diff --git a/core/modules/system/theme.api.php b/core/modules/system/theme.api.php index 2e41d6a..f74af95 100644 --- a/core/modules/system/theme.api.php +++ b/core/modules/system/theme.api.php @@ -448,7 +448,7 @@ function hook_theme_suggestions_HOOK(array $variables) { */ function hook_theme_suggestions_alter(array &$suggestions, array $variables, $hook) { // Add an interface-language specific suggestion to all theme hooks. - $suggestions[] = $hook . '__' . \Drupal::languageManager()->getCurrentLanguage()->getId(); + $suggestions[] = $hook . '__' . \Drupal::languageManager()->getCurrentLanguage()->id; } /** diff --git a/core/modules/taxonomy/src/TermForm.php b/core/modules/taxonomy/src/TermForm.php index 2136b0f..65f1cfd 100644 --- a/core/modules/taxonomy/src/TermForm.php +++ b/core/modules/taxonomy/src/TermForm.php @@ -33,7 +33,7 @@ public function form(array $form, FormStateInterface $form_state) { '#type' => 'language_select', '#title' => $this->t('Language'), '#languages' => LanguageInterface::STATE_ALL, - '#default_value' => $term->getUntranslated()->language()->getId(), + '#default_value' => $term->getUntranslated()->language()->id, '#access' => !empty($language_configuration['language_show']), ); diff --git a/core/modules/taxonomy/src/Tests/TermLanguageTest.php b/core/modules/taxonomy/src/Tests/TermLanguageTest.php index 71cacee..4264c0b 100644 --- a/core/modules/taxonomy/src/Tests/TermLanguageTest.php +++ b/core/modules/taxonomy/src/Tests/TermLanguageTest.php @@ -57,7 +57,7 @@ function testTermLanguage() { $this->drupalPostForm(NULL, $edit, t('Save')); $terms = taxonomy_term_load_multiple_by_name($edit['name[0][value]']); $term = reset($terms); - $this->assertEqual($term->language()->getId(), $edit['langcode'], 'The term contains the correct langcode.'); + $this->assertEqual($term->language()->id, $edit['langcode'], 'The term contains the correct langcode.'); // Check if on the edit page the language is correct. $this->drupalGet('taxonomy/term/' . $term->id() . '/edit'); diff --git a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php index f25591b..d343995 100644 --- a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php +++ b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php @@ -91,7 +91,7 @@ function testTaxonomyTokenReplacement() { $tests['[term:vocabulary:name]'] = String::checkPlain($this->vocabulary->name); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('term' => $term1), array('langcode' => $language_interface->getId())); + $output = $token_service->replace($input, array('term' => $term1), array('langcode' => $language_interface->id)); $this->assertEqual($output, $expected, format_string('Sanitized taxonomy term token %token replaced.', array('%token' => $input))); } @@ -111,7 +111,7 @@ function testTaxonomyTokenReplacement() { $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('term' => $term2), array('langcode' => $language_interface->getId())); + $output = $token_service->replace($input, array('term' => $term2), array('langcode' => $language_interface->id)); $this->assertEqual($output, $expected, format_string('Sanitized taxonomy term token %token replaced.', array('%token' => $input))); } @@ -122,7 +122,7 @@ function testTaxonomyTokenReplacement() { $tests['[term:vocabulary:name]'] = $this->vocabulary->name; foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('term' => $term2), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE)); + $output = $token_service->replace($input, array('term' => $term2), array('langcode' => $language_interface->id, 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized taxonomy term token %token replaced.', array('%token' => $input))); } @@ -138,7 +138,7 @@ function testTaxonomyTokenReplacement() { $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->getId())); + $output = $token_service->replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->id)); $this->assertEqual($output, $expected, format_string('Sanitized taxonomy vocabulary token %token replaced.', array('%token' => $input))); } @@ -147,7 +147,7 @@ function testTaxonomyTokenReplacement() { $tests['[vocabulary:description]'] = $this->vocabulary->description; foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE)); + $output = $token_service->replace($input, array('vocabulary' => $this->vocabulary), array('langcode' => $language_interface->id, 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized taxonomy vocabulary token %token replaced.', array('%token' => $input))); } } diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index fc423d6..e4ecc3b 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -683,7 +683,7 @@ function taxonomy_build_node_index($node) { $field_name = $field->getName(); if ($field->getType() == 'taxonomy_term_reference') { foreach ($node->getTranslationLanguages() as $language) { - foreach ($node->getTranslation($language->getId())->$field_name as $item) { + foreach ($node->getTranslation($language->id)->$field_name as $item) { if (!$item->isEmpty()) { $tid_all[$item->target_id] = $item->target_id; } diff --git a/core/modules/toolbar/src/Element/ToolbarItem.php b/core/modules/toolbar/src/Element/ToolbarItem.php index e596687..5926a37 100644 --- a/core/modules/toolbar/src/Element/ToolbarItem.php +++ b/core/modules/toolbar/src/Element/ToolbarItem.php @@ -29,6 +29,7 @@ public function getInfo() { '#pre_render' => array( array($class, 'preRenderToolbarItem'), ), + '#theme' => 'toolbar_item', 'tab' => array( '#type' => 'link', '#title' => NULL, diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module index a526589..fe49c20 100644 --- a/core/modules/toolbar/toolbar.module +++ b/core/modules/toolbar/toolbar.module @@ -148,7 +148,7 @@ function toolbar_toolbar() { // toolbar_subtrees route. We provide the JavaScript requesting that JSONP // script here with the hash parameter that is needed for that route. // @see toolbar_subtrees_jsonp() - $langcode = \Drupal::languageManager()->getCurrentLanguage()->getId(); + $langcode = \Drupal::languageManager()->getCurrentLanguage()->id; $subtrees_attached['js'][] = array( 'type' => 'setting', 'data' => array('toolbar' => array( diff --git a/core/modules/update/update.fetch.inc b/core/modules/update/update.fetch.inc index fae02d4..64f3ebd 100644 --- a/core/modules/update/update.fetch.inc +++ b/core/modules/update/update.fetch.inc @@ -74,7 +74,7 @@ function _update_cron_notify() { if (!empty($params)) { $notify_list = $update_config->get('notification.emails'); if (!empty($notify_list)) { - $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; foreach ($notify_list as $target) { if ($target_user = user_load_by_mail($target)) { $target_langcode = $target_user->getPreferredLangcode(); diff --git a/core/modules/user/src/AccountForm.php b/core/modules/user/src/AccountForm.php index a8f39aa..99ef5f2 100644 --- a/core/modules/user/src/AccountForm.php +++ b/core/modules/user/src/AccountForm.php @@ -240,9 +240,9 @@ public function form(array $form, FormStateInterface $form_state) { ); } - $user_preferred_langcode = $register ? $language_interface->getId() : $account->getPreferredLangcode(); + $user_preferred_langcode = $register ? $language_interface->id : $account->getPreferredLangcode(); - $user_preferred_admin_langcode = $register ? $language_interface->getId() : $account->getPreferredAdminLangcode(FALSE); + $user_preferred_admin_langcode = $register ? $language_interface->id : $account->getPreferredAdminLangcode(FALSE); // Is the user preferred language added? $user_language_added = FALSE; diff --git a/core/modules/user/src/Entity/User.php b/core/modules/user/src/Entity/User.php index f659d14..6bb533c 100644 --- a/core/modules/user/src/Entity/User.php +++ b/core/modules/user/src/Entity/User.php @@ -372,10 +372,10 @@ function getPreferredLangcode($fallback_to_default = TRUE) { $language_list = language_list(); $preferred_langcode = $this->get('preferred_langcode')->value; if (!empty($preferred_langcode) && isset($language_list[$preferred_langcode])) { - return $language_list[$preferred_langcode]->getId(); + return $language_list[$preferred_langcode]->id; } else { - return $fallback_to_default ? language_default()->getId() : ''; + return $fallback_to_default ? language_default()->id : ''; } } @@ -386,10 +386,10 @@ function getPreferredAdminLangcode($fallback_to_default = TRUE) { $language_list = language_list(); $preferred_langcode = $this->get('preferred_admin_langcode')->value; if (!empty($preferred_langcode) && isset($language_list[$preferred_langcode])) { - return $language_list[$preferred_langcode]->getId(); + return $language_list[$preferred_langcode]->id; } else { - return $fallback_to_default ? language_default()->getId() : ''; + return $fallback_to_default ? language_default()->id : ''; } } diff --git a/core/modules/user/src/Form/UserPasswordForm.php b/core/modules/user/src/Form/UserPasswordForm.php index f06ba29..378f8f3 100644 --- a/core/modules/user/src/Form/UserPasswordForm.php +++ b/core/modules/user/src/Form/UserPasswordForm.php @@ -129,7 +129,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { - $langcode = $this->languageManager->getCurrentLanguage()->getId(); + $langcode = $this->languageManager->getCurrentLanguage()->id; $account = $form_state->getValue('account'); // Mail one time login URL and instructions using current language. diff --git a/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUser.php b/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUser.php index 623dac6..f2c99fe 100644 --- a/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUser.php +++ b/core/modules/user/src/Plugin/LanguageNegotiation/LanguageNegotiationUser.php @@ -36,7 +36,7 @@ public function getLangcode(Request $request = NULL) { // User preference (only for authenticated users). if ($this->languageManager && $this->currentUser->isAuthenticated()) { $preferred_langcode = $this->currentUser->getPreferredLangcode(); - $default_langcode = $this->languageManager->getDefaultLanguage()->getId(); + $default_langcode = $this->languageManager->getDefaultLanguage()->id; $languages = $this->languageManager->getLanguages(); if (!empty($preferred_langcode) && $preferred_langcode != $default_langcode && isset($languages[$preferred_langcode])) { $langcode = $preferred_langcode; diff --git a/core/modules/user/src/Tests/UserInstallTest.php b/core/modules/user/src/Tests/UserInstallTest.php index 33a3238..6b5ddd4 100644 --- a/core/modules/user/src/Tests/UserInstallTest.php +++ b/core/modules/user/src/Tests/UserInstallTest.php @@ -47,8 +47,8 @@ public function testUserInstall() { // Test that the anonymous and administrators languages are equal to the // site's default language. - $this->assertEqual($anon->langcode, \Drupal::languageManager()->getDefaultLanguage()->getId(), 'Anon user language is the default.'); - $this->assertEqual($admin->langcode, \Drupal::languageManager()->getDefaultLanguage()->getId(), 'Admin user language is the default.'); + $this->assertEqual($anon->langcode, \Drupal::languageManager()->getDefaultLanguage()->id); + $this->assertEqual($admin->langcode, \Drupal::languageManager()->getDefaultLanguage()->id); // Test that the administrator is active. $this->assertEqual($admin->status, 1); diff --git a/core/modules/user/src/Tests/UserLanguageCreationTest.php b/core/modules/user/src/Tests/UserLanguageCreationTest.php index fc95906..65e37f9 100644 --- a/core/modules/user/src/Tests/UserLanguageCreationTest.php +++ b/core/modules/user/src/Tests/UserLanguageCreationTest.php @@ -63,7 +63,7 @@ function testLocalUserCreation() { $user = user_load_by_name($username); $this->assertEqual($user->getPreferredLangcode(), $langcode, 'New user has correct preferred language set.'); - $this->assertEqual($user->language()->getId(), $langcode, 'New user has correct profile language set.'); + $this->assertEqual($user->language()->id, $langcode, 'New user has correct profile language set.'); // Register a new user and check if the language selector is hidden. $this->drupalLogout(); @@ -81,7 +81,7 @@ function testLocalUserCreation() { $user = user_load_by_name($username); $this->assertEqual($user->getPreferredLangcode(), $langcode, 'New user has correct preferred language set.'); - $this->assertEqual($user->language()->getId(), $langcode, 'New user has correct profile language set.'); + $this->assertEqual($user->language()->id, $langcode, 'New user has correct profile language set.'); // Test if the admin can use the language selector and if the // correct language is was saved. diff --git a/core/modules/user/src/Tests/UserRegistrationTest.php b/core/modules/user/src/Tests/UserRegistrationTest.php index a1f189d..f6a34bd 100644 --- a/core/modules/user/src/Tests/UserRegistrationTest.php +++ b/core/modules/user/src/Tests/UserRegistrationTest.php @@ -182,8 +182,8 @@ function testRegistrationDefaultValues() { $this->assertTrue(($new_user->getCreatedTime() > REQUEST_TIME - 20 ), 'Correct creation time.'); $this->assertEqual($new_user->isActive(), $config_user_settings->get('register') == USER_REGISTER_VISITORS ? 1 : 0, 'Correct status field.'); $this->assertEqual($new_user->getTimezone(), $config_system_date->get('timezone.default'), 'Correct time zone field.'); - $this->assertEqual($new_user->langcode->value, \Drupal::languageManager()->getDefaultLanguage()->getId(), 'Correct language field.'); - $this->assertEqual($new_user->preferred_langcode->value, \Drupal::languageManager()->getDefaultLanguage()->getId(), 'Correct preferred language field.'); + $this->assertEqual($new_user->langcode->value, \Drupal::languageManager()->getDefaultLanguage()->id, 'Correct language field.'); + $this->assertEqual($new_user->preferred_langcode->value, \Drupal::languageManager()->getDefaultLanguage()->id, 'Correct preferred language field.'); $this->assertEqual($new_user->init->value, $mail, 'Correct init field.'); } diff --git a/core/modules/user/src/Tests/UserRoleAdminTest.php b/core/modules/user/src/Tests/UserRoleAdminTest.php index 427ad8f..7d18b0a 100644 --- a/core/modules/user/src/Tests/UserRoleAdminTest.php +++ b/core/modules/user/src/Tests/UserRoleAdminTest.php @@ -27,7 +27,7 @@ protected function setUp() { */ function testRoleAdministration() { $this->drupalLogin($this->admin_user); - $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); + $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; // Test presence of tab. $this->drupalGet('admin/people/permissions'); $tabs = $this->xpath('//ul[@class=:classes and //a[contains(., :text)]]', array( diff --git a/core/modules/user/src/Tests/UserTokenReplaceTest.php b/core/modules/user/src/Tests/UserTokenReplaceTest.php index 897e2aa..3d9e8fe 100644 --- a/core/modules/user/src/Tests/UserTokenReplaceTest.php +++ b/core/modules/user/src/Tests/UserTokenReplaceTest.php @@ -59,17 +59,17 @@ function testUserTokenReplacement() { $tests['[user:mail]'] = String::checkPlain($account->getEmail()); $tests['[user:url]'] = $account->url('canonical', $url_options); $tests['[user:edit-url]'] = $account->url('edit-form', $url_options); - $tests['[user:last-login]'] = format_date($account->getLastLoginTime(), 'medium', '', NULL, $language_interface->getId()); - $tests['[user:last-login:short]'] = format_date($account->getLastLoginTime(), 'short', '', NULL, $language_interface->getId()); - $tests['[user:created]'] = format_date($account->getCreatedTime(), 'medium', '', NULL, $language_interface->getId()); - $tests['[user:created:short]'] = format_date($account->getCreatedTime(), 'short', '', NULL, $language_interface->getId()); + $tests['[user:last-login]'] = format_date($account->getLastLoginTime(), 'medium', '', NULL, $language_interface->id); + $tests['[user:last-login:short]'] = format_date($account->getLastLoginTime(), 'short', '', NULL, $language_interface->id); + $tests['[user:created]'] = format_date($account->getCreatedTime(), 'medium', '', NULL, $language_interface->id); + $tests['[user:created:short]'] = format_date($account->getCreatedTime(), 'short', '', NULL, $language_interface->id); $tests['[current-user:name]'] = String::checkPlain(user_format_name($global_account)); // Test to make sure that we generated something for each token. $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->getId())); + $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->id)); $this->assertEqual($output, $expected, format_string('Sanitized user token %token replaced.', array('%token' => $input))); } @@ -79,7 +79,7 @@ function testUserTokenReplacement() { $tests['[current-user:name]'] = user_format_name($global_account); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE)); + $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->id, 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized user token %token replaced.', array('%token' => $input))); } @@ -91,7 +91,7 @@ function testUserTokenReplacement() { // Generate tokens with interface language. $link = \Drupal::url('user.page', [], array('absolute' => TRUE)); foreach ($tests as $input => $expected) { - $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->getId(), 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE)); + $output = $token_service->replace($input, array('user' => $account), array('langcode' => $language_interface->id, 'callback' => 'user_mail_tokens', 'sanitize' => FALSE, 'clear' => TRUE)); $this->assertTrue(strpos($output, $link) === 0, 'Generated URL is in interface language.'); } diff --git a/core/modules/user/user.install b/core/modules/user/user.install index 134c251..eca1692 100644 --- a/core/modules/user/user.install +++ b/core/modules/user/user.install @@ -67,7 +67,7 @@ function user_install() { $storage = \Drupal::entityManager()->getStorage('user'); // @todo Rely on the default value for langcode in // https://drupal.org/node/1966436 - $langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); + $langcode = \Drupal::languageManager()->getDefaultLanguage()->id; // Insert a row for the anonymous user. $storage ->create(array( diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 9146aac..61de86c 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -1322,7 +1322,7 @@ function _user_mail_notify($op, $account, $langcode = NULL) { if ($op == 'register_pending_approval') { // If a user registered requiring admin approval, notify the admin, too. // We use the site default language for this. - drupal_mail('user', 'register_pending_approval_admin', $site_mail, \Drupal::languageManager()->getDefaultLanguage()->getId(), $params); + drupal_mail('user', 'register_pending_approval_admin', $site_mail, \Drupal::languageManager()->getDefaultLanguage()->id, $params); } } return empty($mail) ? NULL : $mail['result']; diff --git a/core/modules/views/src/Entity/Render/DefaultLanguageRenderer.php b/core/modules/views/src/Entity/Render/DefaultLanguageRenderer.php index 2e99c12..18875f5 100644 --- a/core/modules/views/src/Entity/Render/DefaultLanguageRenderer.php +++ b/core/modules/views/src/Entity/Render/DefaultLanguageRenderer.php @@ -24,7 +24,7 @@ class DefaultLanguageRenderer extends RendererBase { * A language code. */ protected function getLangcode(ResultRow $row) { - return $row->_entity->getUntranslated()->language()->getId(); + return $row->_entity->getUntranslated()->language()->id; } } diff --git a/core/modules/views/src/Plugin/views/PluginBase.php b/core/modules/views/src/Plugin/views/PluginBase.php index 2edf4c3..179fc05 100644 --- a/core/modules/views/src/Plugin/views/PluginBase.php +++ b/core/modules/views/src/Plugin/views/PluginBase.php @@ -459,14 +459,14 @@ public static function queryLanguageSubstitutions() { $manager = \Drupal::languageManager(); // Handle default language. - $default = $manager->getDefaultLanguage()->getId(); + $default = $manager->getDefaultLanguage()->id; $changes[PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT] = $default; // Handle negotiated languages. $types = $manager->getDefinedLanguageTypesInfo(); foreach ($types as $id => $type) { if (isset($type['name'])) { - $changes['***LANGUAGE_' . $id . '***'] = $manager->getCurrentLanguage($id)->getId(); + $changes['***LANGUAGE_' . $id . '***'] = $manager->getCurrentLanguage($id)->id; } } diff --git a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php index d8cdd7f..57873e4 100644 --- a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php +++ b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php @@ -306,7 +306,7 @@ public function generateResultsKey() { 'build_info' => $build_info, 'roles' => $user->getRoles(), 'super-user' => $user->id() == 1, // special caching for super user. - 'langcode' => \Drupal::languageManager()->getCurrentLanguage()->getId(), + 'langcode' => \Drupal::languageManager()->getCurrentLanguage()->id, 'base_url' => $GLOBALS['base_url'], ); foreach (array('exposed_info', 'page', 'sort', 'order', 'items_per_page', 'offset') as $key) { @@ -335,7 +335,7 @@ public function generateOutputKey() { 'roles' => $user->getRoles(), 'super-user' => $user->id() == 1, // special caching for super user. 'theme' => \Drupal::theme()->getActiveTheme()->getName(), - 'langcode' => \Drupal::languageManager()->getCurrentLanguage()->getId(), + 'langcode' => \Drupal::languageManager()->getCurrentLanguage()->id, 'base_url' => $GLOBALS['base_url'], ); diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php index 3810df3..7503bb7 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php @@ -180,7 +180,7 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio $skip_cache = \Drupal::config('views.settings')->get('skip_cache'); if (empty($view->editing) || !$skip_cache) { - $cid = 'views:unpack_options:' . hash('sha256', serialize(array($this->options, $options))) . ':' . \Drupal::languageManager()->getCurrentLanguage()->getId(); + $cid = 'views:unpack_options:' . hash('sha256', serialize(array($this->options, $options))) . ':' . \Drupal::languageManager()->getCurrentLanguage()->id; if (empty(static::$unpackOptions[$cid])) { $cache = \Drupal::cache('data')->get($cid); if (!empty($cache->data)) { diff --git a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php index b6fa496..c8a127b 100644 --- a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php +++ b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php @@ -693,7 +693,7 @@ protected function instantiateView($form, FormStateInterface $form_state) { 'label' => $form_state->getValue('label'), 'description' => $form_state->getValue('description'), 'base_table' => $this->base_table, - 'langcode' => language_default()->getId(), + 'langcode' => language_default()->id, ); $view = entity_create('view', $values); diff --git a/core/modules/views/src/Tests/Entity/RowEntityRenderersTest.php b/core/modules/views/src/Tests/Entity/RowEntityRenderersTest.php index e820532..f53b53e 100644 --- a/core/modules/views/src/Tests/Entity/RowEntityRenderersTest.php +++ b/core/modules/views/src/Tests/Entity/RowEntityRenderersTest.php @@ -55,7 +55,7 @@ protected function setUp() { // The entity.node.canonical route must exist when nodes are rendered. $this->container->get('router.builder')->rebuild(); - $this->langcodes = array(\Drupal::languageManager()->getDefaultLanguage()->getId()); + $this->langcodes = array(\Drupal::languageManager()->getDefaultLanguage()->id); for ($i = 0; $i < 2; $i++) { $langcode = 'l' . $i; $this->langcodes[] = $langcode; diff --git a/core/modules/views/src/ViewsData.php b/core/modules/views/src/ViewsData.php index 9578994..cfbf254 100644 --- a/core/modules/views/src/ViewsData.php +++ b/core/modules/views/src/ViewsData.php @@ -108,7 +108,7 @@ public function __construct(CacheBackendInterface $cache_backend, ConfigFactoryI $this->moduleHandler = $module_handler; $this->languageManager = $language_manager; - $this->langcode = $this->languageManager->getCurrentLanguage()->getId(); + $this->langcode = $this->languageManager->getCurrentLanguage()->id; $this->skipCache = $config->get('views.settings')->get('skip_cache'); } diff --git a/core/modules/views/views.api.php b/core/modules/views/views.api.php index d5f0529..14b3f1b 100644 --- a/core/modules/views/views.api.php +++ b/core/modules/views/views.api.php @@ -579,8 +579,8 @@ function hook_views_query_substitutions(ViewExecutable $view) { return array( '***CURRENT_VERSION***' => \Drupal::VERSION, '***CURRENT_TIME***' => REQUEST_TIME, - '***LANGUAGE_language_content***' => \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(), - PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT => \Drupal::languageManager()->getDefaultLanguage()->getId(), + '***LANGUAGE_language_content***' => \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->id, + PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT => \Drupal::languageManager()->getDefaultLanguage()->id, ); } diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index ebef6f8..06ccdca 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -901,7 +901,7 @@ function template_preprocess_views_view_rss(&$variables) { $variables['link'] = check_url(_url($path, $url_options)); } - $variables['langcode'] = String::checkPlain(\Drupal::languageManager()->getCurrentLanguage()->getId()); + $variables['langcode'] = String::checkPlain(\Drupal::languageManager()->getCurrentLanguage()->id); $variables['namespaces'] = new Attribute($style->namespaces); $variables['items'] = $items; $variables['channel_elements'] = format_xml_elements($style->channel_elements); diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh old mode 100644 new mode 100755 diff --git a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php index b83c2f3..1287b47 100644 --- a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php @@ -277,11 +277,11 @@ public function testIsTranslatable() { $this->languageManager->expects($this->any()) ->method('isMultilingual') ->will($this->returnValue(TRUE)); - $this->assertTrue($this->entity->language()->getId() == 'en'); + $this->assertTrue($this->entity->language()->id == 'en'); $this->assertFalse($this->entity->language()->isLocked()); $this->assertTrue($this->entity->isTranslatable()); - $this->assertTrue($this->entityUnd->language()->getId() == LanguageInterface::LANGCODE_NOT_SPECIFIED); + $this->assertTrue($this->entityUnd->language()->id == LanguageInterface::LANGCODE_NOT_SPECIFIED); $this->assertTrue($this->entityUnd->language()->isLocked()); $this->assertFalse($this->entityUnd->isTranslatable()); } diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php index b933132..99c783d 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php @@ -114,15 +114,11 @@ protected function setUp() { $this->cache = $this->getMock('Drupal\Core\Cache\CacheBackendInterface'); - $language = $this->getMock('Drupal\Core\Language\LanguageInterface'); - $language->expects($this->any()) - ->method('getId') - ->will($this->returnValue('en')); $this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface'); $this->languageManager->expects($this->any()) ->method('getCurrentLanguage') - ->will($this->returnValue($language)); + ->will($this->returnValue((object) array('id' => 'en'))); $this->languageManager->expects($this->any()) ->method('getLanguages') ->will($this->returnValue(array('en' => (object) array('id' => 'en')))); @@ -950,13 +946,9 @@ public function testGetTranslationFromContext() { $entity->expects($this->exactly(2)) ->method('getUntranslated') ->will($this->returnValue($entity)); - $language = $this->getMock('\Drupal\Core\Language\LanguageInterface'); - $language->expects($this->any()) - ->method('getId') - ->will($this->returnValue('en')); $entity->expects($this->exactly(2)) ->method('language') - ->will($this->returnValue($language)); + ->will($this->returnValue((object) array('id' => 'en'))); $entity->expects($this->exactly(2)) ->method('hasTranslation') ->will($this->returnValueMap(array( @@ -1000,7 +992,8 @@ function testgetExtraFields() { ); $cache_id = 'entity_bundle_extra_fields:' . $entity_type_id . ':' . $bundle . ':' . $language_code; - $language = new Language(array('id' => $language_code)); + $language = new Language(); + $language->id = $language_code; $this->languageManager->expects($this->once()) ->method('getCurrentLanguage') diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php index 6535732..a2034e7 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php @@ -233,7 +233,7 @@ public function testAccess() { * @covers ::language */ public function testLanguage() { - $this->assertSame('en', $this->entity->language()->getId()); + $this->assertSame('en', $this->entity->language()->id); } /** diff --git a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php index 054df81..320f13d 100644 --- a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php +++ b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php @@ -7,7 +7,6 @@ namespace Drupal\Tests\Core\PathProcessor; -use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\PathProcessor\PathProcessorAlias; use Drupal\Core\PathProcessor\PathProcessorDecode; @@ -45,8 +44,10 @@ protected function setUp() { // Set up some languages to be used by the language-based path processor. $languages = array(); - foreach (array('en', 'fr') as $langcode) { - $language = new Language(array('id' => $langcode)); + foreach (array('en' => 'English', 'fr' => 'French') as $langcode => $language_name) { + $language = new \stdClass(); + $language->id = $langcode; + $language->name = $language_name; $languages[$langcode] = $language; } $this->languages = $languages; diff --git a/core/tests/Drupal/Tests/Core/Utility/TokenTest.php b/core/tests/Drupal/Tests/Core/Utility/TokenTest.php index 03878cb..3736f0b 100644 --- a/core/tests/Drupal/Tests/Core/Utility/TokenTest.php +++ b/core/tests/Drupal/Tests/Core/Utility/TokenTest.php @@ -70,10 +70,8 @@ public function testGetInfo() { ), ); - $values = array('id' => $this->randomMachineName()); - $language = $this->getMockBuilder('\Drupal\Core\Language\Language') - ->setConstructorArgs(array($values)) - ->getMock(); + $language = $this->getMock('\Drupal\Core\Language\Language'); + $language->id = $this->randomMachineName(); $this->languageManager->expects($this->once()) ->method('getCurrentLanguage') @@ -86,7 +84,7 @@ public function testGetInfo() { ->method('get'); $this->cache->expects($this->once()) ->method('set') - ->with('token_info:' . $language->getId(), $token_info); + ->with('token_info:' . $language->id, $token_info); $this->moduleHandler->expects($this->once()) ->method('invokeAll')