diff --git a/core/modules/block/custom_block/custom_block.pages.inc b/core/modules/block/custom_block/custom_block.pages.inc index b9fa88f..a0dc773 100644 --- a/core/modules/block/custom_block/custom_block.pages.inc +++ b/core/modules/block/custom_block/custom_block.pages.inc @@ -10,32 +10,25 @@ use Symfony\Component\HttpFoundation\RedirectResponse; /** - * Returns HTML for a list of available custom block types for block creation. + * Prepares variables for a custom block type creation list templates. * - * @param $variables + * Default template: custom-block-add-list.html.twig. + * + * @param array $variables * An associative array containing: * - content: An array of block types. * * @see custom_block_add_page() - * - * @ingroup themeable */ -function theme_custom_block_add_list($variables) { - $content = $variables['content']; - $output = ''; - - if ($content) { - $output = '
'; - foreach ($content as $type) { - $output .= '
' . l($type->label(), 'block/add/' . $type->id()) . '
'; - $output .= '
' . filter_xss_admin($type->description) . '
'; - } - $output .= '
'; +function template_preprocess_custom_block_add_list(&$variables) { + $variables['types'] = array(); + foreach ($variables['content'] as $type) { + $variables['types'][$type->id] = array(); + $variables['types'][$type->id]['link'] = l($type->label(), 'block/add/' . $type->id()); + $variables['types'][$type->id]['description'] = filter_xss_admin($type->description); } - return $output; } - /** * Page callback: Presents the custom block creation form. * @@ -100,10 +93,6 @@ function custom_block_delete_form($form, &$form_state, CustomBlock $block) { ); $instances = $block->getInstances(); - $form['instances'] = array( - '#type' => 'value', - '#value' => $instances, - ); $form['message'] = array( '#type' => 'markup', diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php index f62dd0d..e44aa75 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php @@ -125,6 +125,9 @@ public function testBlockDelete() { $block = custom_block_load(1); + // Test getInstances method. + $this->assertEqual(1, count($block->getInstances())); + // Navigate to home page. $this->drupalGet(''); $this->assertText($body);