diff --git a/core/assets/vendor/classList/README.md b/core/assets/vendor/classList/README.md new file mode 100644 index 0000000..dd7359c --- /dev/null +++ b/core/assets/vendor/classList/README.md @@ -0,0 +1,7 @@ +classList.js is a cross-browser JavaScript shim that fully implements `element.classList`. Refer to [the MDN page on `element.classList`][1] for more information. + + +![Tracking image](https://in.getclicky.com/212712ns.gif) + + + [1]: https://developer.mozilla.org/en/DOM/element.classList "MDN / DOM / element.classList" diff --git a/core/assets/vendor/classList/classList.js b/core/assets/vendor/classList/classList.js new file mode 100644 index 0000000..1faaec8 --- /dev/null +++ b/core/assets/vendor/classList/classList.js @@ -0,0 +1,179 @@ +/* + * classList.js: Cross-browser full element.classList implementation. + * 2012-11-15 + * + * By Eli Grey, http://eligrey.com + * Public Domain. + * NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. + */ + +/*global self, document, DOMException */ + +/*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js*/ + +if ("document" in self && !( + "classList" in document.createElement("_") && + "classList" in document.createElementNS("http://www.w3.org/2000/svg", "svg") + )) { + +(function (view) { + +"use strict"; + +if (!('Element' in view)) return; + +var + classListProp = "classList" + , protoProp = "prototype" + , elemCtrProto = view.Element[protoProp] + , objCtr = Object + , strTrim = String[protoProp].trim || function () { + return this.replace(/^\s+|\s+$/g, ""); + } + , arrIndexOf = Array[protoProp].indexOf || function (item) { + var + i = 0 + , len = this.length + ; + for (; i < len; i++) { + if (i in this && this[i] === item) { + return i; + } + } + return -1; + } + // Vendors: please allow content code to instantiate DOMExceptions + , DOMEx = function (type, message) { + this.name = type; + this.code = DOMException[type]; + this.message = message; + } + , checkTokenAndGetIndex = function (classList, token) { + if (token === "") { + throw new DOMEx( + "SYNTAX_ERR" + , "An invalid or illegal string was specified" + ); + } + if (/\s/.test(token)) { + throw new DOMEx( + "INVALID_CHARACTER_ERR" + , "String contains an invalid character" + ); + } + return arrIndexOf.call(classList, token); + } + , ClassList = function (elem) { + var + trimmedClasses = strTrim.call(elem.getAttribute("class") || "") + , classes = trimmedClasses ? trimmedClasses.split(/\s+/) : [] + , i = 0 + , len = classes.length + ; + for (; i < len; i++) { + this.push(classes[i]); + } + this._updateClassName = function () { + elem.setAttribute("class", this.toString()); + }; + } + , classListProto = ClassList[protoProp] = [] + , classListGetter = function () { + return new ClassList(this); + } +; +// Most DOMException implementations don't allow calling DOMException's toString() +// on non-DOMExceptions. Error's toString() is sufficient here. +DOMEx[protoProp] = Error[protoProp]; +classListProto.item = function (i) { + return this[i] || null; +}; +classListProto.contains = function (token) { + token += ""; + return checkTokenAndGetIndex(this, token) !== -1; +}; +classListProto.add = function () { + var + tokens = arguments + , i = 0 + , l = tokens.length + , token + , updated = false + ; + do { + token = tokens[i] + ""; + if (checkTokenAndGetIndex(this, token) === -1) { + this.push(token); + updated = true; + } + } + while (++i < l); + + if (updated) { + this._updateClassName(); + } +}; +classListProto.remove = function () { + var + tokens = arguments + , i = 0 + , l = tokens.length + , token + , updated = false + ; + do { + token = tokens[i] + ""; + var index = checkTokenAndGetIndex(this, token); + if (index !== -1) { + this.splice(index, 1); + updated = true; + } + } + while (++i < l); + + if (updated) { + this._updateClassName(); + } +}; +classListProto.toggle = function (token, forse) { + token += ""; + + var + result = this.contains(token) + , method = result ? + forse !== true && "remove" + : + forse !== false && "add" + ; + + if (method) { + this[method](token); + } + + return !result; +}; +classListProto.toString = function () { + return this.join(" "); +}; + +if (objCtr.defineProperty) { + var classListPropDesc = { + get: classListGetter + , enumerable: true + , configurable: true + }; + try { + objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); + } catch (ex) { // IE 8 doesn't support enumerable:true + if (ex.number === -0x7FF5EC54) { + classListPropDesc.enumerable = false; + objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); + } + } +} else if (objCtr[protoProp].__defineGetter__) { + elemCtrProto.__defineGetter__(classListProp, classListGetter); +} + +}(self)); + +} diff --git a/core/assets/vendor/classList/classList.min.js b/core/assets/vendor/classList/classList.min.js index 99b828c..fa98825 100644 --- a/core/assets/vendor/classList/classList.min.js +++ b/core/assets/vendor/classList/classList.min.js @@ -1,2 +1,2 @@ -/*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js */ -if("document" in self){if(!("classList" in document.createElement("_"))){(function(j){"use strict";if(!("Element" in j)){return}var a="classList",f="prototype",m=j.Element[f],b=Object,k=String[f].trim||function(){return this.replace(/^\s+|\s+$/g,"")},c=Array[f].indexOf||function(q){var p=0,o=this.length;for(;pisFrontPage(); - - if ($is_front_page) { - $variables['root_path'] = TRUE; - } - else { - $system_path = \Drupal::request()->attributes->get('_system_path'); - $variables['root_path'] = explode('/', $system_path)[0]; - } + $path = \Drupal::request()->getPathInfo(); + $variables['root_path'] = explode('/', $path)[1]; $site_config = \Drupal::config('system.site'); // Construct page title. @@ -1363,7 +1356,7 @@ function template_preprocess_html(&$variables) { } // @todo Remove once views is not bypassing the view subscriber anymore. // @see http://drupal.org/node/2068471 - elseif ($is_front_page) { + elseif (drupal_is_front_page()) { $head_title = array( 'title' => t('Home'), 'name' => String::checkPlain($site_config->get('name')), diff --git a/core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php b/core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php index 373a779..f2e25c5 100644 --- a/core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php +++ b/core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php @@ -48,28 +48,11 @@ public function build($class_name) { EOS; $class_start = 'class {{ proxy_class_name }}'; - // For cases in which the implemented interface is a child of another - // interface, getInterfaceNames() also returns the parent. This causes a - // PHP error. - // In order to avoid that, check for each interface, whether one of its - // parents is also in the list and exclude it. - if ($interfaces = $reflection->getInterfaces()) { - foreach ($interfaces as $interface_name => $interface) { - // Exclude all parents from the list of implemented interfaces of the - // class. - if ($parent_interfaces = $interface->getInterfaceNames()) { - foreach ($parent_interfaces as $parent_interface) { - if (isset($interfaces[$parent_interface])) {} - unset($interfaces[$parent_interface]); - } - } + if ($interfaces = $reflection->getInterfaceNames()) { + foreach ($interfaces as &$interface) { + $interface = '\\' . $interface; } - - $interface_names = []; - foreach ($interfaces as $interface) { - $interface_names[] = '\\' . $interface->getName(); - } - $class_start .= ' implements ' . implode(', ', $interface_names); + $class_start .= ' implements ' . implode(', ', $interfaces); } $output .= $this->buildUseStatements(); @@ -119,7 +102,7 @@ public function build($class_name) { $output .= implode("\n", $methods); // Indent the output. - $output = implode("\n", array_map(function ($value) { + $output = implode("\n", array_map(function($value) { if ($value === '') { return $value; } @@ -191,7 +174,7 @@ protected function buildMethod(\ReflectionMethod $reflection_method) { $output .= $this->buildMethodBody($reflection_method); - $output .= "\n" . '}'; + $output .= "\n". '}'; return $output; } diff --git a/core/lib/Drupal/Component/ProxyBuilder/ProxyDumper.php b/core/lib/Drupal/Component/ProxyBuilder/ProxyDumper.php index 7126062..99eae59 100644 --- a/core/lib/Drupal/Component/ProxyBuilder/ProxyDumper.php +++ b/core/lib/Drupal/Component/ProxyBuilder/ProxyDumper.php @@ -16,13 +16,6 @@ class ProxyDumper implements DumperInterface { /** - * Keeps track of already existing proxy classes. - * - * @var array - */ - protected $buildClasses = []; - - /** * The proxy builder. * * @var \Drupal\Component\ProxyBuilder\ProxyBuilder @@ -63,16 +56,7 @@ public function getProxyFactoryCode(Definition $definition, $id) { * {@inheritdoc} */ public function getProxyCode(Definition $definition) { - // Maybe the same class is used in different services, which are both marked - // as lazy (just think about 2 database connections). - // In those cases we should not generate proxy code the second time. - if (!isset($this->buildClasses[$definition->getClass()])) { - $this->buildClasses[$definition->getClass()] = TRUE; - return $this->builder->build($definition->getClass()); - } - else { - return ''; - } + return $this->builder->build($definition->getClass()); } } diff --git a/core/lib/Drupal/Core/Language/Language.php b/core/lib/Drupal/Core/Language/Language.php index f1845ae..7702496 100644 --- a/core/lib/Drupal/Core/Language/Language.php +++ b/core/lib/Drupal/Core/Language/Language.php @@ -10,7 +10,7 @@ /** * An object containing the information for an interface language. * - * @see \Drupal\Core\Language\LanguageManager::getLanguage() + * @see language_default() */ class Language implements LanguageInterface { diff --git a/core/lib/Drupal/Core/Mail/MailManagerInterface.php b/core/lib/Drupal/Core/Mail/MailManagerInterface.php index 5cb446a..78ae865 100644 --- a/core/lib/Drupal/Core/Mail/MailManagerInterface.php +++ b/core/lib/Drupal/Core/Mail/MailManagerInterface.php @@ -31,11 +31,10 @@ * user_preferred_langcode(). If you send email based on form values filled on * the page, there are two additional choices if you are not sending the email * to a user on the site. You can either use the language used to generate the - * page or the site default language. See - * Drupal\Core\Language\LanguageManagerInterface::getDefaultLanguage(). The - * former is good if sending email to the person filling the form, the later - * is good if you send email to an address previously set up (like contact - * addresses in a contact form). + * page or the site default language. See language_default(). The former is + * good if sending email to the person filling the form, the later is good if + * you send email to an address previously set up (like contact addresses in a + * contact form). * * Taking care of always using the proper language is even more important when * sending emails in a row to multiple users. Hook_mail() abstracts whether diff --git a/core/lib/Drupal/Core/Session/UserSession.php b/core/lib/Drupal/Core/Session/UserSession.php index 6af360d..92629d5 100644 --- a/core/lib/Drupal/Core/Session/UserSession.php +++ b/core/lib/Drupal/Core/Session/UserSession.php @@ -188,7 +188,7 @@ function getPreferredLangcode($fallback_to_default = TRUE) { return $language_list[$this->preferred_langcode]->getId(); } else { - return $fallback_to_default ? \Drupal::languageManager()->getDefaultLanguage()->getId() : ''; + return $fallback_to_default ? language_default()->getId() : ''; } } @@ -201,7 +201,7 @@ function getPreferredAdminLangcode($fallback_to_default = TRUE) { return $language_list[$this->preferred_admin_langcode]->getId(); } else { - return $fallback_to_default ? \Drupal::languageManager()->getDefaultLanguage()->getId() : ''; + return $fallback_to_default ? language_default()->getId() : ''; } } diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php index 0c1ee37..eb2306a 100644 --- a/core/lib/Drupal/Core/Template/TwigExtension.php +++ b/core/lib/Drupal/Core/Template/TwigExtension.php @@ -109,7 +109,7 @@ public function getFilters() { // CSS class and ID filters. new \Twig_SimpleFilter('clean_class', '\Drupal\Component\Utility\Html::getClass'), - new \Twig_SimpleFilter('clean_id', '\Drupal\Component\Utility\Html::getId'), + new \Twig_SimpleFilter('clean_id', 'drupal_clean_id_identifier'), ); } diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php index 273d264..aa25cc6 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php @@ -43,7 +43,7 @@ class Language extends TypedData { */ public function getValue() { if (!isset($this->language) && $this->id) { - $this->language = \Drupal::languageManager()->getLanguage($this->id); + $this->language = language_load($this->id); } return $this->language; } diff --git a/core/modules/action/src/Plugin/Action/EmailAction.php b/core/modules/action/src/Plugin/Action/EmailAction.php index ae9bd00..d93152d 100644 --- a/core/modules/action/src/Plugin/Action/EmailAction.php +++ b/core/modules/action/src/Plugin/Action/EmailAction.php @@ -11,7 +11,6 @@ use Drupal\Core\Action\ConfigurableActionBase; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Mail\MailManagerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Session\AccountInterface; @@ -58,12 +57,6 @@ class EmailAction extends ConfigurableActionBase implements ContainerFactoryPlug */ protected $mailManager; - /** The language manager. - * - * @var \Drupal\Core\Language\LanguageManagerInterface - */ - protected $languageManager; - /** * Constructs a EmailAction object. * @@ -81,17 +74,14 @@ class EmailAction extends ConfigurableActionBase implements ContainerFactoryPlug * A logger instance. * @param \Drupal\Core\Mail\MailManagerInterface * The mail manager. - * @param \Drupal\Core\Language\LanguageManagerInterface - * The language manager. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, Token $token, EntityManagerInterface $entity_manager, LoggerInterface $logger, MailManagerInterface $mail_manager, LanguageManagerInterface $language_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, Token $token, EntityManagerInterface $entity_manager, LoggerInterface $logger, MailManagerInterface $mail_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->token = $token; $this->storage = $entity_manager->getStorage('user'); $this->logger = $logger; $this->mailManager = $mail_manager; - $this->languageManager = $language_manager; } /** @@ -102,8 +92,7 @@ public static function create(ContainerInterface $container, array $configuratio $container->get('token'), $container->get('entity.manager'), $container->get('logger.factory')->get('action'), - $container->get('plugin.manager.mail'), - $container->get('language_manager') + $container->get('plugin.manager.mail') ); } @@ -126,7 +115,7 @@ public function execute($entity = NULL) { $langcode = $recipient_account->getPreferredLangcode(); } else { - $langcode = $this->languageManager->getDefaultLanguage()->getId(); + $langcode = language_default()->getId(); } $params = array('context' => $this->configuration); diff --git a/core/modules/ckeditor/templates/ckeditor-settings-toolbar.html.twig b/core/modules/ckeditor/templates/ckeditor-settings-toolbar.html.twig index daf1301..18d3558 100644 --- a/core/modules/ckeditor/templates/ckeditor-settings-toolbar.html.twig +++ b/core/modules/ckeditor/templates/ckeditor-settings-toolbar.html.twig @@ -68,7 +68,6 @@ {% endfor %} - diff --git a/core/modules/comment/comment.tokens.inc b/core/modules/comment/comment.tokens.inc index 1bae72e..0e27b92 100644 --- a/core/modules/comment/comment.tokens.inc +++ b/core/modules/comment/comment.tokens.inc @@ -110,7 +110,7 @@ function comment_tokens($type, $tokens, array $data = array(), array $options = $url_options = array('absolute' => TRUE); if (isset($options['langcode'])) { - $url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']); + $url_options['language'] = language_load($options['langcode']); $langcode = $options['langcode']; } else { diff --git a/core/modules/config/src/Tests/ConfigLanguageOverrideTest.php b/core/modules/config/src/Tests/ConfigLanguageOverrideTest.php index 4970681..cc754d4 100644 --- a/core/modules/config/src/Tests/ConfigLanguageOverrideTest.php +++ b/core/modules/config/src/Tests/ConfigLanguageOverrideTest.php @@ -39,7 +39,7 @@ function testConfigLanguageOverride() { // The language module implements a config factory override object that // overrides configuration when the Language module is enabled. This test ensures that // English overrides work. - \Drupal::languageManager()->setConfigOverrideLanguage(\Drupal::languageManager()->getLanguage('en')); + \Drupal::languageManager()->setConfigOverrideLanguage(language_load('en')); $config = \Drupal::config('config_test.system'); $this->assertIdentical($config->get('foo'), 'en bar'); @@ -50,11 +50,11 @@ function testConfigLanguageOverride() { ConfigurableLanguage::createFromLangcode('fr')->save(); ConfigurableLanguage::createFromLangcode('de')->save(); - \Drupal::languageManager()->setConfigOverrideLanguage(\Drupal::languageManager()->getLanguage('fr')); + \Drupal::languageManager()->setConfigOverrideLanguage(language_load('fr')); $config = \Drupal::config('config_test.system'); $this->assertIdentical($config->get('foo'), 'fr bar'); - \Drupal::languageManager()->setConfigOverrideLanguage(\Drupal::languageManager()->getLanguage('de')); + \Drupal::languageManager()->setConfigOverrideLanguage(language_load('de')); $config = \Drupal::config('config_test.system'); $this->assertIdentical($config->get('foo'), 'de bar'); @@ -94,7 +94,7 @@ function testConfigLanguageOverride() { $this->assertIdentical($config->get('value'), array('key' => 'override')); // Ensure renaming the config will rename the override. - \Drupal::languageManager()->setConfigOverrideLanguage(\Drupal::languageManager()->getLanguage('en')); + \Drupal::languageManager()->setConfigOverrideLanguage(language_load('en')); \Drupal::configFactory()->rename('config_test.foo', 'config_test.bar'); $config = \Drupal::config('config_test.bar'); $this->assertEqual($config->get('value'), array('key' => 'original')); diff --git a/core/modules/config_translation/src/ConfigEntityMapper.php b/core/modules/config_translation/src/ConfigEntityMapper.php index 08ce8a6..e9bdc60 100644 --- a/core/modules/config_translation/src/ConfigEntityMapper.php +++ b/core/modules/config_translation/src/ConfigEntityMapper.php @@ -11,7 +11,6 @@ use Drupal\Core\Config\TypedConfigManagerInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; -use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Routing\RouteMatch; use Drupal\Core\Routing\RouteProviderInterface; use Drupal\Core\StringTranslation\TranslationInterface; @@ -77,11 +76,9 @@ class ConfigEntityMapper extends ConfigNamesMapper { * The string translation manager. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. - * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager - * The language manager. */ - public function __construct($plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, LocaleConfigManager $locale_config_manager, ConfigMapperManagerInterface $config_mapper_manager, RouteProviderInterface $route_provider, TranslationInterface $translation_manager, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager) { - parent::__construct($plugin_id, $plugin_definition, $config_factory, $typed_config, $locale_config_manager, $config_mapper_manager, $route_provider, $translation_manager, $language_manager); + public function __construct($plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, LocaleConfigManager $locale_config_manager, ConfigMapperManagerInterface $config_mapper_manager, RouteProviderInterface $route_provider, TranslationInterface $translation_manager, EntityManagerInterface $entity_manager) { + parent::__construct($plugin_id, $plugin_definition, $config_factory, $typed_config, $locale_config_manager, $config_mapper_manager, $route_provider, $translation_manager); $this->setType($plugin_definition['entity_type']); $this->entityManager = $entity_manager; @@ -102,8 +99,7 @@ public static function create(ContainerInterface $container, array $configuratio $container->get('plugin.manager.config_translation.mapper'), $container->get('router.route_provider'), $container->get('string_translation'), - $container->get('entity.manager'), - $container->get('language_manager') + $container->get('entity.manager') ); } diff --git a/core/modules/config_translation/src/ConfigNamesMapper.php b/core/modules/config_translation/src/ConfigNamesMapper.php index 95d7e39..e86d2b7 100644 --- a/core/modules/config_translation/src/ConfigNamesMapper.php +++ b/core/modules/config_translation/src/ConfigNamesMapper.php @@ -11,7 +11,6 @@ use Drupal\Core\Config\TypedConfigManagerInterface; use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageInterface; -use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Routing\RouteProviderInterface; use Drupal\Core\StringTranslation\TranslationInterface; @@ -85,13 +84,6 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con protected $langcode = NULL; /** - * The language manager. - * - * @var \Drupal\Core\Language\LanguageManagerInterface - */ - protected $languageManager; - - /** * Constructs a ConfigNamesMapper. * * @param $plugin_id @@ -118,14 +110,12 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con * The route provider. * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation * The string translation manager. - * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager - * The language manager. * * @throws \Symfony\Component\Routing\Exception\RouteNotFoundException * Throws an exception if the route specified by the 'base_route_name' in * the plugin definition could not be found by the route provider. */ - public function __construct($plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, LocaleConfigManager $locale_config_manager, ConfigMapperManagerInterface $config_mapper_manager, RouteProviderInterface $route_provider, TranslationInterface $string_translation, LanguageManagerInterface $language_manager) { + public function __construct($plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, LocaleConfigManager $locale_config_manager, ConfigMapperManagerInterface $config_mapper_manager, RouteProviderInterface $route_provider, TranslationInterface $string_translation) { $this->pluginId = $plugin_id; $this->pluginDefinition = $plugin_definition; $this->routeProvider = $route_provider; @@ -136,7 +126,6 @@ public function __construct($plugin_id, $plugin_definition, ConfigFactoryInterfa $this->configMapperManager = $config_mapper_manager; $this->stringTranslation = $string_translation; - $this->languageManager = $language_manager; } /** @@ -153,8 +142,7 @@ public static function create(ContainerInterface $container, array $configuratio $container->get('locale.config.typed'), $container->get('plugin.manager.config_translation.mapper'), $container->get('router.route_provider'), - $container->get('string_translation'), - $container->get('language_manager') + $container->get('string_translation') ); } @@ -412,7 +400,7 @@ public function getLangcode() { */ public function getLanguageWithFallback() { $langcode = $this->getLangcode(); - $language = $this->languageManager->getLanguage($langcode); + $language = language_load($langcode); // If the language of the file is English but English is not a configured // language on the site, create a mock language object to represent this // language run-time. In this case, the title of the language is diff --git a/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php b/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php index f603740..b7146a3 100644 --- a/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php +++ b/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php @@ -121,7 +121,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Request $ $mapper = $this->configMapperManager->createInstance($plugin_id); $mapper->populateFromRequest($request); - $language = $this->languageManager->getLanguage($langcode); + $language = language_load($langcode); if (!$language) { throw new NotFoundHttpException(); } diff --git a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php index c36176c..6ab80f7 100644 --- a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php +++ b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php @@ -136,7 +136,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Request $ $mapper = $this->configMapperManager->createInstance($plugin_id); $mapper->populateFromRequest($request); - $language = $this->languageManager->getLanguage($langcode); + $language = language_load($langcode); if (!$language) { throw new NotFoundHttpException(); } diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php index 0ef1b31..56fec9a 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php @@ -348,7 +348,7 @@ public function testContactConfigEntityTranslation() { // Test that delete links work and operations perform properly. foreach ($this->langcodes as $langcode) { - $replacements = array('%label' => t('!label !entity_type', array('!label' => $label, '!entity_type' => Unicode::strtolower(t('Contact form')))), '@language' => \Drupal::languageManager()->getLanguage($langcode)->getName()); + $replacements = array('%label' => t('!label !entity_type', array('!label' => $label, '!entity_type' => Unicode::strtolower(t('Contact form')))), '@language' => language_load($langcode)->getName()); $this->drupalGet("$translation_base_url/$langcode/delete"); $this->assertRaw(t('Are you sure you want to delete the @language translation of %label?', $replacements)); diff --git a/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php b/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php index f2906d1..2b1c67e 100644 --- a/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php +++ b/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php @@ -47,13 +47,6 @@ class ConfigEntityMapperTest extends UnitTestCase { */ protected $routeProvider; - /** - * The mocked language manager. - * - * @var \Drupal\Core\Language\LanguageManagerInterface $language_manager|\PHPUnit_Framework_MockObject_MockObject - */ - protected $languageManager; - protected function setUp() { $this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); @@ -82,8 +75,6 @@ protected function setUp() { ->disableOriginalConstructor() ->getMock(); - $this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface'); - $this->configEntityMapper = new ConfigEntityMapper( 'configurable_language', $definition, @@ -93,8 +84,7 @@ protected function setUp() { $this->getMock('Drupal\config_translation\ConfigMapperManagerInterface'), $this->routeProvider, $this->getStringTranslationStub(), - $this->entityManager, - $this->languageManager + $this->entityManager ); } diff --git a/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php b/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php index 59c1469..19cd758 100644 --- a/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php +++ b/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php @@ -81,13 +81,6 @@ class ConfigNamesMapperTest extends UnitTestCase { */ protected $urlGenerator; - /** - * The mocked language manager. - * - * @var \Drupal\Core\Language\LanguageManagerInterface $language_manager|\PHPUnit_Framework_MockObject_MockObject - */ - protected $languageManager; - protected function setUp() { $this->routeProvider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface'); @@ -120,8 +113,6 @@ protected function setUp() { ->with('system.site_information_settings') ->will($this->returnValue($this->baseRoute)); - $this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface'); - $this->configNamesMapper = new TestConfigNamesMapper( 'system.site_information_settings', $this->pluginDefinition, @@ -130,8 +121,7 @@ protected function setUp() { $this->localeConfigManager, $this->configMapperManager, $this->routeProvider, - $this->getStringTranslationStub(), - $this->languageManager + $this->getStringTranslationStub() ); } diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index 9700321..7444b6e 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -91,7 +91,7 @@ function contact_mail($key, &$message, $params) { $contact_message = $params['contact_message']; /** @var $sender \Drupal\user\UserInterface */ $sender = $params['sender']; - $language = \Drupal::languageManager()->getLanguage($message['langcode']); + $language = language_load($message['langcode']); $variables = array( '!site-name' => \Drupal::config('system.site')->get('name'), diff --git a/core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php b/core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php index 0dd98bf..1dfec07 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationContextualLinksTest.php @@ -65,7 +65,7 @@ class ContentTranslationContextualLinksTest extends WebTestBase { protected function setUp() { parent::setUp(); // Set up an additional language. - $this->langcodes = array(\Drupal::languageManager()->getDefaultLanguage()->getId(), 'es'); + $this->langcodes = array(language_default()->getId(), 'es'); ConfigurableLanguage::createFromLangcode('es')->save(); // Create a content type. diff --git a/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php b/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php index 9ae79a7..da87544 100644 --- a/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php +++ b/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php @@ -122,12 +122,8 @@ public function testRelationship() { $this->executeView($view); foreach (array_keys($view->result) as $index) { - // Check that the actual ID of the entity is the expected one. + // Just check that the actual ID of the entity is the expected one. $this->assertEqual($view->result[$index]->id, $this->entities[$index + 1]->id()); - - // Also check that we have the correct result entity. - $this->assertEqual($view->result[$index]->_entity->id(), $this->entities[$index + 1]->id()); - // Test the forward relationship. // The second and third entity refer to the first one. // The value key on the result will be in the format @@ -145,7 +141,6 @@ public function testRelationship() { foreach (array_keys($view->result) as $index) { $this->assertEqual($view->result[$index]->id, $this->entities[$index + 1]->id()); - $this->assertEqual($view->result[$index]->_entity->id(), $this->entities[$index + 1]->id()); // The second and third entity refer to the first one. $this->assertEqual($view->result[$index]->entity_test_entity_test__field_test_id, $index == 0 ? NULL : 1); } diff --git a/core/modules/entity_reference/src/Tests/Views/SelectionTest.php b/core/modules/entity_reference/src/Tests/Views/SelectionTest.php index 26cc00e..60d6f04 100644 --- a/core/modules/entity_reference/src/Tests/Views/SelectionTest.php +++ b/core/modules/entity_reference/src/Tests/Views/SelectionTest.php @@ -8,7 +8,6 @@ namespace Drupal\entity_reference\Tests\Views; use Drupal\simpletest\WebTestBase; -use Drupal\views\Views; /** * Tests entity reference selection handler. @@ -20,33 +19,18 @@ class SelectionTest extends WebTestBase { public static $modules = array('node', 'views', 'entity_reference', 'entity_reference_test', 'entity_test'); /** - * Nodes for testing. - * - * @var array - */ - protected $nodes = array(); - - /** - * The entity reference field to test. - * - * @var \Drupal\Core\Field\FieldDefinitionInterface - */ - protected $field; - - /** - * {@inheritdoc} + * Tests the selection handler. */ - public function setUp() { - parent::setUp(); - + public function testSelectionHandler() { // Create nodes. $type = $this->drupalCreateContentType()->id(); $node1 = $this->drupalCreateNode(array('type' => $type)); $node2 = $this->drupalCreateNode(array('type' => $type)); $node3 = $this->drupalCreateNode(); + $nodes = array(); foreach (array($node1, $node2, $node3) as $node) { - $this->nodes[$node->getType()][$node->id()] = $node->label(); + $nodes[$node->getType()][$node->id()] = $node->label(); } // Create a field. @@ -76,72 +60,21 @@ public function setUp() { ), )); $field->save(); - $this->field = $field; - } - /** - * Confirm the expected results are returned. - * - * @param array $result - * Query results keyed by node type and nid. - */ - protected function assertResults(array $result) { + // Get values from selection handler. + $handler = $this->container->get('plugin.manager.entity_reference.selection')->getSelectionHandler($field); + $result = $handler->getReferenceableEntities(); + $success = FALSE; foreach ($result as $node_type => $values) { foreach ($values as $nid => $label) { - if (!$success = $this->nodes[$node_type][$nid] == trim(strip_tags($label))) { + if (!$success = $nodes[$node_type][$nid] == trim(strip_tags($label))) { // There was some error, so break. break; } } } - $this->assertTrue($success, 'Views selection handler returned expected values.'); - } - /** - * Tests the selection handler. - */ - public function testSelectionHandler() { - // Get values from selection handler. - $handler = $this->container->get('plugin.manager.entity_reference.selection')->getSelectionHandler($this->field); - $result = $handler->getReferenceableEntities(); - $this->assertResults($result); - } - - /** - * Tests the selection handler with a relationship. - */ - public function testSelectionHandlerRelationship() { - // Add a relationship to the view. - $view = Views::getView('test_entity_reference'); - $view->setDisplay(); - $view->displayHandlers->get('default')->setOption('relationships', array( - 'test_relationship' => array( - 'id' => 'uid', - 'table' => 'users', - 'field' => 'uid', - ), - )); - - // Add a filter depending on the relationship to the test view. - $view->displayHandlers->get('default')->setOption('filters', array( - 'uid' => array( - 'id' => 'uid', - 'table' => 'users', - 'field' => 'uid', - 'relationship' => 'test_relationship', - ) - )); - - // Set view to distinct so only one row per node is returned. - $query_options = $view->display_handler->getOption('query'); - $query_options['options']['distinct'] = TRUE; - $view->display_handler->setOption('query', $query_options); - $view->save(); - - // Get values from the selection handler. - $handler = $this->container->get('plugin.manager.entity_reference.selection')->getSelectionHandler($this->field); - $result = $handler->getReferenceableEntities(); - $this->assertResults($result); + $this->assertTrue($success, 'Views selection handler returned expected values.'); } } diff --git a/core/modules/field/src/Tests/TranslationTest.php b/core/modules/field/src/Tests/TranslationTest.php index 4119b88..c03c65f 100644 --- a/core/modules/field/src/Tests/TranslationTest.php +++ b/core/modules/field/src/Tests/TranslationTest.php @@ -42,6 +42,7 @@ class TranslationTest extends FieldUnitTestBase { */ protected $entity_type = 'test_entity'; + /** * An array defining the field storage to use in this test. * @@ -70,9 +71,6 @@ class TranslationTest extends FieldUnitTestBase { */ protected $field; - /** - * {@inheritdoc} - */ protected function setUp() { parent::setUp(); @@ -189,17 +187,4 @@ function testTranslatableFieldSaveLoad() { } } - /** - * Tests field access. - * - * Regression test to verify that fieldAccess() can be called while only - * passing the required parameters. - * - * @see https://www.drupal.org/node/2404739 - */ - public function testFieldAccess() { - $access_control_handler = \Drupal::entityManager()->getAccessControlHandler($this->entity_type); - $this->assertTrue($access_control_handler->fieldAccess('view', $this->field)); - } - } diff --git a/core/modules/file/file.module b/core/modules/file/file.module index d48a407..9438f4a 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -929,7 +929,7 @@ function file_tokens($type, $tokens, array $data = array(), array $options = arr $url_options = array('absolute' => TRUE); if (isset($options['langcode'])) { - $url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']); + $url_options['language'] = language_load($options['langcode']); $langcode = $options['langcode']; } else { diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 89ab28b..d0b9aab 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -511,18 +511,11 @@ function language_field_info_alter(&$info) { * Implements hook_entity_field_access() */ function language_entity_field_access($operation, FieldDefinitionInterface $field_definition, AccountInterface $account, FieldItemListInterface $items = NULL) { - // Only allow access to a langcode field if the entity it is attached to is - // configured to have an alterable language. - // Without items we can not decide whether or not to allow access. - if ($items) { - // Check if we are dealing with a langcode field. - $langcode_key = $items->getEntity()->getEntityType()->getKey('langcode'); - if ($field_definition->getName() == $langcode_key) { - // Grant access depending on whether the entity language can be altered. - $entity = $items->getEntity(); - $config = ContentLanguageSettings::loadByEntityTypeBundle($entity->getEntityTypeId(), $entity->bundle()); - return AccessResult::forbiddenIf(!$config->isLanguageAlterable()); - } + $langcode_key = $items->getEntity()->getEntityType()->getKey('langcode'); + if ($field_definition->getName() == $langcode_key) { + $entity = $items->getEntity(); + $config = ContentLanguageSettings::loadByEntityTypeBundle($entity->getEntityTypeId(), $entity->bundle()); + return AccessResult::forbiddenIf(!$config->isLanguageAlterable()); } return AccessResult::neutral(); } diff --git a/core/modules/language/src/Form/LanguageAddForm.php b/core/modules/language/src/Form/LanguageAddForm.php index f78bb83..93f1445 100644 --- a/core/modules/language/src/Form/LanguageAddForm.php +++ b/core/modules/language/src/Form/LanguageAddForm.php @@ -117,7 +117,7 @@ public function validateCustom(array $form, FormStateInterface $form_state) { // Reuse the editing form validation routine if we add a custom language. $this->validateCommon($form['custom_language'], $form_state); - if ($language = $this->languageManager->getLanguage($langcode)) { + if ($language = language_load($langcode)) { $form_state->setErrorByName('langcode', $this->t('The language %language (%langcode) already exists.', array('%language' => $language->getName(), '%langcode' => $langcode))); } } @@ -135,7 +135,7 @@ public function validatePredefined($form, FormStateInterface $form_state) { $form_state->setErrorByName('predefined_langcode', $this->t('Fill in the language details and save the language with Add custom language.')); } else { - if ($language = $this->languageManager->getLanguage($langcode)) { + if ($language = language_load($langcode)) { $form_state->setErrorByName('predefined_langcode', $this->t('The language %language (%langcode) already exists.', array('%language' => $language->getName(), '%langcode' => $langcode))); } } diff --git a/core/modules/language/src/Form/LanguageDeleteForm.php b/core/modules/language/src/Form/LanguageDeleteForm.php index 3842372..9f96673 100644 --- a/core/modules/language/src/Form/LanguageDeleteForm.php +++ b/core/modules/language/src/Form/LanguageDeleteForm.php @@ -101,7 +101,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 ($this->languageManager->getDefaultLanguage()->getId() == $langcode) { + if (language_default()->getId() == $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/LanguageListBuilder.php b/core/modules/language/src/LanguageListBuilder.php index e392e75..42ec9d3 100644 --- a/core/modules/language/src/LanguageListBuilder.php +++ b/core/modules/language/src/LanguageListBuilder.php @@ -9,11 +9,7 @@ use Drupal\Core\Config\Entity\DraggableListBuilder; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Entity\EntityStorageInterface; -use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Language\LanguageManagerInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * Defines a class to build a listing of language entities. @@ -28,39 +24,6 @@ class LanguageListBuilder extends DraggableListBuilder { protected $entitiesKey = 'languages'; /** - * The language manager. - * - * @var \Drupal\Core\Language\LanguageManagerInterface - */ - protected $languageManager; - - /** - * {@inheritdoc} - */ - public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { - return new static( - $entity_type, - $container->get('entity.manager')->getStorage($entity_type->id()), - $container->get('language_manager') - ); - } - - /** - * Constructs a new EntityListController object. - * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type - * The entity type definition. - * @param \Drupal\Core\Entity\EntityStorageInterface $storage - * The entity storage controller class. - * @param \Drupal\Core\Language\LanguageManagerInterface - * The language manager. - */ - public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, LanguageManagerInterface $language_manager) { - parent::__construct($entity_type, $storage); - $this->languageManager = $language_manager; - } - - /** * {@inheritdoc} */ public function load() { @@ -84,7 +47,7 @@ public function getFormId() { */ public function getDefaultOperations(EntityInterface $entity) { $operations = parent::getDefaultOperations($entity); - $default = $this->languageManager->getDefaultLanguage(); + $default = language_default(); // Deleting the site default language is not allowed. if ($entity->id() == $default->getId()) { @@ -126,9 +89,10 @@ public function buildForm(array $form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); - $this->languageManager->reset(); - if ($this->languageManager instanceof ConfigurableLanguageManagerInterface) { - $this->languageManager->updateLockedLanguageWeights(); + $language_manager = \Drupal::languageManager(); + $language_manager->reset(); + if ($language_manager instanceof ConfigurableLanguageManagerInterface) { + $language_manager->updateLockedLanguageWeights(); } drupal_set_message(t('Configuration saved.')); diff --git a/core/modules/language/src/Tests/LanguageSwitchingTest.php b/core/modules/language/src/Tests/LanguageSwitchingTest.php index d0e2a0d..a39da66 100644 --- a/core/modules/language/src/Tests/LanguageSwitchingTest.php +++ b/core/modules/language/src/Tests/LanguageSwitchingTest.php @@ -163,6 +163,7 @@ protected function doTestLanguageBlockAnonymous($block_label) { /** * Test languge switcher links for domain based negotiation */ + function testLanguageBlockWithDomain() { // Add the Italian language. ConfigurableLanguage::createFromLangcode('it')->save(); @@ -241,33 +242,6 @@ function testLanguageLinkActiveClass() { } /** - * Check the path-admin class, as same as on default language. - */ - function testLanguageBodyClass() { - $searched_class = 'path-admin'; - - // Add language. - $edit = array( - 'predefined_langcode' => 'fr', - ); - $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language')); - - // Enable URL language detection and selection. - $edit = array('language_interface[enabled][language-url]' => '1'); - $this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings')); - - // Go to admin/config, check the class on default language. - $this->drupalGet('admin/config'); - $class = $this->xpath('//body[contains(@class, :class)]', array(':class' => $searched_class)); - $this->assertTrue(isset($class[0]), t('The path-admin class appears on default language.')); - - // Go to admin/config, check the class on french language. - $this->drupalGet('fr/admin/config'); - $class = $this->xpath('//body[contains(@class, :class)]', array(':class' => $searched_class)); - $this->assertTrue(isset($class[0]), t('The path-admin class same as on default language.')); - } - - /** * For authenticated users, the "active" class is set by JavaScript. * * @see testLanguageLinkActiveClass() diff --git a/core/modules/locale/src/Form/LocaleSettingsForm.php b/core/modules/locale/src/Form/LocaleSettingsForm.php index 64460cc..4ff2c33 100644 --- a/core/modules/locale/src/Form/LocaleSettingsForm.php +++ b/core/modules/locale/src/Form/LocaleSettingsForm.php @@ -36,32 +36,32 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['update_interval_days'] = array( '#type' => 'radios', - '#title' => $this->t('Check for updates'), + '#title' => t('Check for updates'), '#default_value' => $config->get('translation.update_interval_days'), '#options' => array( - '0' => $this->t('Never (manually)'), - '7' => $this->t('Weekly'), - '30' => $this->t('Monthly'), + '0' => t('Never (manually)'), + '7' => t('Weekly'), + '30' => t('Monthly'), ), - '#description' => $this->t('Select how frequently you want to check for new interface translations for your currently installed modules and themes. Check updates now.', array('@url' => $this->url('locale.check_translation'))), + '#description' => t('Select how frequently you want to check for new interface translations for your currently installed modules and themes. Check updates now.', array('@url' => $this->url('locale.check_translation'))), ); if ($directory = $config->get('translation.path')) { - $description = $this->t('Translation files are stored locally in the %path directory. You can change this directory on the File system configuration page.', array('%path' => $directory, '@url' => $this->url('system.file_system_settings'))); + $description = t('Translation files are stored locally in the %path directory. You can change this directory on the File system configuration page.', array('%path' => $directory, '@url' => $this->url('system.file_system_settings'))); } else { - $description = $this->t('Translation files will not be stored locally. Change the Interface translation directory on the File system configuration page.', array('@url' => $this->url('system.file_system_settings'))); + $description = t('Translation files will not be stored locally. Change the Interface translation directory on the File system configuration page.', array('@url' => $this->url('system.file_system_settings'))); } $form['#translation_directory'] = $directory; $form['use_source'] = array( '#type' => 'radios', - '#title' => $this->t('Translation source'), + '#title' => t('Translation source'), '#default_value' => $config->get('translation.use_source'), '#options' => array( - LOCALE_TRANSLATION_USE_SOURCE_REMOTE_AND_LOCAL => $this->t('Drupal translation server and local files'), - LOCALE_TRANSLATION_USE_SOURCE_LOCAL => $this->t('Local files only'), + LOCALE_TRANSLATION_USE_SOURCE_REMOTE_AND_LOCAL => t('Drupal translation server and local files'), + LOCALE_TRANSLATION_USE_SOURCE_LOCAL => t('Local files only'), ), - '#description' => $this->t('The source of translation files for automatic interface translation.') . ' ' . $description, + '#description' => t('The source of translation files for automatic interface translation.') . ' ' . $description, ); if ($config->get('translation.overwrite_not_customized') == FALSE) { @@ -75,14 +75,14 @@ public function buildForm(array $form, FormStateInterface $form_state) { } $form['overwrite'] = array( '#type' => 'radios', - '#title' => $this->t('Import behavior'), + '#title' => t('Import behavior'), '#default_value' => $default, '#options' => array( - LOCALE_TRANSLATION_OVERWRITE_NONE => $this->t("Don't overwrite existing translations."), - LOCALE_TRANSLATION_OVERWRITE_NON_CUSTOMIZED => $this->t('Only overwrite imported translations, customized translations are kept.'), - LOCALE_TRANSLATION_OVERWRITE_ALL => $this->t('Overwrite existing translations.'), + LOCALE_TRANSLATION_OVERWRITE_NONE => t("Don't overwrite existing translations."), + LOCALE_TRANSLATION_OVERWRITE_NON_CUSTOMIZED => t('Only overwrite imported translations, customized translations are kept.'), + LOCALE_TRANSLATION_OVERWRITE_ALL => t('Overwrite existing translations.'), ), - '#description' => $this->t('How to treat existing translations when automatically updating the interface translations.'), + '#description' => t('How to treat existing translations when automatically updating the interface translations.'), ); return parent::buildForm($form, $form_state); diff --git a/core/modules/locale/src/LocaleConfigManager.php b/core/modules/locale/src/LocaleConfigManager.php index 23eebdf..7bc846e 100644 --- a/core/modules/locale/src/LocaleConfigManager.php +++ b/core/modules/locale/src/LocaleConfigManager.php @@ -117,7 +117,7 @@ public function get($name) { $data_definition = $this->typedConfigManager->buildDataDefinition($definition, $data); // Unless the configuration has a explicit language code we assume English. $langcode = isset($default['langcode']) ? $default['langcode'] : 'en'; - $wrapper = new LocaleTypedConfig($data_definition, $name, $langcode, $this, $this->typedConfigManager, $this->languageManager); + $wrapper = new LocaleTypedConfig($data_definition, $name, $langcode, $this, $this->typedConfigManager); $wrapper->setValue($data); return $wrapper; } diff --git a/core/modules/locale/src/LocaleTypedConfig.php b/core/modules/locale/src/LocaleTypedConfig.php index ca31a38..ee0b470 100644 --- a/core/modules/locale/src/LocaleTypedConfig.php +++ b/core/modules/locale/src/LocaleTypedConfig.php @@ -7,7 +7,6 @@ namespace Drupal\locale; -use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\TypedData\ContextAwareInterface; use Drupal\Core\TypedData\DataDefinitionInterface; use Drupal\Core\Config\Schema\Element; @@ -49,13 +48,6 @@ class LocaleTypedConfig extends Element { protected $typedConfigManager; /** - * The language manager. - * - * @var \Drupal\Core\Language\LanguageManagerInterface - */ - protected $languageManager; - - /** * Constructs a configuration wrapper object. * * @param \Drupal\Core\TypedData\DataDefinitionInterface $definition @@ -68,15 +60,12 @@ class LocaleTypedConfig extends Element { * The locale configuration manager object. * @param \Drupal\locale\TypedConfigManagerInterface $typed_config; * The typed configuration manager interface. - * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager - * The language manager. */ - public function __construct(DataDefinitionInterface $definition, $name, $langcode, LocaleConfigManager $locale_config, TypedConfigManagerInterface $typed_config, LanguageManagerInterface $language_manager) { + public function __construct(DataDefinitionInterface $definition, $name, $langcode, LocaleConfigManager $locale_config, TypedConfigManagerInterface $typed_config) { parent::__construct($definition, $name); $this->langcode = $langcode; $this->localeConfig = $locale_config; $this->typedConfigManager = $typed_config; - $this->languageManager = $language_manager; } /** @@ -102,7 +91,7 @@ public function getTranslation($langcode) { * {@inheritdoc} */ public function language() { - return $this->languageManager->getLanguage($this->langcode); + return language_load($this->langcode); } /** diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorFeedTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorFeedTest.php index 214b0e8..769c994 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorFeedTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateAggregatorFeedTest.php @@ -50,6 +50,7 @@ public function testAggregatorFeedImport() { $this->assertEqual($feed->link->value, 'http://knowyourmeme.com'); $this->assertEqual($feed->description->value, 'New items added to the News Feed'); $this->assertEqual($feed->image->value, 'http://b.thumbs.redditmedia.com/harEHsUUZVajabtC.png'); + $this->assertEqual($feed->hash->value, ''); $this->assertEqual($feed->etag->value, '"213cc1365b96c310e92053c5551f0504"'); $this->assertEqual($feed->modified->value, 0); } diff --git a/core/modules/node/node.services.yml b/core/modules/node/node.services.yml index 41a6c37..2586da3 100644 --- a/core/modules/node/node.services.yml +++ b/core/modules/node/node.services.yml @@ -5,7 +5,7 @@ services: - { name: event_subscriber } node.grant_storage: class: Drupal\node\NodeGrantDatabaseStorage - arguments: ['@database', '@module_handler', '@language_manager'] + arguments: ['@database', '@module_handler'] tags: - { name: backend_overridable } access_check.node.revision: diff --git a/core/modules/node/src/NodeGrantDatabaseStorage.php b/core/modules/node/src/NodeGrantDatabaseStorage.php index d9e8d5c..1c0c0f7 100644 --- a/core/modules/node/src/NodeGrantDatabaseStorage.php +++ b/core/modules/node/src/NodeGrantDatabaseStorage.php @@ -13,7 +13,6 @@ use Drupal\Core\Database\Query\Condition; use Drupal\Core\Entity\ContentEntityBase; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Session\AccountInterface; use Drupal\user\Entity\User; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -40,26 +39,16 @@ class NodeGrantDatabaseStorage implements NodeGrantDatabaseStorageInterface { protected $moduleHandler; /** - * The language manager. - * - * @var \Drupal\Core\Language\LanguageManagerInterface - */ - protected $languageManager; - - /** * Constructs a NodeGrantDatabaseStorage object. * * @param \Drupal\Core\Database\Connection $database * The database connection. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. - * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager - * The language manager. */ - public function __construct(Connection $database, ModuleHandlerInterface $module_handler, LanguageManagerInterface $language_manager) { + public function __construct(Connection $database, ModuleHandlerInterface $module_handler) { $this->database = $database; $this->moduleHandler = $module_handler; - $this->languageManager = $language_manager; } /** @@ -212,7 +201,7 @@ public function write(NodeInterface $node, array $grants, $realm = NULL, $delete continue; } if (isset($grant['langcode'])) { - $grant_languages = array($grant['langcode'] => $this->languageManager->getLanguage($grant['langcode'])); + $grant_languages = array($grant['langcode'] => language_load($grant['langcode'])); } else { $grant_languages = $node->getTranslationLanguages(TRUE); diff --git a/core/modules/node/src/Plugin/Search/NodeSearch.php b/core/modules/node/src/Plugin/Search/NodeSearch.php index 83140c1..47f1bc9 100644 --- a/core/modules/node/src/Plugin/Search/NodeSearch.php +++ b/core/modules/node/src/Plugin/Search/NodeSearch.php @@ -18,7 +18,6 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; -use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Access\AccessibleInterface; use Drupal\Core\Database\Query\Condition; @@ -67,13 +66,6 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter protected $searchSettings; /** - * The language manager. - * - * @var \Drupal\Core\Language\LanguageManagerInterface - */ - protected $languageManager; - - /** * The Drupal account to use for checking for access to advanced search. * * @var \Drupal\Core\Session\AccountInterface @@ -119,7 +111,6 @@ static public function create(ContainerInterface $container, array $configuratio $container->get('entity.manager'), $container->get('module_handler'), $container->get('config.factory')->get('search.settings'), - $container->get('language_manager'), $container->get('current_user') ); } @@ -141,17 +132,14 @@ static public function create(ContainerInterface $container, array $configuratio * A module manager object. * @param \Drupal\Core\Config\Config $search_settings * A config object for 'search.settings'. - * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager - * The language manager. * @param \Drupal\Core\Session\AccountInterface $account * The $account object to use for checking for access to advanced search. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, Connection $database, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, Config $search_settings, LanguageManagerInterface $language_manager, AccountInterface $account = NULL) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, Connection $database, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, Config $search_settings, AccountInterface $account = NULL) { $this->database = $database; $this->entityManager = $entity_manager; $this->moduleHandler = $module_handler; $this->searchSettings = $search_settings; - $this->languageManager = $language_manager; $this->account = $account; parent::__construct($configuration, $plugin_id, $plugin_definition); } @@ -314,7 +302,7 @@ protected function prepareResults(StatementInterface $found) { $extra = $this->moduleHandler->invokeAll('node_search_result', array($node, $item->langcode)); - $language = $this->languageManager->getLanguage($item->langcode); + $language = language_load($item->langcode); $username = array( '#theme' => 'username', '#account' => $node->getOwner(), @@ -498,7 +486,7 @@ public function searchFormAlter(array &$form, FormStateInterface $form_state) { // Add languages. $language_options = array(); - $language_list = $this->languageManager->getLanguages(LanguageInterface::STATE_ALL); + $language_list = \Drupal::languageManager()->getLanguages(LanguageInterface::STATE_ALL); foreach ($language_list as $langcode => $language) { // Make locked languages appear special in the list. $language_options[$langcode] = $language->isLocked() ? t('- @name -', array('@name' => $language->getName())) : $language->getName(); diff --git a/core/modules/node/src/Plugin/views/field/Language.php b/core/modules/node/src/Plugin/views/field/Language.php index 10acf52..9e55ce9 100644 --- a/core/modules/node/src/Plugin/views/field/Language.php +++ b/core/modules/node/src/Plugin/views/field/Language.php @@ -44,7 +44,7 @@ public function render(ResultRow $values) { // @todo: Drupal Core dropped native language until config translation is // ready, see http://drupal.org/node/1616594. $value = $this->getValue($values); - $language = \Drupal::languageManager()->getLanguage($value); + $language = language_load($value); $value = $language ? $language->getName() : ''; return $this->renderLink($value, $values); } diff --git a/core/modules/system/core.api.php b/core/modules/system/core.api.php index 3ffb004..3fc1f91 100644 --- a/core/modules/system/core.api.php +++ b/core/modules/system/core.api.php @@ -576,9 +576,25 @@ * * @section sec_define Defining permissions * Modules define permissions via a $module.permissions.yml file. This file - * defines machine names, human-readable names, and optionally - * descriptions for each permission type. The machine names are the canonical - * way to refer to permissions for access checking. + * defines machine names, human-readable names, restrict access (if required for + * security warning) and optionally descriptions for each permission type. The + * machine names are the canonical way to refer to permissions for access + * checking. + * + * Here is an example from the core filter module: + * @code + * administer filters: + * title: 'Administer text formats and filters' + * description: 'Define how text is handled by combining filters into text formats.' + * restrict access: true + * @endcode + * + * Some notes: + * - Machine name of the permission required. + * - Title is the human readable name appearing in the Permissions page. + * - When "restrict access" is set to "true" a warning about site security will + * be displayed on the Permissions page. + * - Description is optional. * * @section sec_access Access permission checking * Depending on the situation, there are several methods for ensuring that diff --git a/core/modules/system/src/Tests/Installer/InstallerTest.php b/core/modules/system/src/Tests/Installer/InstallerTest.php index b17e3e7..ee53a4e 100644 --- a/core/modules/system/src/Tests/Installer/InstallerTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerTest.php @@ -39,7 +39,7 @@ protected function setUpLanguage() { // Test that \Drupal\Core\Render\BareHtmlPageRenderer adds assets and // metatags as expected to the first page of the installer. $this->assertRaw('core/themes/seven/css/components/buttons.css'); - $this->assertRaw(''); + $this->assertRaw(''); parent::setUpLanguage(); } } diff --git a/core/modules/system/src/Tests/KeyValueStore/KeyValueContentEntityStorageTest.php b/core/modules/system/src/Tests/KeyValueStore/KeyValueContentEntityStorageTest.php index 66fd3c2..6ab645f 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 = \Drupal::languageManager()->getDefaultLanguage()->getId(); + $default_langcode = language_default()->getId(); // 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/Page/DefaultMetatagsTest.php b/core/modules/system/src/Tests/Page/DefaultMetatagsTest.php index beb43c0..5739137 100644 --- a/core/modules/system/src/Tests/Page/DefaultMetatagsTest.php +++ b/core/modules/system/src/Tests/Page/DefaultMetatagsTest.php @@ -22,11 +22,12 @@ class DefaultMetatagsTest extends WebTestBase { public function testMetaTag() { $this->drupalGet(''); // Ensures that the charset metatag is on the page. - $result = $this->xpath('//meta[@charset="utf-8"]'); + $result = $this->xpath('//meta[@name="charset" and @charset="utf-8"]'); $this->assertEqual(count($result), 1); // Ensure that the charset one is the first metatag. $result = $this->xpath('//meta'); + $this->assertEqual((string) $result[0]->attributes()->name, 'charset'); $this->assertEqual((string) $result[0]->attributes()->charset, 'utf-8'); // Ensure that the shortcut icon is on the page. diff --git a/core/modules/system/src/Tests/Pager/PagerTest.php b/core/modules/system/src/Tests/Pager/PagerTest.php index 6595de3..7076291 100644 --- a/core/modules/system/src/Tests/Pager/PagerTest.php +++ b/core/modules/system/src/Tests/Pager/PagerTest.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\system\Tests\Pager\PagerTest. + * Definition of Drupal\system\Tests\Pager\PagerTest. */ namespace Drupal\system\Tests\Pager; @@ -21,7 +21,7 @@ class PagerTest extends WebTestBase { * * @var array */ - public static $modules = array('dblog', 'pager_test'); + public static $modules = array('dblog'); protected $profile = 'testing'; @@ -63,25 +63,6 @@ function testActiveClass() { } /** - * Test proper functioning of the query parameters. - */ - protected function testPagerQueryParameters() { - // First page. - $this->drupalGet('pager-test/query-parameters'); - $this->assertText(t('Pager calls: 0'), 'Initial call to pager shows 0 calls.'); - - // Go to last page, the count of pager calls need to go to 1. - $elements = $this->xpath('//li[contains(@class, :class)]/a', array(':class' => 'pager__item--last')); - $this->drupalGet($GLOBALS['base_root'] . $elements[0]['href'], array('external' => TRUE)); - $this->assertText(t('Pager calls: 1'), 'First link call to pager shows 1 calls.'); - - // Go back to first page, the count of pager calls need to go to 2. - $elements = $this->xpath('//li[contains(@class, :class)]/a', array(':class' => 'pager__item--first')); - $this->drupalGet($GLOBALS['base_root'] . $elements[0]['href'], array('external' => TRUE)); - $this->assertText(t('Pager calls: 2'), 'Second link call to pager shows 2 calls.'); - } - - /** * Asserts pager items and links. * * @param int $current_page diff --git a/core/modules/system/src/Tests/Theme/TwigEnvironmentTest.php b/core/modules/system/src/Tests/Theme/TwigEnvironmentTest.php index 8edb4b2..6ecabec 100644 --- a/core/modules/system/src/Tests/Theme/TwigEnvironmentTest.php +++ b/core/modules/system/src/Tests/Theme/TwigEnvironmentTest.php @@ -33,7 +33,7 @@ public function testInlineTemplate() { /** @var \Drupal\Core\Template\TwigEnvironment $environment */ $environment = \Drupal::service('twig'); $this->assertEqual($environment->renderInline('test-no-context'), 'test-no-context'); - $this->assertEqual($environment->renderInline('test-with-context {{ llama }}', array('llama' => 'muuh')), 'test-with-context muuh'); + $this->assertEqual($environment->renderInline('test-with-context {{ lama }}', array('lama' => 'muuh')), 'test-with-context muuh'); $element = array(); $unsafe_string = ''; @@ -56,8 +56,8 @@ public function testInlineTemplate() { $element = array(); $element['test'] = array( '#type' => 'inline_template', - '#template' => 'test-with-context {{ llama }}', - '#context' => array('llama' => 'muuh'), + '#template' => 'test-with-context {{ lama }}', + '#context' => array('lama' => 'muuh'), ); $element_copy = $element; // Render it twice so that twig caching is triggered. diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index 7167fcb..66ffff9 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -535,7 +535,7 @@ function hook_tokens($type, $tokens, array $data = array(), array $options = arr $url_options = array('absolute' => TRUE); if (isset($options['langcode'])) { - $url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']); + $url_options['language'] = language_load($options['langcode']); $langcode = $options['langcode']; } else { @@ -608,7 +608,7 @@ function hook_tokens_alter(array &$replacements, array $context) { $options = $context['options']; if (isset($options['langcode'])) { - $url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']); + $url_options['language'] = language_load($options['langcode']); $langcode = $options['langcode']; } else { diff --git a/core/modules/system/system.links.menu.yml b/core/modules/system/system.links.menu.yml index 9563f83..1a0028f 100644 --- a/core/modules/system/system.links.menu.yml +++ b/core/modules/system/system.links.menu.yml @@ -115,7 +115,7 @@ system.admin_config_system: system.site_information_settings: title: 'Site information' parent: system.admin_config_system - description: 'Change site name, email address, slogan, default front page, and error pages.' + description: 'Change site name, email address, slogan, default front page, and number of posts per page, error pages.' route_name: system.site_information_settings weight: -20 system.cron_settings: diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 7c67714..255449e 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -551,6 +551,7 @@ function system_page_attachments(array &$page) { 'system_meta_content_type' => array( '#tag' => 'meta', '#attributes' => array( + 'name' => 'charset', 'charset' => 'utf-8', ), // Security: This always has to be output first. diff --git a/core/modules/system/system.tokens.inc b/core/modules/system/system.tokens.inc index 9e9d03d..ff78335 100644 --- a/core/modules/system/system.tokens.inc +++ b/core/modules/system/system.tokens.inc @@ -92,7 +92,7 @@ function system_tokens($type, $tokens, array $data = array(), array $options = a $url_options = array('absolute' => TRUE); if (isset($options['langcode'])) { - $url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']); + $url_options['language'] = language_load($options['langcode']); $langcode = $options['langcode']; } else { diff --git a/core/modules/system/tests/modules/pager_test/pager_test.info.yml b/core/modules/system/tests/modules/pager_test/pager_test.info.yml deleted file mode 100644 index 54a4a40..0000000 --- a/core/modules/system/tests/modules/pager_test/pager_test.info.yml +++ /dev/null @@ -1,6 +0,0 @@ -type: module -core: 8.x -name: 'Pager Test' -description: 'Support module for pager tests.' -package: Testing -version: VERSION diff --git a/core/modules/system/tests/modules/pager_test/pager_test.routing.yml b/core/modules/system/tests/modules/pager_test/pager_test.routing.yml deleted file mode 100644 index 9720507..0000000 --- a/core/modules/system/tests/modules/pager_test/pager_test.routing.yml +++ /dev/null @@ -1,7 +0,0 @@ -pager_test.query_parameters: - path: '/pager-test/query-parameters' - defaults: - _title: 'Pager using query parameters for testing' - _controller: '\Drupal\pager_test\Controller\PagerTestController::queryParameters' - requirements: - _access: 'TRUE' diff --git a/core/modules/system/tests/modules/pager_test/src/Controller/PagerTestController.php b/core/modules/system/tests/modules/pager_test/src/Controller/PagerTestController.php deleted file mode 100644 index 3a22070..0000000 --- a/core/modules/system/tests/modules/pager_test/src/Controller/PagerTestController.php +++ /dev/null @@ -1,64 +0,0 @@ - 'wid'), - array('data' => 'type'), - array('data' => 'timestamp'), - ); - $query_0 = db_select('watchdog', 'd')->extend('Drupal\Core\Database\Query\PagerSelectExtender')->element(0); - $query_0->fields('d', array('wid', 'type', 'timestamp')); - $result_0 = $query_0 - ->limit(5) - ->orderBy('d.wid') - ->execute(); - $rows_0 = array(); - foreach ($result_0 as $row) { - $rows_0[] = array('data' => (array) $row); - } - $build['pager_table_0'] = array( - '#theme' => 'table', - '#header' => $header_0, - '#rows' => $rows_0, - '#empty' => $this->t("There are no watchdog records found in the db"), - ); - - // Counter of calls to the current pager. - $query_params = pager_get_query_parameters(); - $pager_calls = isset($query_params['pager_calls']) ? ($query_params['pager_calls'] ? $query_params['pager_calls'] : 0) : 0; - $build['l_pager_pager_0'] = array('#markup' => $this->t('Pager calls: @pager_calls', array('@pager_calls' => $pager_calls))); - - // Pager. - $build['pager_pager_0'] = array( - '#theme' => 'pager', - '#element' => 0, - '#parameters' => array( - 'pager_calls' => ++$pager_calls, - ), - ); - - return $build; - } -} diff --git a/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php b/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php index abaaa4c..9deae9f 100644 --- a/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php +++ b/core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php @@ -16,7 +16,6 @@ * Controller providing page callbacks for the action admin interface. */ class SessionTestController extends ControllerBase { - /** * Prints the stored session value to the screen. * @@ -124,5 +123,4 @@ public function setMessageButDontSave() { public function isLoggedIn() { return ['#markup' => $this->t('User is logged in.')]; } - } diff --git a/core/modules/system/tests/modules/theme_test/src/ThemeTestController.php b/core/modules/system/tests/modules/theme_test/src/ThemeTestController.php index 335ed83..cf42211 100644 --- a/core/modules/system/tests/modules/theme_test/src/ThemeTestController.php +++ b/core/modules/system/tests/modules/theme_test/src/ThemeTestController.php @@ -63,8 +63,8 @@ public function testInlineTemplate() { $element = array(); $element['test'] = array( '#type' => 'inline_template', - '#template' => 'test-with-context {{ llama }}', - '#context' => array('llama' => 'muuh'), + '#template' => 'test-with-context {{ lama }}', + '#context' => array('lama' => 'muuh'), ); return $element; } diff --git a/core/modules/user/src/Entity/User.php b/core/modules/user/src/Entity/User.php index 98c1641..7c8af82 100644 --- a/core/modules/user/src/Entity/User.php +++ b/core/modules/user/src/Entity/User.php @@ -372,13 +372,13 @@ public function getTimeZone() { * {@inheritdoc} */ function getPreferredLangcode($fallback_to_default = TRUE) { - $language_list = $this->languageManager()->getLanguages(); + $language_list = \Drupal::languageManager()->getLanguages(); $preferred_langcode = $this->get('preferred_langcode')->value; if (!empty($preferred_langcode) && isset($language_list[$preferred_langcode])) { return $language_list[$preferred_langcode]->getId(); } else { - return $fallback_to_default ? $this->languageManager()->getDefaultLanguage()->getId() : ''; + return $fallback_to_default ? language_default()->getId() : ''; } } @@ -386,13 +386,13 @@ function getPreferredLangcode($fallback_to_default = TRUE) { * {@inheritdoc} */ function getPreferredAdminLangcode($fallback_to_default = TRUE) { - $language_list = $this->languageManager()->getLanguages(); + $language_list = \Drupal::languageManager()->getLanguages(); $preferred_langcode = $this->get('preferred_admin_langcode')->value; if (!empty($preferred_langcode) && isset($language_list[$preferred_langcode])) { return $language_list[$preferred_langcode]->getId(); } else { - return $fallback_to_default ? $this->languageManager()->getDefaultLanguage()->getId() : ''; + return $fallback_to_default ? language_default()->getId() : ''; } } diff --git a/core/modules/user/src/PermissionHandler.php b/core/modules/user/src/PermissionHandler.php index d41b05e..d576cdd 100644 --- a/core/modules/user/src/PermissionHandler.php +++ b/core/modules/user/src/PermissionHandler.php @@ -24,6 +24,8 @@ * restrict access: true * description: some description * @endcode + * + * @see user_api */ class PermissionHandler implements PermissionHandlerInterface { diff --git a/core/modules/user/src/Plugin/views/field/Language.php b/core/modules/user/src/Plugin/views/field/Language.php index bf5abaa..7e7c0ed 100644 --- a/core/modules/user/src/Plugin/views/field/Language.php +++ b/core/modules/user/src/Plugin/views/field/Language.php @@ -30,7 +30,7 @@ protected function renderLink($data, ResultRow $values) { } } if (empty($data)) { - $lang = \Drupal::languageManager()->getDefaultLanguage(); + $lang = language_default(); } else { $lang = \Drupal::languageManager()->getLanguages(); diff --git a/core/modules/user/src/Plugin/views/filter/Roles.php b/core/modules/user/src/Plugin/views/filter/Roles.php index f878785..014425d 100644 --- a/core/modules/user/src/Plugin/views/filter/Roles.php +++ b/core/modules/user/src/Plugin/views/filter/Roles.php @@ -7,9 +7,7 @@ namespace Drupal\user\Plugin\views\filter; -use Drupal\user\RoleStorageInterface; use Drupal\views\Plugin\views\filter\ManyToOne; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * Filter handler for user roles. @@ -20,42 +18,6 @@ */ class Roles extends ManyToOne { - /** - * The role storage. - * - * @var \Drupal\user\RoleStorageInterface - */ - protected $roleStorage; - - /** - * Constructs a Roles object. - * - * @param array $configuration - * A configuration array containing information about the plugin instance. - * @param string $plugin_id - * The plugin_id for the plugin instance. - * @param mixed $plugin_definition - * The plugin implementation definition. - * @param \Drupal\user\RoleStorageInterface $role_storage - * The role storage. - */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, RoleStorageInterface $role_storage) { - parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->roleStorage = $role_storage; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('entity.manager')->getStorage('user_role') - ); - } - public function getValueOptions() { $this->valueOptions = user_role_names(TRUE); unset($this->valueOptions[DRUPAL_AUTHENTICATED_RID]); @@ -71,16 +33,4 @@ function operators() { return $operators; } - /** - * {@inheritdoc} - */ - public function calculateDependencies() { - $dependencies = array(); - foreach ($this->value as $role_id) { - $role = $this->roleStorage->load($role_id); - $dependencies[$role->getConfigDependencyKey()][] = $role->getConfigDependencyName(); - } - return $dependencies; - } - } diff --git a/core/modules/user/src/Tests/Views/HandlerFilterRolesTest.php b/core/modules/user/src/Tests/Views/HandlerFilterRolesTest.php deleted file mode 100644 index 6ed889b..0000000 --- a/core/modules/user/src/Tests/Views/HandlerFilterRolesTest.php +++ /dev/null @@ -1,72 +0,0 @@ - 'test_user_role']); - $role->save(); - $view = View::load('test_user_name'); - $expected = [ - 'module' => ['user'], - ]; - $this->assertEqual($expected, $view->getDependencies()); - - $display = &$view->getDisplay('default'); - $display['display_options']['filters']['roles_target_id'] = [ - 'id' => 'roles_target_id', - 'table' => 'user__roles', - 'field' => 'roles_target_id', - 'value' => [ - 'test_user_role' => 'test_user_role', - ], - 'plugin_id' => 'user_roles', - ]; - $view->save(); - $expected['config'][] = 'user.role.test_user_role'; - $this->assertEqual($expected, $view->getDependencies()); - - $view = View::load('test_user_name'); - $display = &$view->getDisplay('default'); - $display['display_options']['filters']['roles_target_id'] = [ - 'id' => 'roles_target_id', - 'table' => 'user__roles', - 'field' => 'roles_target_id', - 'value' => [], - 'plugin_id' => 'user_roles', - ]; - $view->save(); - unset($expected['config']); - $this->assertEqual($expected, $view->getDependencies()); - } - -} diff --git a/core/modules/user/tests/src/Unit/Menu/UserLocalTasksTest.php b/core/modules/user/tests/src/Unit/Menu/UserLocalTasksTest.php index 22d2ea4..b58f86b 100644 --- a/core/modules/user/tests/src/Unit/Menu/UserLocalTasksTest.php +++ b/core/modules/user/tests/src/Unit/Menu/UserLocalTasksTest.php @@ -47,10 +47,13 @@ public function getUserAdminRoutes() { * * @dataProvider getUserLoginRoutes */ - public function testUserLoginLocalTasks($route) { + public function testUserLoginLocalTasks($route, $subtask = array()) { $tasks = array( - 0 => array('user.register', 'user.pass', 'user.login',), + 0 => array('user.page', 'user.register', 'user.pass',), ); + if ($subtask) { + $tasks[] = $subtask; + } $this->assertLocalTasks($route, $tasks); } @@ -59,7 +62,8 @@ public function testUserLoginLocalTasks($route) { */ public function getUserLoginRoutes() { return array( - array('user.login'), + array('user.page', array('user.login',)), + array('user.login', array('user.login',)), array('user.register'), array('user.pass'), ); diff --git a/core/modules/user/user.links.task.yml b/core/modules/user/user.links.task.yml index be51381..9d9661d 100644 --- a/core/modules/user/user.links.task.yml +++ b/core/modules/user/user.links.task.yml @@ -1,3 +1,4 @@ + entity.user_role.edit_form: title: 'Edit' route_name: entity.user_role.edit_form @@ -8,22 +9,24 @@ user.account_settings_tab: title: 'Settings' base_route: entity.user.admin_form +user.page: + route_name: user.page + base_route: user.page + title: 'Log in' + weight: -10 user.register: route_name: user.register base_route: user.page title: 'Create new account' - user.pass: route_name: user.pass base_route: user.page title: 'Reset your password' - # Other authentication methods may add pages below user/login/. user.login: route_name: user.login - base_route: user.page - title: 'Log in' - weight: -10 + parent_id: user.page + title: 'Username and password' entity.user.canonical: route_name: entity.user.canonical diff --git a/core/modules/views/src/Plugin/views/field/LanguageField.php b/core/modules/views/src/Plugin/views/field/LanguageField.php index 2933ae7..5792bd0 100644 --- a/core/modules/views/src/Plugin/views/field/LanguageField.php +++ b/core/modules/views/src/Plugin/views/field/LanguageField.php @@ -43,7 +43,7 @@ public function render(ResultRow $values) { // @todo: Drupal Core dropped native language until config translation is // ready, see http://drupal.org/node/1616594. $value = $this->getValue($values); - $language = \Drupal::languageManager()->getLanguage($value); + $language = language_load($value); return $language ? $language->getName() : ''; } diff --git a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php index 1c254dc..98e7e50 100644 --- a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php +++ b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php @@ -277,8 +277,8 @@ public function getEntityTableInfo() { ); // Include the entity provider. - if (!empty($base_table_data['table']['provider'])) { - $entity_tables[$base_table_data['table']['entity type']]['provider'] = $base_table_data['table']['provider']; + if (!empty($table_data['table']['provider'])) { + $entity_tables[$table_data['table']['entity type']]['provider'] = $table_data['table']['provider']; } } @@ -286,7 +286,7 @@ public function getEntityTableInfo() { foreach ((array) $this->view->relationship as $relationship_id => $relationship) { $table_data = $views_data->get($relationship->definition['base']); if (isset($table_data['table']['entity type'])) { - $entity_tables[$relationship_id . '__' . $relationship->tableAlias] = array( + $entity_tables[$table_data['table']['entity type']] = array( 'base' => $relationship->definition['base'], 'relationship_id' => $relationship_id, 'alias' => $relationship->alias, @@ -296,7 +296,7 @@ public function getEntityTableInfo() { // Include the entity provider. if (!empty($table_data['table']['provider'])) { - $entity_tables[$relationship_id . '__' . $relationship->tableAlias]['provider'] = $table_data['table']['provider']; + $entity_tables[$table_data['table']['entity type']]['provider'] = $table_data['table']['provider']; } } } diff --git a/core/modules/views/src/Plugin/views/query/Sql.php b/core/modules/views/src/Plugin/views/query/Sql.php index 7a6706c..3aed415 100644 --- a/core/modules/views/src/Plugin/views/query/Sql.php +++ b/core/modules/views/src/Plugin/views/query/Sql.php @@ -1254,7 +1254,7 @@ public function query($get_count = FALSE) { } foreach ($entity_information as $entity_type_id => $info) { - $entity_type = \Drupal::entityManager()->getDefinition($info['entity_type']); + $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); $base_field = empty($table['revision']) ? $entity_type->getKey('id') : $entity_type->getKey('revision'); $this->addField($info['alias'], $base_field, '', $params); } @@ -1468,40 +1468,30 @@ function loadEntities(&$results) { return; } - // Extract all entity types from entity_information. - $entity_types = array(); - foreach ($entity_information as $info) { - $entity_type = $info['entity_type']; - if (!isset($entity_types[$entity_type])) { - $entity_types[$entity_type] = \Drupal::entityManager()->getDefinition($entity_type); - } - } - // Assemble a list of entities to load. $ids_by_type = array(); - foreach ($entity_information as $info) { - $relationship_id = $info['relationship_id']; - $entity_type = $info['entity_type']; - $entity_info = $entity_types[$entity_type]; + foreach ($entity_information as $entity_type => $info) { + $entity_info = \Drupal::entityManager()->getDefinition($entity_type); $id_key = empty($table['revision']) ? $entity_info->getKey('id') : $entity_info->getKey('revision'); $id_alias = $this->getFieldAlias($info['alias'], $id_key); foreach ($results as $index => $result) { // Store the entity id if it was found. if (isset($result->{$id_alias}) && $result->{$id_alias} != '') { - $ids_by_type[$entity_type][$index][$relationship_id] = $result->$id_alias; + $ids_by_type[$entity_type][$index] = $result->$id_alias; } } } // Load all entities and assign them to the correct result row. foreach ($ids_by_type as $entity_type => $ids) { - $flat_ids = iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($ids)), FALSE); + $info = $entity_information[$entity_type]; + $relationship_id = $info['relationship_id']; // Drupal core currently has no way to load multiple revisions. Sad. - if (isset($entity_table_info[$entity_type]['revision']) && $entity_table_info[$entity_type]['revision'] == TRUE) { + if ($info['revision']) { $entities = array(); - foreach ($flat_ids as $revision_id) { + foreach ($ids as $revision_id) { $entity = entity_revision_load($entity_type, $revision_id); if ($entity) { $entities[$revision_id] = $entity; @@ -1509,24 +1499,22 @@ function loadEntities(&$results) { } } else { - $entities = entity_load_multiple($entity_type, $flat_ids); + $entities = entity_load_multiple($entity_type, $ids); } - foreach ($ids as $index => $relationships) { - foreach ($relationships as $relationship_id => $entity_id) { - if (isset($entities[$entity_id])) { - $entity = $entities[$entity_id]; - } - else { - $entity = NULL; - } + foreach ($ids as $index => $id) { + if (isset($entities[$id])) { + $entity = $entities[$id]; + } + else { + $entity = NULL; + } - if ($relationship_id == 'none') { - $results[$index]->_entity = $entity; - } - else { - $results[$index]->_relationship_entities[$relationship_id] = $entity; - } + if ($relationship_id == 'none') { + $results[$index]->_entity = $entity; + } + else { + $results[$index]->_relationship_entities[$relationship_id] = $entity; } } } diff --git a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php index cdf0723..bbf06ce 100644 --- a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php +++ b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php @@ -655,7 +655,7 @@ protected function instantiateView($form, FormStateInterface $form_state) { 'label' => $form_state->getValue('label'), 'description' => $form_state->getValue('description'), 'base_table' => $this->base_table, - 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(), + 'langcode' => language_default()->getId(), ); $view = entity_create('view', $values); diff --git a/core/modules/views_ui/css/views_ui.admin.theme.css b/core/modules/views_ui/css/views_ui.admin.theme.css index c195cce..f423263 100644 --- a/core/modules/views_ui/css/views_ui.admin.theme.css +++ b/core/modules/views_ui/css/views_ui.admin.theme.css @@ -595,9 +595,6 @@ td.group-title { margin: 0; padding: 0; } -.views-displays .tabs.secondary .action-list input.form-submit:hover { - box-shadow: none; -} .views-displays .tabs.secondary .action-list li:hover { background-color: #ddd; diff --git a/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php b/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php index 83435b1..45074a5 100644 --- a/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php +++ b/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php @@ -165,19 +165,6 @@ public function testMethod($parameter) } /** - * @covers ::build() - */ - public function testBuildWithNestedInterface() { - $class = 'Drupal\Tests\Component\ProxyBuilder\TestServiceWithChildInterfaces'; - - $result = $this->proxyBuilder->build($class); - $method_body = ''; - - $interface_string = ' implements \Drupal\Tests\Component\ProxyBuilder\TestChildInterface'; - $this->assertEquals($this->buildExpectedClass($class, $method_body, $interface_string), $result); - } - - /** * @covers ::buildMethod() * @covers ::buildParameter() * @covers ::buildMethodBody() @@ -361,14 +348,3 @@ public static function testMethod($parameter) { } -interface TestBaseInterface { - -} - -interface TestChildInterface extends TestBaseInterface { - -} - -class TestServiceWithChildInterfaces implements TestChildInterface { - -} diff --git a/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyDumperTest.php b/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyDumperTest.php index 3c5066a..d8fed50 100644 --- a/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyDumperTest.php +++ b/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyDumperTest.php @@ -85,9 +85,6 @@ public function testGetProxyFactoryCode() { $this->assertEquals($expected, $result); } - /** - * @covers ::getProxyCode() - */ public function testGetProxyCode() { $definition = new Definition('Drupal\Tests\Component\ProxyBuilder\TestService'); $definition->setLazy(TRUE); @@ -102,26 +99,6 @@ public function testGetProxyCode() { $this->assertEquals($class, $result); } - /** - * @covers ::getProxyCode() - */ - public function testGetProxyCodeWithSameClassMultipleTimes() { - $definition = new Definition('Drupal\Tests\Component\ProxyBuilder\TestService'); - $definition->setLazy(TRUE); - - $class = 'class Drupal_Tests_Component_ProxyBuilder_TestService_Proxy {}'; - $this->proxyBuilder->expects($this->once()) - ->method('build') - ->with('Drupal\Tests\Component\ProxyBuilder\TestService') - ->willReturn($class); - - $result = $this->proxyDumper->getProxyCode($definition); - $this->assertEquals($class, $result); - - $result = $this->proxyDumper->getProxyCode($definition); - $this->assertEquals('', $result); - } - } class TestService { diff --git a/core/tests/Drupal/Tests/Core/Template/AttributeTest.php b/core/tests/Drupal/Tests/Core/Template/AttributeTest.php index b4a192d..d587db2 100644 --- a/core/tests/Drupal/Tests/Core/Template/AttributeTest.php +++ b/core/tests/Drupal/Tests/Core/Template/AttributeTest.php @@ -331,87 +331,16 @@ public function testPrint() { $content = $this->randomMachineName(); $html = '' . $content . ''; - $this->assertClass('example-class', $html); - $this->assertNoClass('example-class2', $html); + $this->assertSelectEquals('div.example-class', $content, 1, $html); + $this->assertSelectEquals('div.example-class2', $content, 0, $html); - $this->assertID('example-id', $html); - $this->assertNoID('example-id2', $html); + $this->assertSelectEquals('div#example-id', $content, 1, $html); + $this->assertSelectEquals('div#example-id2', $content, 0, $html); $this->assertTrue(strpos($html, 'enabled') !== FALSE); } /** - * Checks that the given CSS class is present in the given HTML snippet. - * - * @param string $class - * The CSS class to check. - * @param string $html - * The HTML snippet to check. - */ - protected function assertClass($class, $html) { - $xpath = "//*[@class='$class']"; - self::assertTrue((bool) $this->getXPathResultCount($xpath, $html)); - } - - /** - * Checks that the given CSS class is not present in the given HTML snippet. - * - * @param string $class - * The CSS class to check. - * @param string $html - * The HTML snippet to check. - */ - protected function assertNoClass($class, $html) { - $xpath = "//*[@class='$class']"; - self::assertFalse((bool) $this->getXPathResultCount($xpath, $html)); - } - - /** - * Checks that the given CSS ID is present in the given HTML snippet. - * - * @param string $id - * The CSS ID to check. - * @param string $html - * The HTML snippet to check. - */ - protected function assertID($id, $html) { - $xpath = "//*[@id='$id']"; - self::assertTrue((bool) $this->getXPathResultCount($xpath, $html)); - } - - /** - * Checks that the given CSS ID is not present in the given HTML snippet. - * - * @param string $id - * The CSS ID to check. - * @param string $html - * The HTML snippet to check. - */ - protected function assertNoID($id, $html) { - $xpath = "//*[@id='$id']"; - self::assertFalse((bool) $this->getXPathResultCount($xpath, $html)); - } - - /** - * Counts the occurrences of the given XPath query in a given HTML snippet. - * - * @param string $query - * The XPath query to execute. - * @param string $html - * The HTML snippet to check. - * - * @return int - * The number of results that are found. - */ - protected function getXPathResultCount($query, $html) { - $document = new \DOMDocument; - $document->loadHTML($html); - $xpath = new \DOMXPath($document); - - return $xpath->query($query)->length; - } - - /** * Tests the storage method. */ public function testStorage() { diff --git a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php index f28f6e2..1f371fa 100644 --- a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php @@ -109,7 +109,8 @@ public function testGenerateHrefs($route_name, array $parameters, $absolute, $ex $url = new Url($route_name, $parameters, array('absolute' => $absolute)); $url->setUrlGenerator($this->urlGenerator); $result = $this->linkGenerator->generate('Test', $url); - $this->assertLink(array( + $this->assertTag(array( + 'tag' => 'a', 'attributes' => array('href' => $expected_url), ), $result); } @@ -133,7 +134,8 @@ public function testGenerate() { $url->setUrlGenerator($this->urlGenerator); $result = $this->linkGenerator->generate('Test', $url); - $this->assertLink(array( + $this->assertTag(array( + 'tag' => 'a', 'attributes' => array( 'href' => '/test-route-1#the-fragment', ), @@ -170,7 +172,8 @@ public function testGenerateExternal() { $url->setOption('set_active_class', TRUE); $result = $this->linkGenerator->generate('Drupal', $url); - $this->assertLink(array( + $this->assertTag(array( + 'tag' => 'a', 'attributes' => array( 'href' => 'http://drupal.org', ), @@ -197,7 +200,8 @@ public function testGenerateAttributes() { )); $url->setUrlGenerator($this->urlGenerator); $result = $this->linkGenerator->generate('Test', $url); - $this->assertLink(array( + $this->assertTag(array( + 'tag' => 'a', 'attributes' => array( 'href' => '/test-route-1', 'title' => 'Tooltip', @@ -223,7 +227,8 @@ public function testGenerateQuery() { )); $url->setUrlGenerator($this->urlGenerator); $result = $this->linkGenerator->generate('Test', $url); - $this->assertLink(array( + $this->assertTag(array( + 'tag' => 'a', 'attributes' => array( 'href' => '/test-route-1?test=value', ), @@ -246,7 +251,8 @@ public function testGenerateParametersAsQuery() { $url = new Url('test_route_1', array('test' => 'value'), array()); $url->setUrlGenerator($this->urlGenerator); $result = $this->linkGenerator->generate('Test', $url); - $this->assertLink(array( + $this->assertTag(array( + 'tag' => 'a', 'attributes' => array( 'href' => '/test-route-1?test=value', ), @@ -271,7 +277,8 @@ public function testGenerateOptions() { )); $url->setUrlGenerator($this->urlGenerator); $result = $this->linkGenerator->generate('Test', $url); - $this->assertLink(array( + $this->assertTag(array( + 'tag' => 'a', 'attributes' => array( 'href' => '/test-route-1?test=value', ), @@ -295,7 +302,13 @@ public function testGenerateXss() { $url = new Url('test_route_4'); $url->setUrlGenerator($this->urlGenerator); $result = $this->linkGenerator->generate("", $url); - $this->assertNoXPathResults('//a[@href="/test-route-4"]/script', $result); + $this->assertNotTag(array( + 'tag' => 'a', + 'attributes' => array('href' => '/test-route-4'), + 'child' => array( + 'tag' => 'script', + ), + ), $result); } /** @@ -323,7 +336,8 @@ public function testGenerateWithHtml() { )); $url->setUrlGenerator($this->urlGenerator); $result = $this->linkGenerator->generate('Test', $url); - $this->assertLink(array( + $this->assertTag(array( + 'tag' => 'a', 'attributes' => array( 'href' => '/test-route-5', 'title' => 'HTML Tooltip', @@ -334,7 +348,8 @@ public function testGenerateWithHtml() { $url = new Url('test_route_5', array(), array('html' => TRUE)); $url->setUrlGenerator($this->urlGenerator); $result = $this->linkGenerator->generate('HTML output', $url); - $this->assertLink(array( + $this->assertTag(array( + 'tag' => 'a', 'attributes' => array('href' => '/test-route-5'), 'child' => array( 'tag' => 'em', @@ -375,7 +390,8 @@ public function testGenerateActive() { $url = new Url('test_route_1', array(), array('set_active_class' => TRUE)); $url->setUrlGenerator($this->urlGenerator); $result = $this->linkGenerator->generate('Test', $url); - $this->assertLink(array( + $this->assertTag(array( + 'tag' => 'a', 'attributes' => array('data-drupal-link-system-path' => 'test-route-1'), ), $result); @@ -383,7 +399,10 @@ public function testGenerateActive() { $url = new Url('test_route_1', array(), array('set_active_class' => FALSE)); $url->setUrlGenerator($this->urlGenerator); $result = $this->linkGenerator->generate('Test', $url); - $this->assertNoXPathResults('//a[@data-drupal-link-system-path="test-route-1"]', $result); + $this->assertNotTag(array( + 'tag' => 'a', + 'attributes' => array('data-drupal-link-system-path' => 'test-route-1'), + ), $result); // Render a link with an associated language. $url = new Url('test_route_1', array(), array( @@ -392,7 +411,8 @@ public function testGenerateActive() { )); $url->setUrlGenerator($this->urlGenerator); $result = $this->linkGenerator->generate('Test', $url); - $this->assertLink(array( + $this->assertTag(array( + 'tag' => 'a', 'attributes' => array( 'data-drupal-link-system-path' => 'test-route-1', 'hreflang' => 'de', @@ -406,10 +426,11 @@ public function testGenerateActive() { )); $url->setUrlGenerator($this->urlGenerator); $result = $this->linkGenerator->generate('Test', $url); - $this->assertLink(array( + $this->assertTag(array( + 'tag' => 'a', 'attributes' => array( 'data-drupal-link-system-path' => 'test-route-3', - 'data-drupal-link-query' => '{"value":"example_1"}', + 'data-drupal-link-query' => 'regexp:/.*value.*example_1.*/', ), ), $result); @@ -420,72 +441,15 @@ public function testGenerateActive() { )); $url->setUrlGenerator($this->urlGenerator); $result = $this->linkGenerator->generate('Test', $url); - $this->assertLink(array( + $this->assertTag(array( + 'tag' => 'a', 'attributes' => array( 'data-drupal-link-system-path' => 'test-route-4/1', - 'data-drupal-link-query' => '{"value":"example_1"}', + 'data-drupal-link-query' => 'regexp:/.*value.*example_1.*/', ), ), $result); } - /** - * Checks that a link with certain properties exists in a given HTML snippet. - * - * @param array $properties - * An associative array of link properties, with the following keys: - * - attributes: optional array of HTML attributes that should be present. - * - content: optional link content. - * @param string $html - * The HTML to check. - * @param int $count - * How many times the link should be present in the HTML. Defaults to 1. - */ - public static function assertLink(array $properties, $html, $count = 1) { - // Provide default values. - $properties += array('attributes' => array()); - - // Create an XPath query that selects a link element. - $query = '//a'; - - // Append XPath predicates for the attributes and content text. - $predicates = array(); - foreach ($properties['attributes'] as $attribute => $value) { - $predicates[] = "@$attribute='$value'"; - } - if (!empty($properties['content'])) { - $predicates[] = "contains(.,'{$properties['content']}')"; - } - if (!empty($predicates)) { - $query .= '[' . implode(' and ', $predicates) . ']'; - } - - // Execute the query. - $document = new \DOMDocument; - $document->loadHTML($html); - $xpath = new \DOMXPath($document); - - self::assertEquals($count, $xpath->query($query)->length); - } - - /** - * Checks that the given XPath query has no results in a given HTML snippet. - * - * @param string $query - * The XPath query to execute. - * @param string $html - * The HTML snippet to check. - * - * @return int - * The number of results that are found. - */ - protected function assertNoXPathResults($query, $html) { - $document = new \DOMDocument; - $document->loadHTML($html); - $xpath = new \DOMXPath($document); - - self::assertFalse((bool) $xpath->query($query)->length); - } - } } diff --git a/core/themes/classy/templates/links.html.twig b/core/themes/classy/templates/links.html.twig deleted file mode 100644 index 56c7ec2..0000000 --- a/core/themes/classy/templates/links.html.twig +++ /dev/null @@ -1,60 +0,0 @@ -{# -/** - * @file - * Default theme implementation for a set of links. - * - * Available variables: - * - attributes: Attributes for the UL containing the list of links. - * - links: Links to be output. - * Each link will have the following elements: - * - title: The link text. - * - href: The link URL. If omitted, the 'title' is shown as a plain text - * item in the links list. If 'href' is supplied, the entire link is passed - * to l() as its $options parameter. - * - html: (optional) Whether or not 'title' is HTML. If set, the title will - * not be passed through \Drupal\Component\Utility\String::checkPlain(). - * - attributes: (optional) HTML attributes for the anchor, or for the - * tag if no 'href' is supplied. - * - link_key: The link CSS class. - * - heading: (optional) A heading to precede the links. - * - text: The heading text. - * - level: The heading level (e.g. 'h2', 'h3'). - * - attributes: (optional) A keyed list of attributes for the heading. - * If the heading is a string, it will be used as the text of the heading and - * the level will default to 'h2'. - * - * Headings should be used on navigation menus and any list of links that - * consistently appears on multiple pages. To make the heading invisible use - * the 'visually-hidden' CSS class. Do not use 'display:none', which - * removes it from screen readers and assistive technology. Headings allow - * screen reader and keyboard only users to navigate to or skip the links. - * See http://juicystudio.com/article/screen-readers-display-none.php and - * http://www.w3.org/TR/WCAG-TECHS/H42.html for more information. - * - * @see template_preprocess_links() - * - * @ingroup themeable - */ -#} -{% if links -%} - {%- if heading -%} - {%- if heading.level -%} - <{{ heading.level }}{{ heading.attributes }}>{{ heading.text }} - {%- else -%} - {{ heading.text }} - {%- endif -%} - {%- endif -%} - - {%- for key, item in links -%} - - {%- if item.link -%} - {{ item.link }} - {%- elseif item.text_attributes -%} - {{ item.text }} - {%- else -%} - {{ item.text }} - {%- endif -%} - - {%- endfor -%} - -{%- endif %}