commit 93accc2b7311bd655a09c1d4fc7d3e535558f9c0 Author: Lee Rowlands Date: Thu Feb 14 09:12:01 2013 +1000 Merge 8.x and test diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module index cdcf258..3ee9574 100644 --- a/core/modules/block/custom_block/custom_block.module +++ b/core/modules/block/custom_block/custom_block.module @@ -8,6 +8,8 @@ use Drupal\custom_block\Plugin\Core\Entity\CustomBlockType; use Drupal\custom_block\Plugin\Core\Entity\CustomBlock; use Symfony\Component\HttpFoundation\RedirectResponse; +use Drupal\custom_block\Plugin\block\block\CustomBlock as CustomBlockPlugin; +use Drupal\block\Plugin\Core\Entity\Block; /** * Implements hook_menu(). @@ -86,16 +88,20 @@ function custom_block_menu() { 'description' => 'Add custom block', 'file' => 'custom_block.pages.inc', ); - $items['block/%custom_block/edit'] = array( + // There has to be a base-item in order for contextual links to work. + $items['block/%custom_block'] = array( 'title' => 'Edit', 'page callback' => 'custom_block_edit', 'page arguments' => array(1), 'access callback' => 'entity_page_access', 'access arguments' => array(1, 'update'), + 'file' => 'custom_block.pages.inc', + ); + $items['block/%custom_block/edit'] = array( + 'title' => 'Edit', 'weight' => 0, - 'type' => MENU_LOCAL_TASK, + 'type' => MENU_DEFAULT_LOCAL_TASK, 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, - 'file' => 'custom_block.pages.inc', ); $items['block/%custom_block/delete'] = array( 'title' => 'Delete', @@ -119,6 +125,10 @@ function custom_block_theme($existing, $type, $theme, $path) { 'custom_block_block' => array( 'variables' => array('body' => NULL, 'format' => NULL), ), + 'custom_block_add_list' => array( + 'variables' => array('content' => NULL), + 'file' => 'custom_block.pages.inc', + ), ); } @@ -175,12 +185,13 @@ function custom_block_entity_info_alter(&$types) { */ function custom_block_entity_bundle_info() { $bundles = array(); - foreach (entity_load_multiple('custom_block_type') as $id => $block_type) { - $bundles['custom_block'][$id] = array( - 'label' => $block_type->label(), + foreach (config_get_storage_names_with_prefix('custom_block.type.') as $config_name) { + $config = config($config_name); + $bundles['custom_block'][$config->get('id')] = array( + 'label' => $config->get('label'), 'admin' => array( 'path' => 'admin/structure/custom-blocks/manage/%', - 'real path' => 'admin/structure/custom-blocks/manage/' . $id, + 'real path' => 'admin/structure/custom-blocks/manage/' . $config->get('id'), 'bundle argument' => 4, ), ); @@ -253,9 +264,10 @@ function custom_block_form_block_plugin_ui_alter(&$form, $form_state) { if ($base !== 'custom_block') { continue; } + $custom_block = entity_load_by_uuid('custom_block', $derivative); $row['1']['data']['#links']['edit'] = array( 'title' => t('Edit'), - 'href' => 'block/' . $derivative . '/edit' + 'href' => 'block/' . $custom_block->id() . '/edit' ); } } @@ -284,3 +296,15 @@ function custom_block_add_block_redirect($theme) { $url = url('block/add', array('query' => array('theme' => $theme))); return new RedirectResponse($url); } + +/** + * Implements hook_block_view_alter(). + */ +function custom_block_block_view_alter(array &$build, Block $block) { + // Add contextual links for custom blocks. + if ($block->getPlugin() instanceof CustomBlockPlugin) { + // Move contextual links from inner content to outer wrapper. + $build['#contextual_links']['custom_block'] = $build['content']['#contextual_links']['custom_block']; + unset($build['content']['#contextual_links']['custom_block']); + } +} diff --git a/core/modules/block/custom_block/custom_block.pages.inc b/core/modules/block/custom_block/custom_block.pages.inc index 3bbce06..2af5a70 100644 --- a/core/modules/block/custom_block/custom_block.pages.inc +++ b/core/modules/block/custom_block/custom_block.pages.inc @@ -37,25 +37,37 @@ function custom_block_add_page() { $url = url('block/add/' . $type->id(), $options); return new RedirectResponse($url); } - // Multiple custom block types exist, present a list of links. - $links = array(); - foreach ($types as $id => $type) { - $links[] = l($config->get('label'), 'block/add/' . $config->get('id'), $options); + return array('#theme' => 'custom_block_add_list', '#content' => $types); +} + +/** + * Returns HTML for a list of available custom block types for block creation. + * + * @param $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 .= '
'; } - $item = menu_get_item(); - $content = system_admin_menu_block($item); - dsm($content); - return array( - '#theme' => array( - 'item_list', - 'item_list__custom_block_add' - ), - '#items' => $links, - '#title' => t('Choose a block type to continue.') - ); + return $output; } + /** * Page callback: Presents the custom block creation form. * diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php index fe733de..60c2b7e 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php @@ -21,7 +21,7 @@ class CustomBlockRenderController extends EntityRenderController { */ protected function alterBuild(array &$build, EntityInterface $entity, EntityDisplay $display, $view_mode, $langcode = NULL) { parent::alterBuild($build, $entity, $display, $view_mode, $langcode); - // Add contextual links for this custom block, except when the block. + // Add contextual links for this custom block. if (!empty($entity->id->value) && $view_mode == 'full') { $build['#contextual_links']['custom_block'] = array('block', array($entity->id())); } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeListController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeListController.php index 8f4e333..caa93bb 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeListController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeListController.php @@ -42,6 +42,7 @@ public function getOperations(EntityInterface $entity) { */ public function buildHeader() { $row['type'] = t('Block type'); + $row['description'] = t('Description'); $row['operations'] = t('Operations'); return $row; } @@ -53,6 +54,7 @@ public function buildRow(EntityInterface $entity) { parent::buildRow($entity); $uri = $entity->uri(); $row['type'] = l($entity->label(), $uri['path'], $uri['options']); + $row['description'] = filter_xss_admin($entity->description); $row['operations']['data'] = $this->buildOperations($entity); return $row; } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php index cd73741..11b5a6f 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php @@ -195,7 +195,8 @@ protected function init() { */ public function uri() { return array( - 'path' => 'block/' . $block->id(), + 'path' => 'block/' . $this->id(), + 'options' => array() ); } } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlockType.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlockType.php index 2d7daba..f2843f7 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlockType.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlockType.php @@ -73,7 +73,8 @@ class CustomBlockType extends ConfigEntityBase { */ public function uri() { return array( - 'path' => 'admin/structure/custom-blocks/manage/' . $block_type->id(), + 'path' => 'admin/structure/custom-blocks/manage/' . $this->id(), + 'options' => array() ); } } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php index 2cc8916..3b88c43 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php @@ -76,7 +76,7 @@ public function blockSubmit($form, &$form_state) { */ public function build() { list(, $uuid) = explode(':', $this->getPluginId()); - if ($block = entity_load_by_uuid($uuid)) { + if ($block = entity_load_by_uuid('custom_block', $uuid)) { return entity_view($block, $this->configuration['view_mode']); } else { diff --git a/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php b/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php index 2b00c56..740b349 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php +++ b/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php @@ -95,7 +95,7 @@ public function form($form, &$form_state, $facet = NULL) { } } // Sort rows alphabetically. - sort($rows); + asort($rows); $form['left']['plugin_library'] = array( '#theme' => 'table', '#header' => $this->tableHeader(), diff --git a/core/themes/seven/template.php b/core/themes/seven/template.php index ae9120d..a2c85ee 100644 --- a/core/themes/seven/template.php +++ b/core/themes/seven/template.php @@ -63,6 +63,27 @@ function seven_node_add_list($variables) { } /** + * Displays the list of available custom block types for creation. + */ +function seven_custom_block_add_list($variables) { + $content = $variables['content']; + $output = ''; + if ($content) { + $output = ''; + } + return $output; +} + +/** * Overrides theme_admin_block_content(). * * Uses an unordered list markup in both compact and extended mode. commit 9ee641188ce6c4a0d61be1e1ec0db887edad18d0 Author: Lee Rowlands Date: Thu Feb 14 09:12:01 2013 +1000 Merge 8.x and test diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module index cdcf258..3ee9574 100644 --- a/core/modules/block/custom_block/custom_block.module +++ b/core/modules/block/custom_block/custom_block.module @@ -8,6 +8,8 @@ use Drupal\custom_block\Plugin\Core\Entity\CustomBlockType; use Drupal\custom_block\Plugin\Core\Entity\CustomBlock; use Symfony\Component\HttpFoundation\RedirectResponse; +use Drupal\custom_block\Plugin\block\block\CustomBlock as CustomBlockPlugin; +use Drupal\block\Plugin\Core\Entity\Block; /** * Implements hook_menu(). @@ -86,16 +88,20 @@ function custom_block_menu() { 'description' => 'Add custom block', 'file' => 'custom_block.pages.inc', ); - $items['block/%custom_block/edit'] = array( + // There has to be a base-item in order for contextual links to work. + $items['block/%custom_block'] = array( 'title' => 'Edit', 'page callback' => 'custom_block_edit', 'page arguments' => array(1), 'access callback' => 'entity_page_access', 'access arguments' => array(1, 'update'), + 'file' => 'custom_block.pages.inc', + ); + $items['block/%custom_block/edit'] = array( + 'title' => 'Edit', 'weight' => 0, - 'type' => MENU_LOCAL_TASK, + 'type' => MENU_DEFAULT_LOCAL_TASK, 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, - 'file' => 'custom_block.pages.inc', ); $items['block/%custom_block/delete'] = array( 'title' => 'Delete', @@ -119,6 +125,10 @@ function custom_block_theme($existing, $type, $theme, $path) { 'custom_block_block' => array( 'variables' => array('body' => NULL, 'format' => NULL), ), + 'custom_block_add_list' => array( + 'variables' => array('content' => NULL), + 'file' => 'custom_block.pages.inc', + ), ); } @@ -175,12 +185,13 @@ function custom_block_entity_info_alter(&$types) { */ function custom_block_entity_bundle_info() { $bundles = array(); - foreach (entity_load_multiple('custom_block_type') as $id => $block_type) { - $bundles['custom_block'][$id] = array( - 'label' => $block_type->label(), + foreach (config_get_storage_names_with_prefix('custom_block.type.') as $config_name) { + $config = config($config_name); + $bundles['custom_block'][$config->get('id')] = array( + 'label' => $config->get('label'), 'admin' => array( 'path' => 'admin/structure/custom-blocks/manage/%', - 'real path' => 'admin/structure/custom-blocks/manage/' . $id, + 'real path' => 'admin/structure/custom-blocks/manage/' . $config->get('id'), 'bundle argument' => 4, ), ); @@ -253,9 +264,10 @@ function custom_block_form_block_plugin_ui_alter(&$form, $form_state) { if ($base !== 'custom_block') { continue; } + $custom_block = entity_load_by_uuid('custom_block', $derivative); $row['1']['data']['#links']['edit'] = array( 'title' => t('Edit'), - 'href' => 'block/' . $derivative . '/edit' + 'href' => 'block/' . $custom_block->id() . '/edit' ); } } @@ -284,3 +296,15 @@ function custom_block_add_block_redirect($theme) { $url = url('block/add', array('query' => array('theme' => $theme))); return new RedirectResponse($url); } + +/** + * Implements hook_block_view_alter(). + */ +function custom_block_block_view_alter(array &$build, Block $block) { + // Add contextual links for custom blocks. + if ($block->getPlugin() instanceof CustomBlockPlugin) { + // Move contextual links from inner content to outer wrapper. + $build['#contextual_links']['custom_block'] = $build['content']['#contextual_links']['custom_block']; + unset($build['content']['#contextual_links']['custom_block']); + } +} diff --git a/core/modules/block/custom_block/custom_block.pages.inc b/core/modules/block/custom_block/custom_block.pages.inc index 3bbce06..2af5a70 100644 --- a/core/modules/block/custom_block/custom_block.pages.inc +++ b/core/modules/block/custom_block/custom_block.pages.inc @@ -37,25 +37,37 @@ function custom_block_add_page() { $url = url('block/add/' . $type->id(), $options); return new RedirectResponse($url); } - // Multiple custom block types exist, present a list of links. - $links = array(); - foreach ($types as $id => $type) { - $links[] = l($config->get('label'), 'block/add/' . $config->get('id'), $options); + return array('#theme' => 'custom_block_add_list', '#content' => $types); +} + +/** + * Returns HTML for a list of available custom block types for block creation. + * + * @param $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 .= '
'; } - $item = menu_get_item(); - $content = system_admin_menu_block($item); - dsm($content); - return array( - '#theme' => array( - 'item_list', - 'item_list__custom_block_add' - ), - '#items' => $links, - '#title' => t('Choose a block type to continue.') - ); + return $output; } + /** * Page callback: Presents the custom block creation form. * diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php index 883dc2f..2865baf 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php @@ -67,12 +67,18 @@ public function form(array $form, array &$form_state, EntityInterface $block) { $language_configuration = module_invoke('language', 'get_default_configuration', 'custom_block', $block->type->value); + // Set the correct default language. + if ($block->isNew() && !empty($language_configuration['langcode'])) { + $language_default = language($language_configuration['langcode']); + $block->langcode->value = $language_default->langcode; + } + $form['langcode'] = array( '#title' => t('Language'), '#type' => 'language_select', '#default_value' => $block->langcode->value, '#languages' => LANGUAGE_ALL, - '#access' => isset($language_configuration['language_show']) && !$language_configuration['language_show'], + '#access' => isset($language_configuration['language_show']) && $language_configuration['language_show'], ); $form['additional_settings'] = array( diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php index fe733de..60c2b7e 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php @@ -21,7 +21,7 @@ class CustomBlockRenderController extends EntityRenderController { */ protected function alterBuild(array &$build, EntityInterface $entity, EntityDisplay $display, $view_mode, $langcode = NULL) { parent::alterBuild($build, $entity, $display, $view_mode, $langcode); - // Add contextual links for this custom block, except when the block. + // Add contextual links for this custom block. if (!empty($entity->id->value) && $view_mode == 'full') { $build['#contextual_links']['custom_block'] = array('block', array($entity->id())); } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeListController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeListController.php index 8f4e333..caa93bb 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeListController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeListController.php @@ -42,6 +42,7 @@ public function getOperations(EntityInterface $entity) { */ public function buildHeader() { $row['type'] = t('Block type'); + $row['description'] = t('Description'); $row['operations'] = t('Operations'); return $row; } @@ -53,6 +54,7 @@ public function buildRow(EntityInterface $entity) { parent::buildRow($entity); $uri = $entity->uri(); $row['type'] = l($entity->label(), $uri['path'], $uri['options']); + $row['description'] = filter_xss_admin($entity->description); $row['operations']['data'] = $this->buildOperations($entity); return $row; } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php index cd73741..11b5a6f 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php @@ -195,7 +195,8 @@ protected function init() { */ public function uri() { return array( - 'path' => 'block/' . $block->id(), + 'path' => 'block/' . $this->id(), + 'options' => array() ); } } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlockType.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlockType.php index 2d7daba..f2843f7 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlockType.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlockType.php @@ -73,7 +73,8 @@ class CustomBlockType extends ConfigEntityBase { */ public function uri() { return array( - 'path' => 'admin/structure/custom-blocks/manage/' . $block_type->id(), + 'path' => 'admin/structure/custom-blocks/manage/' . $this->id(), + 'options' => array() ); } } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php index 2cc8916..3b88c43 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php @@ -76,7 +76,7 @@ public function blockSubmit($form, &$form_state) { */ public function build() { list(, $uuid) = explode(':', $this->getPluginId()); - if ($block = entity_load_by_uuid($uuid)) { + if ($block = entity_load_by_uuid('custom_block', $uuid)) { return entity_view($block, $this->configuration['view_mode']); } else { diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTranslationUITest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTranslationUITest.php index 3a14bff..3ccac91 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTranslationUITest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTranslationUITest.php @@ -59,13 +59,12 @@ public function setUp() { * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::getTranslatorPermission(). */ public function getTranslatorPermissions() { - return array( + return array_merge(parent::getTranslatorPermissions(), array( 'translate any entity', - 'edit original values', 'access administration pages', 'administer blocks', 'administer custom_block fields' - ); + )); } /** @@ -94,32 +93,6 @@ protected function createCustomBlock($title = FALSE, $bundle = FALSE) { } /** - * Tests field translation form. - */ - public function testFieldTranslationForm() { - $admin_user = $this->drupalCreateUser(array( - 'translate any entity', - 'access administration pages', - 'administer blocks', - 'administer custom_block fields' - )); - $this->drupalLogin($admin_user); - - $block = $this->createCustomBlock($this->name); - - // Visit translation page. - $this->drupalGet('block/' . $block->id() . '/translations'); - $this->assertRaw('Not translated'); - - // Delete the only translatable field. - field_delete_field('field_test_et_ui_test'); - - // Visit translation page. - $this->drupalGet('block/' . $block->id() . '/translations'); - $this->assertRaw('no translatable fields'); - } - - /** * Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::getNewEntityValues(). */ protected function getNewEntityValues($langcode) { diff --git a/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php b/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php index 2b00c56..740b349 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php +++ b/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php @@ -95,7 +95,7 @@ public function form($form, &$form_state, $facet = NULL) { } } // Sort rows alphabetically. - sort($rows); + asort($rows); $form['left']['plugin_library'] = array( '#theme' => 'table', '#header' => $this->tableHeader(), diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php index 4c7d5b8..33de0fd 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php @@ -96,7 +96,6 @@ public function testCustomBlock() { $langcode = LANGUAGE_NOT_SPECIFIED; $values = array( 'info' => $info, - 'machine_name' => $info, "block_body[$langcode][0][value]" => $this->randomName(8) ); $this->drupalPost('block/add/basic', $values, t('Save')); @@ -154,11 +153,13 @@ public function testCustomBlockFormat() { $langcode = LANGUAGE_NOT_SPECIFIED; $values = array( 'info' => $info, - 'machine_name' => $info, "block_body[$langcode][0][value]" => '

Full HTML

', "block_body[$langcode][0][format]" => 'full_html' ); $this->drupalPost('block/add/basic', $values, t('Save')); + // Load the block up from the database. + $blocks = entity_load_multiple('custom_block'); + $loaded_block = end($blocks); $custom_block['machine_name'] = $info; $custom_block['label'] = $this->randomName(8); $custom_block['region'] = $this->regions[0]; @@ -177,7 +178,7 @@ public function testCustomBlockFormat() { // field, but can still submit the form without errors. $block_admin = $this->drupalCreateUser(array('administer blocks')); $this->drupalLogin($block_admin); - $this->drupalGet("block/$info/edit"); + $this->drupalGet("block/" . $loaded_block->id() . "/edit"); $this->assertFieldByXPath("//textarea[@name='block_body[und][0][value]' and @disabled='disabled']", t('This field has been disabled because you do not have sufficient permissions to edit it.'), 'Body field contains denied message'); $this->assertNoText(t('Ensure that each block description is unique.')); diff --git a/core/themes/seven/template.php b/core/themes/seven/template.php index ae9120d..a2c85ee 100644 --- a/core/themes/seven/template.php +++ b/core/themes/seven/template.php @@ -63,6 +63,27 @@ function seven_node_add_list($variables) { } /** + * Displays the list of available custom block types for creation. + */ +function seven_custom_block_add_list($variables) { + $content = $variables['content']; + $output = ''; + if ($content) { + $output = ''; + } + return $output; +} + +/** * Overrides theme_admin_block_content(). * * Uses an unordered list markup in both compact and extended mode.