diff --git a/core/modules/block/lib/Drupal/block/Entity/Block.php b/core/modules/block/lib/Drupal/block/Entity/Block.php index 44fa169..a8ea16e 100644 --- a/core/modules/block/lib/Drupal/block/Entity/Block.php +++ b/core/modules/block/lib/Drupal/block/Entity/Block.php @@ -121,7 +121,11 @@ public function getPlugin() { */ public function label($langcode = NULL) { $settings = $this->get('settings'); - return $settings['label']; + $definition = $this->getPlugin()->getPluginDefinition(); + $definition += array( + 'admin_label' => '', + ); + return $settings['label'] ?: $definition['admin_label']; } /** diff --git a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php index 3f3fe30..9628826 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php @@ -46,7 +46,7 @@ public function build() { * {@inheritdoc} */ public function defaultConfiguration() { - $settings = array(); + $settings = parent::defaultConfiguration(); if ($this->displaySet) { return $this->view->display_handler->blockSettings($settings); diff --git a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlockBase.php b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlockBase.php index e20f146..a04fd08 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlockBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlockBase.php @@ -87,6 +87,16 @@ public function access(AccountInterface $account) { /** * {@inheritdoc} */ + public function defaultConfiguration() { + $settings = array(); + $settings['views_label'] = ''; + + return $settings; + } + + /** + * {@inheritdoc} + */ public function buildConfigurationForm(array $form, array &$form_state) { $form = parent::buildConfigurationForm($form, $form_state); @@ -94,10 +104,59 @@ public function buildConfigurationForm(array $form, array &$form_state) { $form['label']['#default_value'] = ''; $form['label']['#access'] = FALSE; + // Allow to override the label on the actual page. + $form['views_label_checkbox'] = array( + '#type' => 'checkbox', + '#title' => $this->t('Override title'), + '#default_value' => !empty($this->configuration['views_label']), + ); + + $form['views_label_fieldset'] = array( + '#type' => 'fieldset', + '#states' => array( + 'visible' => array(array( + ':input[name="settings[views_label_checkbox]"]' => array('checked' => TRUE), + ), + )), + ); + + $form['views_label_fieldset']['views_label_warning'] = array( + '#markup' => $this->t('