diff --git a/core/modules/language/lib/Drupal/language/Plugin/block/block/LanguageBlock.php b/core/modules/language/lib/Drupal/language/Plugin/block/block/LanguageBlock.php index 53c58e7..68bf40e 100644 --- a/core/modules/language/lib/Drupal/language/Plugin/block/block/LanguageBlock.php +++ b/core/modules/language/lib/Drupal/language/Plugin/block/block/LanguageBlock.php @@ -24,6 +24,15 @@ class LanguageBlock extends BlockBase { /** + * Overrides \Drupal\block\BlockBase::settings(). + */ + public function settings() { + return array( + 'block_type' => 'theme', + ); + } + + /** * Overrides \Drupal\block\BlockBase::blockAccess(). */ function blockAccess() { @@ -31,6 +40,29 @@ function blockAccess() { } /** + * Overrides \Drupal\block\BlockBase::blockForm(). + */ + public function blockForm($form, &$form_state) { + $form['block_type'] = array( + '#type' => 'radios', + '#title' => t('Display as'), + '#default_value' => $this->configuration['block_type'], + '#options' => array( + 'theme' => t('HTML List'), + 'type' => t('JavaScript operations'), + ), + ); + return $form; + } + + /** + * Overrides \Drupal\block\BlockBase::blockSubmit(). + */ + public function blockSubmit($form, &$form_state) { + $this->configuration['block_type'] = $form_state['values']['block_type']; + } + + /** * Implements \Drupal\block\BlockBase::build(). */ public function build() { @@ -41,7 +73,6 @@ public function build() { if (isset($links->links)) { $build = array( - '#theme' => 'links__language_block', '#links' => $links->links, '#attributes' => array( 'class' => array( @@ -49,6 +80,17 @@ public function build() { ), ), ); + // Attach some logic. + if ($this->configuration['block_type'] == 'theme') { + $build += array( + '#theme' => 'links__language_block', + ); + } + elseif ($this->configuration['block_type'] == 'type') { + $build += array( + '#type' => 'operations', + ); + } } return $build; } diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php index ac834d1..ea732c5 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php @@ -59,7 +59,7 @@ function testLanguageBlock() { $this->assertText($block->label(), 'Language switcher block found.'); // Assert that only the current language is marked as active. - list($language_switcher) = $this->xpath('//div[@id=:id]/div[@class="content"]', array(':id' => 'block-test-language-block')); + $language_switcher_item = $this->xpath('//div[@id=:id]//li', array(':id' => 'block-test-language-block')); $links = array( 'active' => array(), 'inactive' => array(), @@ -68,7 +68,7 @@ function testLanguageBlock() { 'active' => array(), 'inactive' => array(), ); - foreach ($language_switcher->ul->li as $link) { + foreach ($language_switcher_item as $link) { $classes = explode(" ", (string) $link['class']); list($langcode) = array_intersect($classes, array('en', 'fr')); if (in_array('active', $classes)) {