diff --git a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php index d6b1cd6..cb85878 100644 --- a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php +++ b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php @@ -41,9 +41,6 @@ public function __construct(ParameterBagInterface $parameterBag = NULL) { * services in a frozen builder. */ public function set($id, $service, $scope = self::SCOPE_CONTAINER) { - if (strtolower($id) !== $id) { - throw new \InvalidArgumentException("Service ID names must be lowercase: $id"); - } SymfonyContainer::set($id, $service, $scope); // Ensure that the _serviceId property is set on synthetic services as well. @@ -53,26 +50,6 @@ public function set($id, $service, $scope = self::SCOPE_CONTAINER) { } /** - * {@inheritdoc} - */ - public function register($id, $class = null) { - if (strtolower($id) !== $id) { - throw new \InvalidArgumentException("Service ID names must be lowercase: $id"); - } - return parent::register($id, $class); - } - - /** - * {@inheritdoc} - */ - public function setParameter($name, $value) { - if (strtolower($name) !== $name) { - throw new \InvalidArgumentException("Parameter names must be lowercase: $name"); - } - parent::setParameter($name, $value); - } - - /** * Synchronizes a service change. * * This method is a copy of the ContainerBuilder of symfony. diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 8202cd6..815f7f3 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -977,7 +977,7 @@ protected function initializeRequestGlobals(Request $request) { */ protected function getServicesToPersist(ContainerInterface $container) { $persist = array(); - foreach ($container->getParameter('persist_ids') as $id) { + foreach ($container->getParameter('persistIds') as $id) { // It's pointless to persist services not yet initialized. if ($container->initialized($id)) { $persist[$id] = $container->get($id); @@ -1127,7 +1127,7 @@ protected function compileContainer() { $persist_ids[] = $id; } } - $container->setParameter('persist_ids', $persist_ids); + $container->setParameter('persistIds', $persist_ids); $container->compile(); return $container; diff --git a/core/modules/config/src/Tests/DefaultConfigTest.php b/core/modules/config/src/Tests/DefaultConfigTest.php index 9e32a45..99ff07a 100644 --- a/core/modules/config/src/Tests/DefaultConfigTest.php +++ b/core/modules/config/src/Tests/DefaultConfigTest.php @@ -53,12 +53,12 @@ protected function setUp() { */ public function containerBuild(ContainerBuilder $container) { parent::containerBuild($container); - $container->register('default_config_test.schema_storage') + $container->register('DefaultConfigTest.schema_storage') ->setClass('\Drupal\config_test\TestInstallStorage') ->addArgument(InstallStorage::CONFIG_SCHEMA_DIRECTORY); $definition = $container->getDefinition('config.typed'); - $definition->replaceArgument(1, new Reference('default_config_test.schema_storage')); + $definition->replaceArgument(1, new Reference('DefaultConfigTest.schema_storage')); } /** diff --git a/core/modules/language/src/Plugin/Block/LanguageBlock.php b/core/modules/language/src/Plugin/Block/LanguageBlock.php index 3995ece..1e7c26b 100644 --- a/core/modules/language/src/Plugin/Block/LanguageBlock.php +++ b/core/modules/language/src/Plugin/Block/LanguageBlock.php @@ -10,6 +10,8 @@ use Drupal\Core\Access\AccessResult; use Drupal\Core\Block\BlockBase; use Drupal\Core\Path\PathMatcherInterface; +use Drupal\Core\Form\FormStateInterface; +use Drupal\language\LanguageNegotiatorInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; @@ -36,6 +38,12 @@ class LanguageBlock extends BlockBase implements ContainerFactoryPluginInterface protected $languageManager; /** + * The language negotiator. + * @var \Drupal\language\LanguageNegotiatorInterface + */ + protected $negotiator; + + /** * The path matcher. * * @var \Drupal\Core\Path\PathMatcherInterface @@ -55,11 +63,14 @@ class LanguageBlock extends BlockBase implements ContainerFactoryPluginInterface * The language manager. * @param \Drupal\Core\Path\PathMatcherInterface $path_matcher * The path matcher. + * @param \Drupal\language\LanguageNegotiatorInterface $negotiator + * The language negotiator. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, LanguageManagerInterface $language_manager, PathMatcherInterface $path_matcher) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, LanguageManagerInterface $language_manager, PathMatcherInterface $path_matcher, LanguageNegotiatorInterface $negotiator) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->languageManager = $language_manager; $this->pathMatcher = $path_matcher; + $this->negotiator = $negotiator; } @@ -72,7 +83,8 @@ public static function create(ContainerInterface $container, array $configuratio $plugin_id, $plugin_definition, $container->get('language_manager'), - $container->get('path.matcher') + $container->get('path.matcher'), + $container->get('language_negotiator') ); } @@ -118,4 +130,23 @@ public function getCacheMaxAge() { return 0; } + /** + * {@inheritdoc} + */ + public function blockForm($form, FormStateInterface $form_state) { + $form = parent::blockForm($form, $form_state); + $languages = $this->languageManager->getLanguages(); + // Warn the user that if only one language is enabled the block won't appear. + if (count($languages) == 1) { + drupal_set_message($this->t('Only one language is enabled. Therefore the language switcher block will not be shown. To add a new language on the site, go to @language-link.', array('@language-link' => \Drupal::l(t('Language list'), Url::fromRoute('entity.configurable_language.collection')))), 'warning'); + } + // Warn the user that if there are no links to show because language-url + // method detection isn't enabled, the block won't appear. + elseif (!$this->negotiator->isNegotiationMethodEnabled('language-url')) { + drupal_set_message($this->t('No language detection method is enabled that would provide URL based detection. Therefore the language switcher block will not be shown.'), 'warning'); + } + + return $form; + } + } diff --git a/core/modules/system/tests/modules/form_test/form_test.routing.yml b/core/modules/system/tests/modules/form_test/form_test.routing.yml index 8a200a3..140b17c 100644 --- a/core/modules/system/tests/modules/form_test/form_test.routing.yml +++ b/core/modules/system/tests/modules/form_test/form_test.routing.yml @@ -15,7 +15,7 @@ form_test.route2: form_test.route3: path: '/form-test/object-service-builder' defaults: - _form: 'form_test.form.serviceform' + _form: 'form_test.form.serviceForm' requirements: _access: 'TRUE' diff --git a/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerBuilderTest.php b/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerBuilderTest.php index 0df17c4..8a93b6d 100644 --- a/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/DependencyInjection/ContainerBuilderTest.php @@ -38,36 +38,4 @@ public function testSet() { $this->assertEquals('bar', $class->_serviceId); } - /** - * @covers ::set - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Service ID names must be lowercase: Bar - */ - public function testSetException() { - $container = new ContainerBuilder(); - $class = new BarClass(); - $container->set('Bar', $class); - $this->assertNotEquals('bar', $class->_serviceId); - } - - /** - * @covers ::setParameter - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Parameter names must be lowercase: Buzz - */ - public function testSetParameterException() { - $container = new ContainerBuilder(); - $container->setParameter('Buzz', 'buzz'); - } - - /** - * @covers ::register - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Service ID names must be lowercase: Bar - */ - public function testRegisterException() { - $container = new ContainerBuilder(); - $container->register('Bar'); - } - }