Commit ffea3bb9 authored by alexpott's avatar alexpott

Issue #2408977 by geertvd: Fatal error: Cannot access protected property...

Issue #2408977 by geertvd: Fatal error: Cannot access protected property Drupal\block\Entity\Block::$id
parent 94c7316a
......@@ -334,7 +334,7 @@ protected function disableLanguageSwitcher(array $language_types) {
$blocks = $this->blockStorage->loadByProperties(array('theme' => $theme));
foreach ($language_types as $language_type) {
foreach ($blocks as $block) {
if (strpos($block->id, 'language_switcher_' . substr($language_type, 9)) !== FALSE) {
if ($block->getPluginId() == 'language_block:' . $language_type) {
$block->delete();
}
}
......
......@@ -20,6 +20,7 @@
use Drupal\Core\Language\LanguageInterface;
use Symfony\Component\HttpFoundation\Request;
use Drupal\language\LanguageNegotiatorInterface;
use Drupal\block\Entity\Block;
/**
* Tests UI language switching.
......@@ -502,4 +503,29 @@ public function testContentCustomization() {
$this->assertFalse(array_key_exists('language-url', $config->get('negotiation.language_content.enabled')), 'URL negotiation is not enabled for content.');
$this->assertTrue(array_key_exists('language-session', $config->get('negotiation.language_content.enabled')), 'Session negotiation is enabled for content.');
}
/**
* Tests if the language switcher block gets deleted when a language type has been made not configurable.
*/
public function testDisableLanguageSwitcher() {
$block_id = 'test_language_block';
// Enable the language switcher block.
$this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_CONTENT, array('id' => $block_id));
// Check if the language switcher block has been created.
$block = Block::load($block_id);
$this->assertTrue($block, 'Language switcher block was created.');
// Make sure language_content is not configurable.
$edit = array(
'language_content[configurable]' => FALSE,
);
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
$this->assertResponse(200);
// Check if the language switcher block has been removed.
$block = Block::load($block_id);
$this->assertFalse($block, 'Language switcher block was removed.');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment