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 43c0813..23d614b 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php @@ -114,15 +114,6 @@ protected function addContextualLinks(&$output, $block_type = 'block') { } /** - * Returns the ViewExecutable instance for this block. - * - * @return \Drupal\views\ViewExecutable - */ - public function getView() { - return $this->view; - } - - /** * Generates a views block instance ID. * * @param \Drupal\Core\Entity\EntityStorageControllerInterface $manager @@ -141,6 +132,8 @@ public function generateBlockInstanceID(EntityStorageControllerInterface $manage return end($parts); }, array_keys($manager->load())); + // Iterate through potential IDs until we get a new one. E.g. + // 'views_block__MYVIEW_PAGE_1_2' $count = 1; $id = $original_id; while (in_array($id, $block_ids)) { diff --git a/core/modules/views/views.module b/core/modules/views/views.module index f5dd587..f5ccf36 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -1724,23 +1724,24 @@ function views_cache_get($cid, $use_language = FALSE) { } /** - * Implement hook_form_alter for the views block form. + * Implements hook_form_block_form_alter. * - * Views overrides block configuration form elements during ViewsBlock:form() - * but machine_name assignment is added later by BlockFormController:form() - * so we provide an override for the block machine_name here. + * Views overrides block configuration form elements during + * \Drupal\views\Plugin\Block\ViewsBlock::form() but machine_name assignment is + * added later by \Drupal\block\BlockFormController::form() so we provide an + * override for the block machine_name here. */ function views_form_block_form_alter(&$form, &$form_state) { // Ensure the block-form being altered is a Views block configuration form. if (($form['settings']['module']['#value'] == 'views') && empty($form['machine_name']['#default_value'])) { - // Unset the machine_name provided by BlockFormController + // Unset the machine_name provided by BlockFormController. unset($form['machine_name']['#machine_name']['source']); // Load the Views plugin object using form_state array and create a // block machine_name based on the View ID and View Display ID. $block_plugin = $form_state['controller']->getEntity()->getPlugin(); // Override the Views block's machine_name by providing a default_value. $form['machine_name']['#default_value'] = $block_plugin->generateBlockInstanceID(Drupal::entityManager()->getStorageController('block')); - // Prevent users from changing the auto-generate block machine_name. + // Prevent users from changing the auto-generated block machine_name. $form['machine_name']['#access'] = FALSE; } }