From 95725e29e981707db065ea3957edb1ea4e8e95fb Mon Sep 17 00:00:00 2001 From: webchick <drupal@webchick.net> Date: Mon, 9 Jun 2014 13:19:08 -0700 Subject: [PATCH] Issue #1920862 by martin107, Mixologic, cilefen, larowlan, xan.ps, tim.plunkett | sun: Rename custom_block.module to block_content.module. --- core/modules/block/block.module | 2 +- .../entity.view_mode.custom_block.full.yml | 8 -- .../custom_block.contextual_links.yml | 10 -- .../custom_block.local_actions.yml | 14 -- .../custom_block/custom_block.local_tasks.yml | 27 ---- .../custom_block/custom_block.routing.yml | 80 ----------- .../custom_block/src/CustomBlockStorage.php | 34 ----- .../src/CustomBlockTypeInterface.php | 17 --- .../src/Entity/CustomBlockType.php | 86 ------------ .../src/Plugin/Derivative/CustomBlock.php | 28 ---- .../custom_block_test.module | 68 ---------- .../custom_block_test.routing.yml | 6 - .../src/Menu/CustomBlockLocalTasksTest.php | 64 --------- .../block/src/Tests/BlockConfigSchemaTest.php | 2 +- .../block_content.contextual_links.yml | 10 ++ .../block_content.info.yml} | 2 +- .../block_content/block_content.install | 125 ++++++++++++++++++ .../block_content.libraries.yml} | 4 +- .../block_content.local_actions.yml | 14 ++ .../block_content.local_tasks.yml | 27 ++++ .../block_content.module} | 42 +++--- .../block_content.pages.inc} | 12 +- .../block_content/block_content.routing.yml | 80 +++++++++++ .../install/block_content.type.basic.yml} | 0 .../entity.view_mode.block_content.full.yml | 8 ++ .../config/schema/block_content.schema.yml} | 2 +- .../js/block_content.js} | 8 +- .../src/BlockContentAccessController.php} | 6 +- .../src/BlockContentForm.php} | 36 ++--- .../src/BlockContentInterface.php} | 12 +- .../src/BlockContentListBuilder.php} | 10 +- .../block_content/src/BlockContentStorage.php | 34 +++++ .../src/BlockContentTranslationHandler.php} | 10 +- .../src/BlockContentTypeForm.php} | 18 +-- .../src/BlockContentTypeInterface.php | 17 +++ .../src/BlockContentTypeListBuilder.php} | 8 +- .../src/BlockContentViewBuilder.php} | 10 +- .../Controller/BlockContentController.php} | 46 +++---- .../src/Entity/BlockContent.php} | 48 +++---- .../src/Entity/BlockContentType.php | 101 ++++++++++++++ .../src/Form/BlockContentDeleteForm.php} | 10 +- .../src/Form/BlockContentTypeDeleteForm.php} | 12 +- .../src/Plugin/Block/BlockContentBlock.php} | 20 +-- .../src/Plugin/Derivative/BlockContent.php | 28 ++++ .../BlockContentAddLocalAction.php} | 14 +- .../src/Tests/BlockContentCacheTagsTest.php} | 14 +- .../src/Tests/BlockContentCreationTest.php} | 38 +++--- .../src/Tests/BlockContentFieldTest.php} | 22 +-- .../src/Tests/BlockContentListTest.php} | 14 +- .../src/Tests/BlockContentPageViewTest.php} | 12 +- .../src/Tests/BlockContentRevisionsTest.php} | 12 +- .../src/Tests/BlockContentSaveTest.php} | 36 ++--- .../src/Tests/BlockContentTestBase.php} | 24 ++-- .../Tests/BlockContentTranslationUITest.php} | 32 ++--- .../src/Tests/BlockContentTypeTest.php} | 57 ++++---- .../src/Tests/PageEditTest.php | 12 +- .../block-content-add-list.html.twig} | 2 +- .../block_content_test.info.yml} | 0 .../block_content_test.module | 68 ++++++++++ .../block_content_test.routing.yml | 6 + .../src/Menu/BlockContentLocalTasksTest.php | 94 +++++++++++++ .../src/Tests/ConfigTranslationListUiTest.php | 20 +-- .../migrate.migration.d6_custom_block.yml | 2 +- .../migrate/process/d6/BlockPluginId.php | 10 +- ...ckTest.php => MigrateBlockContentTest.php} | 14 +- .../src/Tests/d6/MigrateBlockTest.php | 6 +- .../src/Tests/d6/MigrateDrupal6Test.php | 4 +- core/modules/quickedit/js/quickedit.js | 2 +- core/profiles/standard/standard.info.yml | 2 +- core/themes/seven/seven.theme | 6 +- 70 files changed, 950 insertions(+), 779 deletions(-) delete mode 100644 core/modules/block/custom_block/config/install/entity.view_mode.custom_block.full.yml delete mode 100644 core/modules/block/custom_block/custom_block.contextual_links.yml delete mode 100644 core/modules/block/custom_block/custom_block.local_actions.yml delete mode 100644 core/modules/block/custom_block/custom_block.local_tasks.yml delete mode 100644 core/modules/block/custom_block/custom_block.routing.yml delete mode 100644 core/modules/block/custom_block/src/CustomBlockStorage.php delete mode 100644 core/modules/block/custom_block/src/CustomBlockTypeInterface.php delete mode 100644 core/modules/block/custom_block/src/Entity/CustomBlockType.php delete mode 100644 core/modules/block/custom_block/src/Plugin/Derivative/CustomBlock.php delete mode 100644 core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module delete mode 100644 core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.routing.yml delete mode 100644 core/modules/block/custom_block/tests/src/Menu/CustomBlockLocalTasksTest.php create mode 100644 core/modules/block_content/block_content.contextual_links.yml rename core/modules/{block/custom_block/custom_block.info.yml => block_content/block_content.info.yml} (86%) create mode 100644 core/modules/block_content/block_content.install rename core/modules/{block/custom_block/custom_block.libraries.yml => block_content/block_content.libraries.yml} (66%) create mode 100644 core/modules/block_content/block_content.local_actions.yml create mode 100644 core/modules/block_content/block_content.local_tasks.yml rename core/modules/{block/custom_block/custom_block.module => block_content/block_content.module} (72%) rename core/modules/{block/custom_block/custom_block.pages.inc => block_content/block_content.pages.inc} (64%) create mode 100644 core/modules/block_content/block_content.routing.yml rename core/modules/{block/custom_block/config/install/custom_block.type.basic.yml => block_content/config/install/block_content.type.basic.yml} (100%) create mode 100644 core/modules/block_content/config/install/entity.view_mode.block_content.full.yml rename core/modules/{block/custom_block/config/schema/custom_block.schema.yml => block_content/config/schema/block_content.schema.yml} (92%) rename core/modules/{block/custom_block/js/custom_block.js => block_content/js/block_content.js} (81%) rename core/modules/{block/custom_block/src/CustomBlockAccessController.php => block_content/src/BlockContentAccessController.php} (75%) rename core/modules/{block/custom_block/src/CustomBlockForm.php => block_content/src/BlockContentForm.php} (86%) rename core/modules/{block/custom_block/src/CustomBlockInterface.php => block_content/src/BlockContentInterface.php} (83%) rename core/modules/{block/custom_block/src/CustomBlockListBuilder.php => block_content/src/BlockContentListBuilder.php} (78%) create mode 100644 core/modules/block_content/src/BlockContentStorage.php rename core/modules/{block/custom_block/src/CustomBlockTranslationHandler.php => block_content/src/BlockContentTranslationHandler.php} (73%) rename core/modules/{block/custom_block/src/CustomBlockTypeForm.php => block_content/src/BlockContentTypeForm.php} (80%) create mode 100644 core/modules/block_content/src/BlockContentTypeInterface.php rename core/modules/{block/custom_block/src/CustomBlockTypeListBuilder.php => block_content/src/BlockContentTypeListBuilder.php} (85%) rename core/modules/{block/custom_block/src/CustomBlockViewBuilder.php => block_content/src/BlockContentViewBuilder.php} (70%) rename core/modules/{block/custom_block/src/Controller/CustomBlockController.php => block_content/src/Controller/BlockContentController.php} (61%) rename core/modules/{block/custom_block/src/Entity/CustomBlock.php => block_content/src/Entity/BlockContent.php} (78%) create mode 100644 core/modules/block_content/src/Entity/BlockContentType.php rename core/modules/{block/custom_block/src/Form/CustomBlockDeleteForm.php => block_content/src/Form/BlockContentDeleteForm.php} (77%) rename core/modules/{block/custom_block/src/Form/CustomBlockTypeDeleteForm.php => block_content/src/Form/BlockContentTypeDeleteForm.php} (82%) rename core/modules/{block/custom_block/src/Plugin/Block/CustomBlockBlock.php => block_content/src/Plugin/Block/BlockContentBlock.php} (88%) create mode 100644 core/modules/block_content/src/Plugin/Derivative/BlockContent.php rename core/modules/{block/custom_block/src/Plugin/Menu/LocalAction/CustomBlockAddLocalAction.php => block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php} (76%) rename core/modules/{block/custom_block/src/Tests/CustomBlockCacheTagsTest.php => block_content/src/Tests/BlockContentCacheTagsTest.php} (73%) rename core/modules/{block/custom_block/src/Tests/CustomBlockCreationTest.php => block_content/src/Tests/BlockContentCreationTest.php} (82%) rename core/modules/{block/custom_block/src/Tests/CustomBlockFieldTest.php => block_content/src/Tests/BlockContentFieldTest.php} (77%) rename core/modules/{block/custom_block/src/Tests/CustomBlockListTest.php => block_content/src/Tests/BlockContentListTest.php} (91%) rename core/modules/{block/custom_block/src/Tests/CustomBlockPageViewTest.php => block_content/src/Tests/BlockContentPageViewTest.php} (67%) rename core/modules/{block/custom_block/src/Tests/CustomBlockRevisionsTest.php => block_content/src/Tests/BlockContentRevisionsTest.php} (87%) rename core/modules/{block/custom_block/src/Tests/CustomBlockSaveTest.php => block_content/src/Tests/BlockContentSaveTest.php} (68%) rename core/modules/{block/custom_block/src/Tests/CustomBlockTestBase.php => block_content/src/Tests/BlockContentTestBase.php} (67%) rename core/modules/{block/custom_block/src/Tests/CustomBlockTranslationUITest.php => block_content/src/Tests/BlockContentTranslationUITest.php} (77%) rename core/modules/{block/custom_block/src/Tests/CustomBlockTypeTest.php => block_content/src/Tests/BlockContentTypeTest.php} (79%) rename core/modules/{block/custom_block => block_content}/src/Tests/PageEditTest.php (84%) rename core/modules/{block/custom_block/templates/custom-block-add-list.html.twig => block_content/templates/block-content-add-list.html.twig} (91%) rename core/modules/{block/custom_block/tests/modules/custom_block_test/custom_block_test.info.yml => block_content/tests/modules/block_content_test/block_content_test.info.yml} (100%) create mode 100644 core/modules/block_content/tests/modules/block_content_test/block_content_test.module create mode 100644 core/modules/block_content/tests/modules/block_content_test/block_content_test.routing.yml create mode 100644 core/modules/block_content/tests/src/Menu/BlockContentLocalTasksTest.php rename core/modules/migrate_drupal/src/Tests/d6/{MigrateCustomBlockTest.php => MigrateBlockContentTest.php} (84%) diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 37b93bd6d8b2..ceffa1ff5d05 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -49,7 +49,7 @@ function block_help($route_name, Request $request) { $output .= '<dt>' . t('Controlling visibility') . '</dt>'; $output .= '<dd>' . t('You can control the visibility of a block by restricting it to specific pages, content types, and/or roles by setting the appropriate options under <em>Visibility settings</em> of the block configuration.') . '</dd>'; $output .= '<dt>' . t('Adding custom blocks') . '</dt>'; - $output .= '<dd>' . t('You can add custom blocks, if the the <em>Custom Block</em> module is enabled on the <a href="!extend">Extend page</a>. For more information, see the <a href="!customblock-help">Custom Block help page</a>.', array('!extend' => \Drupal::url('system.modules_list'), '!customblock-help' => \Drupal::url('help.page', array('name' => 'custom_block')))) . '</dd>'; + $output .= '<dd>' . t('You can add custom blocks, if the the <em>Custom Block</em> module is enabled on the <a href="!extend">Extend page</a>. For more information, see the <a href="!blockcontent-help">Custom Block help page</a>.', array('!extend' => \Drupal::url('system.modules_list'), '!blockcontent-help' => \Drupal::url('help.page', array('name' => 'block_content')))) . '</dd>'; $output .= '</dl>'; return $output; } diff --git a/core/modules/block/custom_block/config/install/entity.view_mode.custom_block.full.yml b/core/modules/block/custom_block/config/install/entity.view_mode.custom_block.full.yml deleted file mode 100644 index 298762915c06..000000000000 --- a/core/modules/block/custom_block/config/install/entity.view_mode.custom_block.full.yml +++ /dev/null @@ -1,8 +0,0 @@ -id: custom_block.full -label: Full -status: false -cache: true -targetEntityType: custom_block -dependencies: - module: - - custom_block diff --git a/core/modules/block/custom_block/custom_block.contextual_links.yml b/core/modules/block/custom_block/custom_block.contextual_links.yml deleted file mode 100644 index acd117fb62fc..000000000000 --- a/core/modules/block/custom_block/custom_block.contextual_links.yml +++ /dev/null @@ -1,10 +0,0 @@ -custom_block.block_edit: - title: 'Edit' - group: custom_block - route_name: 'custom_block.edit' - -custom_block.block_delete: - title: 'Delete' - group: custom_block - route_name: 'custom_block.delete' - weight: 1 diff --git a/core/modules/block/custom_block/custom_block.local_actions.yml b/core/modules/block/custom_block/custom_block.local_actions.yml deleted file mode 100644 index e3b57c6b40fd..000000000000 --- a/core/modules/block/custom_block/custom_block.local_actions.yml +++ /dev/null @@ -1,14 +0,0 @@ -custom_block_type_add: - route_name: custom_block.type_add - title: 'Add custom block type' - appears_on: - - custom_block.type_list - -custom_block_add_action: - route_name: custom_block.add_page - title: 'Add custom block' - appears_on: - - block.admin_display - - block.admin_display_theme - - custom_block.list - class: \Drupal\custom_block\Plugin\Menu\LocalAction\CustomBlockAddLocalAction diff --git a/core/modules/block/custom_block/custom_block.local_tasks.yml b/core/modules/block/custom_block/custom_block.local_tasks.yml deleted file mode 100644 index 041abb76a44a..000000000000 --- a/core/modules/block/custom_block/custom_block.local_tasks.yml +++ /dev/null @@ -1,27 +0,0 @@ -custom_block.list: - title: 'Custom block library' - route_name: custom_block.list - base_route: block.admin_display -custom_block.list_sub: - title: Blocks - route_name: custom_block.list - parent_id: custom_block.list -custom_block.type_list: - title: Types - route_name: custom_block.type_list - parent_id: custom_block.list - -custom_block.edit: - title: Edit - route_name: custom_block.edit - base_route: custom_block.edit -custom_block.delete: - title: Delete - route_name: custom_block.delete - base_route: custom_block.edit - -# Default tab for custom block type editing. -custom_block.type_edit: - title: 'Edit' - route_name: custom_block.type_edit - base_route: custom_block.type_edit diff --git a/core/modules/block/custom_block/custom_block.routing.yml b/core/modules/block/custom_block/custom_block.routing.yml deleted file mode 100644 index cad1f094b153..000000000000 --- a/core/modules/block/custom_block/custom_block.routing.yml +++ /dev/null @@ -1,80 +0,0 @@ -custom_block.type_list: - path: '/admin/structure/block/custom-blocks/types' - defaults: - _entity_list: 'custom_block_type' - _title: 'Edit' - requirements: - _permission: 'administer blocks' - -custom_block.add_page: - path: '/block/add' - defaults: - _content: '\Drupal\custom_block\Controller\CustomBlockController::add' - _title: 'Add custom block' - options: - _admin_route: TRUE - requirements: - _permission: 'administer blocks' - -custom_block.add_form: - path: '/block/add/{custom_block_type}' - defaults: - _content: '\Drupal\custom_block\Controller\CustomBlockController::addForm' - _title_callback: 'Drupal\custom_block\Controller\CustomBlockController::getAddFormTitle' - options: - _admin_route: TRUE - requirements: - _permission: 'administer blocks' - -custom_block.type_delete: - path: '/admin/structure/block/custom-blocks/manage/{custom_block_type}/delete' - defaults: - _entity_form: 'custom_block_type.delete' - _title: 'Delete' - requirements: - _entity_access: 'custom_block_type.delete' - options: - _admin_route: TRUE - -custom_block.edit: - path: '/block/{custom_block}' - defaults: - _entity_form: 'custom_block.edit' - options: - _admin_route: TRUE - requirements: - _entity_access: 'custom_block.update' - -custom_block.delete: - path: '/block/{custom_block}/delete' - defaults: - _entity_form: 'custom_block.delete' - _title: 'Delete' - options: - _admin_route: TRUE - requirements: - _entity_access: 'custom_block.delete' - -custom_block.type_add: - path: '/admin/structure/block/custom-blocks/types/add' - defaults: - _entity_form: 'custom_block_type.add' - _title: 'Add' - requirements: - _permission: 'administer blocks' - -custom_block.type_edit: - path: '/admin/structure/block/custom-blocks/manage/{custom_block_type}' - defaults: - _entity_form: 'custom_block_type.edit' - _title: 'Edit' - requirements: - _entity_access: 'custom_block_type.update' - -custom_block.list: - path: '/admin/structure/block/custom-blocks' - defaults: - _title: 'Custom block library' - _entity_list: 'custom_block' - requirements: - _permission: 'administer blocks' diff --git a/core/modules/block/custom_block/src/CustomBlockStorage.php b/core/modules/block/custom_block/src/CustomBlockStorage.php deleted file mode 100644 index b7b8711bdc99..000000000000 --- a/core/modules/block/custom_block/src/CustomBlockStorage.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php - -/** - * @file - * Contains \Drupal\custom_block\CustomBlockStorage. - */ - -namespace Drupal\custom_block; - -use Drupal\Core\Entity\ContentEntityDatabaseStorage; - -/** - * Provides storage for the 'custom_block' entity type. - */ -class CustomBlockStorage extends ContentEntityDatabaseStorage { - - /** - * {@inheritdoc} - */ - public function getSchema() { - $schema = parent::getSchema(); - - // Marking the respective fields as NOT NULL makes the indexes more - // performant. - $schema['custom_block']['fields']['info']['not null'] = TRUE; - - $schema['custom_block']['unique keys'] += array( - 'custom_block__info' => array('info'), - ); - - return $schema; - } - -} diff --git a/core/modules/block/custom_block/src/CustomBlockTypeInterface.php b/core/modules/block/custom_block/src/CustomBlockTypeInterface.php deleted file mode 100644 index 53bfe1b84634..000000000000 --- a/core/modules/block/custom_block/src/CustomBlockTypeInterface.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -/** - * @file - * Contains \Drupal\custom_block\Entity\CustomBlockTypeInterface. - */ - -namespace Drupal\custom_block; - -use Drupal\Core\Config\Entity\ConfigEntityInterface; - -/** - * Provides an interface defining a custom block type entity. - */ -interface CustomBlockTypeInterface extends ConfigEntityInterface { - -} diff --git a/core/modules/block/custom_block/src/Entity/CustomBlockType.php b/core/modules/block/custom_block/src/Entity/CustomBlockType.php deleted file mode 100644 index 65dd97491571..000000000000 --- a/core/modules/block/custom_block/src/Entity/CustomBlockType.php +++ /dev/null @@ -1,86 +0,0 @@ -<?php - -/** - * @file - * Contains \Drupal\custom_block\Entity\CustomBlockType. - */ - -namespace Drupal\custom_block\Entity; - -use Drupal\Core\Config\Entity\ConfigEntityBase; -use Drupal\Core\Config\Entity\ConfigEntityBundleBase; -use Drupal\Core\Entity\EntityStorageInterface; -use Drupal\custom_block\CustomBlockTypeInterface; - -/** - * Defines the custom block type entity. - * - * @ConfigEntityType( - * id = "custom_block_type", - * label = @Translation("Custom block type"), - * controllers = { - * "form" = { - * "default" = "Drupal\custom_block\CustomBlockTypeForm", - * "add" = "Drupal\custom_block\CustomBlockTypeForm", - * "edit" = "Drupal\custom_block\CustomBlockTypeForm", - * "delete" = "Drupal\custom_block\Form\CustomBlockTypeDeleteForm" - * }, - * "list_builder" = "Drupal\custom_block\CustomBlockTypeListBuilder" - * }, - * admin_permission = "administer blocks", - * config_prefix = "type", - * bundle_of = "custom_block", - * entity_keys = { - * "id" = "id", - * "label" = "label" - * }, - * links = { - * "delete-form" = "custom_block.type_delete", - * "edit-form" = "custom_block.type_edit" - * } - * ) - */ -class CustomBlockType extends ConfigEntityBundleBase implements CustomBlockTypeInterface { - - /** - * The custom block type ID. - * - * @var string - */ - public $id; - - /** - * The custom block type label. - * - * @var string - */ - public $label; - - /** - * The default revision setting for custom blocks of this type. - * - * @var bool - */ - public $revision; - - /** - * The description of the block type. - * - * @var string - */ - public $description; - - /** - * {@inheritdoc} - */ - public function postSave(EntityStorageInterface $storage, $update = TRUE) { - parent::postSave($storage, $update); - - if (!$update && !$this->isSyncing()) { - if (!$this->isSyncing()) { - custom_block_add_body_field($this->id); - } - } - } - -} diff --git a/core/modules/block/custom_block/src/Plugin/Derivative/CustomBlock.php b/core/modules/block/custom_block/src/Plugin/Derivative/CustomBlock.php deleted file mode 100644 index f93b41312c97..000000000000 --- a/core/modules/block/custom_block/src/Plugin/Derivative/CustomBlock.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php - -/** - * @file - * Contains \Drupal\custom_block\Plugin\Derivative\CustomBlock. - */ - -namespace Drupal\custom_block\Plugin\Derivative; - -use Drupal\Component\Plugin\Derivative\DerivativeBase; -use Drupal\Core\Plugin\Discovery\ContainerDerivativeInterface; - -/** - * Retrieves block plugin definitions for all custom blocks. - */ -class CustomBlock extends DerivativeBase { - /** - * {@inheritdoc} - */ - public function getDerivativeDefinitions($base_plugin_definition) { - $custom_blocks = entity_load_multiple('custom_block'); - foreach ($custom_blocks as $custom_block) { - $this->derivatives[$custom_block->uuid()] = $base_plugin_definition; - $this->derivatives[$custom_block->uuid()]['admin_label'] = $custom_block->label(); - } - return parent::getDerivativeDefinitions($base_plugin_definition); - } -} diff --git a/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module b/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module deleted file mode 100644 index 65e9c5679070..000000000000 --- a/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module +++ /dev/null @@ -1,68 +0,0 @@ -<?php - -/** - * @file - * A dummy module for testing custom block related hooks. - * - * This is a dummy module that implements custom block related hooks to test API - * interaction with the custom_block module. - */ - -use Drupal\custom_block\Entity\CustomBlock; - -/** - * Implements hook_custom_block_view(). - */ -function custom_block_test_custom_block_view(array &$build, CustomBlock $custom_block, $view_mode) { - // Add extra content. - $build['extra_content'] = array( - '#markup' => '<blink>Yowser</blink>', - ); -} - -/** - * Implements hook_custom_block_presave(). - */ -function custom_block_test_custom_block_presave(CustomBlock $custom_block) { - if ($custom_block->label() == 'testing_custom_block_presave') { - $custom_block->setInfo($custom_block->label() .'_presave'); - } - // Determine changes. - if (!empty($custom_block->original) && $custom_block->original->label() == 'test_changes') { - if ($custom_block->original->label() != $custom_block->label()) { - $custom_block->setInfo($custom_block->label() .'_presave'); - // Drupal 1.0 release. - $custom_block->changed = 979534800; - } - } -} - -/** - * Implements hook_custom_block_update(). - */ -function custom_block_test_custom_block_update(CustomBlock $custom_block) { - // Determine changes on update. - if (!empty($custom_block->original) && $custom_block->original->label() == 'test_changes') { - if ($custom_block->original->label() != $custom_block->label()) { - $custom_block->setInfo($custom_block->label() .'_update'); - } - } -} - -/** - * Implements hook_custom_block_insert(). - * - * This tests saving a custom_block on custom_block insert. - * - * @see \Drupal\custom_block\Tests\CustomBlockSaveTest::testCustomBlockSaveOnInsert() - */ -function custom_block_test_custom_block_insert(CustomBlock $custom_block) { - // Set the custom_block title to the custom_block ID and save. - if ($custom_block->label() == 'new') { - $custom_block->setInfo('CustomBlock ' . $custom_block->id()); - $custom_block->save(); - } - if ($custom_block->label() == 'fail_creation') { - throw new Exception('Test exception for rollback.'); - } -} diff --git a/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.routing.yml b/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.routing.yml deleted file mode 100644 index a7ca068eb101..000000000000 --- a/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.routing.yml +++ /dev/null @@ -1,6 +0,0 @@ -custom_block_test.custom_block_view: - path: '/custom-block/{custom_block}' - defaults: - _entity_view: 'custom_block' - requirements: - _entity_access: 'custom_block.view' diff --git a/core/modules/block/custom_block/tests/src/Menu/CustomBlockLocalTasksTest.php b/core/modules/block/custom_block/tests/src/Menu/CustomBlockLocalTasksTest.php deleted file mode 100644 index d04ad152e25c..000000000000 --- a/core/modules/block/custom_block/tests/src/Menu/CustomBlockLocalTasksTest.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php - -/** - * @file - * Contains \Drupal\custom_block\Tests\Menu\CustomBlockLocalTasksTest. - */ - -namespace Drupal\custom_block\Tests\Menu; - -use Drupal\Tests\Core\Menu\LocalTaskIntegrationTest; - -/** - * Tests existence of custom_block local tasks. - * - * @group Drupal - * @group Block - */ -class CustomBlockLocalTasksTest extends LocalTaskIntegrationTest { - - public static function getInfo() { - return array( - 'name' => 'Custom Block local tasks test', - 'description' => 'Test custom_block local tasks.', - 'group' => 'Block', - ); - } - - public function setUp() { - $this->directoryList = array( - 'block' => 'core/modules/block', - 'custom_block' => 'core/modules/block/custom_block', - ); - parent::setUp(); - } - - /** - * Checks custom_block listing local tasks. - * - * @dataProvider getCustomBlockListingRoutes - */ - public function testCustomBlockListLocalTasks($route) { - // - $this->assertLocalTasks($route, array( - 0 => array( - 'block.admin_display', - 'custom_block.list', - ), - 1 => array( - 'custom_block.list_sub', - 'custom_block.type_list', - ) - )); - } - - /** - * Provides a list of routes to test. - */ - public function getCustomBlockListingRoutes() { - return array( - array('custom_block.list', 'custom_block.type_list'), - ); - } - -} diff --git a/core/modules/block/src/Tests/BlockConfigSchemaTest.php b/core/modules/block/src/Tests/BlockConfigSchemaTest.php index 54d20de4fc0d..05f080e2e40a 100644 --- a/core/modules/block/src/Tests/BlockConfigSchemaTest.php +++ b/core/modules/block/src/Tests/BlockConfigSchemaTest.php @@ -18,7 +18,7 @@ class BlockConfigSchemaTest extends ConfigSchemaTestBase { /** * {@inheritdoc} */ - public static $modules = array('block', 'aggregator', 'book', 'custom_block', 'forum', 'statistics'); + public static $modules = array('block', 'aggregator', 'book', 'block_content', 'forum', 'statistics'); /** * The typed config manager. diff --git a/core/modules/block_content/block_content.contextual_links.yml b/core/modules/block_content/block_content.contextual_links.yml new file mode 100644 index 000000000000..4751e6ce76d0 --- /dev/null +++ b/core/modules/block_content/block_content.contextual_links.yml @@ -0,0 +1,10 @@ +block_content.block_edit: + title: 'Edit' + group: block_content + route_name: 'block_content.edit' + +block_content.block_delete: + title: 'Delete' + group: block_content + route_name: 'block_content.delete' + weight: 1 diff --git a/core/modules/block/custom_block/custom_block.info.yml b/core/modules/block_content/block_content.info.yml similarity index 86% rename from core/modules/block/custom_block/custom_block.info.yml rename to core/modules/block_content/block_content.info.yml index 692648fded23..e9e7afbf13fe 100644 --- a/core/modules/block/custom_block/custom_block.info.yml +++ b/core/modules/block_content/block_content.info.yml @@ -7,4 +7,4 @@ core: 8.x dependencies: - block - text -configure: custom_block.list +configure: block_content.list diff --git a/core/modules/block_content/block_content.install b/core/modules/block_content/block_content.install new file mode 100644 index 000000000000..49bce265538a --- /dev/null +++ b/core/modules/block_content/block_content.install @@ -0,0 +1,125 @@ +<?php + +/** + * @file + * Install, update and uninstall functions for the custom block module. + */ + +use Drupal\Core\Entity\EntityTypeInterface; + +/** + * Implements hook_schema(). + */ +function block_content_schema() { + $schema = array(); + $schema['block_content'] = array( + 'description' => 'Stores contents of custom-made blocks.', + 'fields' => array( + 'id' => array( + 'type' => 'serial', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'description' => "The block's {block_content}.id.", + ), + 'uuid' => array( + 'description' => 'Unique Key: Universally unique identifier for this entity.', + 'type' => 'varchar', + 'length' => 128, + 'not null' => FALSE, + ), + 'info' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => TRUE, + 'default' => '', + 'description' => 'Block description.', + ), + // Defaults to NULL in order to avoid a brief period of potential + // deadlocks on the index. + 'revision_id' => array( + 'description' => 'The current {block_content_revision}.revision_id version identifier.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => FALSE, + 'default' => NULL, + ), + 'type' => array( + 'description' => 'The type of this custom block.', + 'type' => 'varchar', + 'length' => EntityTypeInterface::BUNDLE_MAX_LENGTH, + 'not null' => TRUE, + 'default' => '', + ), + 'changed' => array( + 'description' => 'The Unix timestamp when the custom block was most recently saved.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'langcode' => array( + 'description' => 'The {language}.langcode of this node.', + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => '', + ), + ), + 'primary key' => array('id'), + 'indexes' => array( + 'block_content_type' => array('type'), + ), + 'unique keys' => array( + 'revision_id' => array('revision_id'), + 'uuid' => array('uuid'), + 'info' => array('info'), + ), + 'foreign keys' => array( + 'block_content_revision' => array( + 'table' => 'block_content_revision', + 'columns' => array('revision_id' => 'revision_id'), + ), + ), + ); + + $schema['block_content_revision'] = array( + 'description' => 'Stores contents of custom-made blocks.', + 'fields' => array( + 'id' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'description' => "The block's {block_content}.id.", + ), + // Defaults to NULL in order to avoid a brief period of potential + // deadlocks on the index. + 'revision_id' => array( + 'description' => 'The current version identifier.', + 'type' => 'serial', + 'unsigned' => TRUE, + 'not null' => TRUE, + ), + 'revision_log' => array( + 'description' => 'The log entry explaining the changes in this version.', + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + ), + 'info' => array( + 'type' => 'varchar', + 'length' => 128, + 'not null' => TRUE, + 'default' => '', + 'description' => 'Block description.', + ), + 'changed' => array( + 'description' => 'The Unix timestamp when the version was most recently saved.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'primary key' => array('revision_id'), + ); + return $schema; +} diff --git a/core/modules/block/custom_block/custom_block.libraries.yml b/core/modules/block_content/block_content.libraries.yml similarity index 66% rename from core/modules/block/custom_block/custom_block.libraries.yml rename to core/modules/block_content/block_content.libraries.yml index 34539a8d1dd4..5a1b5b6a799c 100644 --- a/core/modules/block/custom_block/custom_block.libraries.yml +++ b/core/modules/block_content/block_content.libraries.yml @@ -1,7 +1,7 @@ -drupal.custom_block: +drupal.block_content: version: VERSION js: - js/custom_block.js: {} + js/block_content.js: {} dependencies: - core/jquery - core/drupal diff --git a/core/modules/block_content/block_content.local_actions.yml b/core/modules/block_content/block_content.local_actions.yml new file mode 100644 index 000000000000..735e3747722a --- /dev/null +++ b/core/modules/block_content/block_content.local_actions.yml @@ -0,0 +1,14 @@ +block_content_type_add: + route_name: block_content.type_add + title: 'Add custom block type' + appears_on: + - block_content.type_list + +block_content_add_action: + route_name: block_content.add_page + title: 'Add custom block' + appears_on: + - block.admin_display + - block.admin_display_theme + - block_content.list + class: \Drupal\block_content\Plugin\Menu\LocalAction\BlockContentAddLocalAction diff --git a/core/modules/block_content/block_content.local_tasks.yml b/core/modules/block_content/block_content.local_tasks.yml new file mode 100644 index 000000000000..0674c99b6c69 --- /dev/null +++ b/core/modules/block_content/block_content.local_tasks.yml @@ -0,0 +1,27 @@ +block_content.list: + title: 'Custom block library' + route_name: block_content.list + base_route: block.admin_display +block_content.list_sub: + title: Blocks + route_name: block_content.list + parent_id: block_content.list +block_content.type_list: + title: Types + route_name: block_content.type_list + parent_id: block_content.list + +block_content.edit: + title: Edit + route_name: block_content.edit + base_route: block_content.edit +block_content.delete: + title: Delete + route_name: block_content.delete + base_route: block_content.edit + +# Default tab for custom block type editing. +block_content.type_edit: + title: 'Edit' + route_name: block_content.type_edit + base_route: block_content.type_edit diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block_content/block_content.module similarity index 72% rename from core/modules/block/custom_block/custom_block.module rename to core/modules/block_content/block_content.module index b833a01fca8c..96ff041e0037 100644 --- a/core/modules/block/custom_block/custom_block.module +++ b/core/modules/block_content/block_content.module @@ -12,26 +12,26 @@ /** * Implements hook_help(). */ -function custom_block_help($route_name, Request $request) { +function block_content_help($route_name, Request $request) { switch ($route_name) { - case 'help.page.custom_block': + case 'help.page.block_content': $output = ''; $output .= '<h3>' . t('About') . '</h3>'; - $output .= '<p>' . t('The Custom Block module allows you to create blocks of content, which can be placed in regions throughout the website. Custom blocks can have fields; see the <a href="!field-help">Field module help</a> for more information. Once created, custom blocks can be placed like blocks provided by other modules; see the <a href="!blocks">Block module help page</a> for details. For more information, see <a href="!online-help">the online documentation for the Custom Block module</a>.', array('!custom-blocks' => \Drupal::url('custom_block.list'), '!field-help' => \Drupal::url('help.page', array('name' => 'field')), '!blocks' => \Drupal::url('help.page', array('name' => 'block')), '!online-help' => 'https://drupal.org/documentation/modules/custom_block')) . '</p>'; + $output .= '<p>' . t('The Custom Block module allows you to create blocks of content, which can be placed in regions throughout the website. Custom blocks can have fields; see the <a href="!field-help">Field module help</a> for more information. Once created, custom blocks can be placed like blocks provided by other modules; see the <a href="!blocks">Block module help page</a> for details. For more information, see <a href="!online-help">the online documentation for the Custom Block module</a>.', array('!block-content' => \Drupal::url('block_content.list'), '!field-help' => \Drupal::url('help.page', array('name' => 'field')), '!blocks' => \Drupal::url('help.page', array('name' => 'block')), '!online-help' => 'https://drupal.org/documentation/modules/block_content')) . '</p>'; $output .= '<h3>' . t('Uses') . '</h3>'; $output .= '<dl>'; $output .= '<dt>' . t('Creating and managing custom block types') . '</dt>'; - $output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can create different custom block types, each with different fields and display settings, from the <a href="!types">Custom block types</a> page. The Custom block types page lists all of your created custom block types, and allows you to edit and manage them. For more information about managing fields and display settings, see the <a href="!field-ui">Field UI module help</a>.', array('!types' => \Drupal::url('custom_block.type_list'), '!field-ui' => \Drupal::url('help.page', array('name' => 'field_ui')))) . '</dd>'; + $output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can create different custom block types, each with different fields and display settings, from the <a href="!types">Custom block types</a> page. The Custom block types page lists all of your created custom block types, and allows you to edit and manage them. For more information about managing fields and display settings, see the <a href="!field-ui">Field UI module help</a>.', array('!types' => \Drupal::url('block_content.type_list'), '!field-ui' => \Drupal::url('help.page', array('name' => 'field_ui')))) . '</dd>'; $output .= '<dt>' . t('Creating custom blocks') . '</dt>'; - $output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can <a href="!block-add">add custom blocks</a> of each of their defined custom block types. Created custom blocks are then listed on the <a href="!blocks">Blocks administration page</a>.', array('!blocks' => \Drupal::url('block.admin_display'), '!block-add' => \Drupal::url('custom_block.add_page'))) . '</dd>'; + $output .= '<dd>' . t('Users with the <em>Administer blocks</em> permission can <a href="!block-add">add custom blocks</a> of each of their defined custom block types. Created custom blocks are then listed on the <a href="!blocks">Blocks administration page</a>.', array('!blocks' => \Drupal::url('block.admin_display'), '!block-add' => \Drupal::url('block_content.add_page'))) . '</dd>'; $output .= '</dl>'; return $output; - case 'custom_block.list': + case 'block_content.list': $output = '<p>' . t('This page lists user-created blocks. These blocks are derived from block types. A block type can consist of different fields and display settings. From the block types tab you can manage these fields as well as create new block types.') . '</p>'; return $output; - case 'custom_block.type_list': + case 'block_content.type_list': $output = '<p>' . t('This page lists block types. A block type can consist of different fields and display settings. From here you can manage these fields as well as create new block types.') . '</p>'; return $output; @@ -41,12 +41,12 @@ function custom_block_help($route_name, Request $request) { /** * Implements hook_theme(). */ -function custom_block_theme($existing, $type, $theme, $path) { +function block_content_theme($existing, $type, $theme, $path) { return array( - 'custom_block_add_list' => array( + 'block_content_add_list' => array( 'variables' => array('content' => NULL), - 'file' => 'custom_block.pages.inc', - 'template' => 'custom-block-add-list', + 'file' => 'block_content.pages.inc', + 'template' => 'block-content-add-list', ), ); } @@ -54,13 +54,13 @@ function custom_block_theme($existing, $type, $theme, $path) { /** * Implements hook_entity_type_alter(). */ -function custom_block_entity_type_alter(array &$entity_types) { +function block_content_entity_type_alter(array &$entity_types) { /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ // Add a translation handler for fields if the language module is enabled. if (\Drupal::moduleHandler()->moduleExists('language')) { - $translation = $entity_types['custom_block']->get('translation'); - $translation['custom_block'] = TRUE; - $entity_types['custom_block']->set('translation', $translation); + $translation = $entity_types['block_content']->get('translation'); + $translation['block_content'] = TRUE; + $entity_types['block_content']->set('translation', $translation); } } @@ -75,14 +75,14 @@ function custom_block_entity_type_alter(array &$entity_types) { * @return array() * Body field instance. */ -function custom_block_add_body_field($block_type_id, $label = 'Body') { +function block_content_add_body_field($block_type_id, $label = 'Body') { // Add or remove the body field, as needed. - $field = FieldConfig::loadByName('custom_block', 'body'); - $instance = FieldInstanceConfig::loadByName('custom_block', $block_type_id, 'body'); + $field = FieldConfig::loadByName('block_content', 'body'); + $instance = FieldInstanceConfig::loadByName('block_content', $block_type_id, 'body'); if (empty($field)) { $field = entity_create('field_config', array( 'name' => 'body', - 'entity_type' => 'custom_block', + 'entity_type' => 'block_content', 'type' => 'text_with_summary', )); $field->save(); @@ -97,14 +97,14 @@ function custom_block_add_body_field($block_type_id, $label = 'Body') { $instance->save(); // Assign widget settings for the 'default' form mode. - entity_get_form_display('custom_block', $block_type_id, 'default') + entity_get_form_display('block_content', $block_type_id, 'default') ->setComponent('body', array( 'type' => 'text_textarea_with_summary', )) ->save(); // Assign display settings for 'default' view mode. - entity_get_display('custom_block', $block_type_id, 'default') + entity_get_display('block_content', $block_type_id, 'default') ->setComponent('body', array( 'label' => 'hidden', 'type' => 'text_default', diff --git a/core/modules/block/custom_block/custom_block.pages.inc b/core/modules/block_content/block_content.pages.inc similarity index 64% rename from core/modules/block/custom_block/custom_block.pages.inc rename to core/modules/block_content/block_content.pages.inc index f24e16b05790..d2dc0c43c25a 100644 --- a/core/modules/block/custom_block/custom_block.pages.inc +++ b/core/modules/block_content/block_content.pages.inc @@ -6,27 +6,27 @@ */ use Drupal\Component\Utility\Xss; -use Drupal\custom_block\Entity\CustomBlockType; -use Drupal\custom_block\Entity\CustomBlock; +use Drupal\block_content\Entity\BlockContentType; +use Drupal\block_content\Entity\BlockContent; use Symfony\Component\HttpFoundation\RedirectResponse; /** * Prepares variables for a custom block type creation list templates. * - * Default template: custom-block-add-list.html.twig. + * Default template: block-content-add-list.html.twig. * * @param array $variables * An associative array containing: * - content: An array of block types. * - * @see custom_block_add_page() + * @see block_content_add_page() */ -function template_preprocess_custom_block_add_list(&$variables) { +function template_preprocess_block_content_add_list(&$variables) { $variables['types'] = array(); $query = \Drupal::request()->query->all(); foreach ($variables['content'] as $type) { $variables['types'][$type->id()] = array( - 'link' => \Drupal::l($type->label(), 'custom_block.add_form', array('custom_block_type' => $type->id()), array('query' => $query)), + 'link' => \Drupal::l($type->label(), 'block_content.add_form', array('block_content_type' => $type->id()), array('query' => $query)), 'description' => Xss::filterAdmin($type->description), 'title' => $type->label(), 'localized_options' => array( diff --git a/core/modules/block_content/block_content.routing.yml b/core/modules/block_content/block_content.routing.yml new file mode 100644 index 000000000000..b6a1aaf13aba --- /dev/null +++ b/core/modules/block_content/block_content.routing.yml @@ -0,0 +1,80 @@ +block_content.type_list: + path: '/admin/structure/block/block-content/types' + defaults: + _entity_list: 'block_content_type' + _title: 'Edit' + requirements: + _permission: 'administer blocks' + +block_content.add_page: + path: '/block/add' + defaults: + _content: '\Drupal\block_content\Controller\BlockContentController::add' + _title: 'Add custom block' + options: + _admin_route: TRUE + requirements: + _permission: 'administer blocks' + +block_content.add_form: + path: '/block/add/{block_content_type}' + defaults: + _content: '\Drupal\block_content\Controller\BlockContentController::addForm' + _title_callback: 'Drupal\block_content\Controller\BlockContentController::getAddFormTitle' + options: + _admin_route: TRUE + requirements: + _permission: 'administer blocks' + +block_content.type_delete: + path: '/admin/structure/block/block-content/manage/{block_content_type}/delete' + defaults: + _entity_form: 'block_content_type.delete' + _title: 'Delete' + requirements: + _entity_access: 'block_content_type.delete' + options: + _admin_route: TRUE + +block_content.edit: + path: '/block/{block_content}' + defaults: + _entity_form: 'block_content.edit' + options: + _admin_route: TRUE + requirements: + _entity_access: 'block_content.update' + +block_content.delete: + path: '/block/{block_content}/delete' + defaults: + _entity_form: 'block_content.delete' + _title: 'Delete' + options: + _admin_route: TRUE + requirements: + _entity_access: 'block_content.delete' + +block_content.type_add: + path: '/admin/structure/block/block-content/types/add' + defaults: + _entity_form: 'block_content_type.add' + _title: 'Add' + requirements: + _permission: 'administer blocks' + +block_content.type_edit: + path: '/admin/structure/block/block-content/manage/{block_content_type}' + defaults: + _entity_form: 'block_content_type.edit' + _title: 'Edit' + requirements: + _entity_access: 'block_content_type.update' + +block_content.list: + path: '/admin/structure/block/block-content' + defaults: + _title: 'Custom block library' + _entity_list: 'block_content' + requirements: + _permission: 'administer blocks' diff --git a/core/modules/block/custom_block/config/install/custom_block.type.basic.yml b/core/modules/block_content/config/install/block_content.type.basic.yml similarity index 100% rename from core/modules/block/custom_block/config/install/custom_block.type.basic.yml rename to core/modules/block_content/config/install/block_content.type.basic.yml diff --git a/core/modules/block_content/config/install/entity.view_mode.block_content.full.yml b/core/modules/block_content/config/install/entity.view_mode.block_content.full.yml new file mode 100644 index 000000000000..c558d549fb0e --- /dev/null +++ b/core/modules/block_content/config/install/entity.view_mode.block_content.full.yml @@ -0,0 +1,8 @@ +id: block_content.full +label: Full +status: false +cache: true +targetEntityType: block_content +dependencies: + module: + - block_content diff --git a/core/modules/block/custom_block/config/schema/custom_block.schema.yml b/core/modules/block_content/config/schema/block_content.schema.yml similarity index 92% rename from core/modules/block/custom_block/config/schema/custom_block.schema.yml rename to core/modules/block_content/config/schema/block_content.schema.yml index b65523950d9d..d24149492a84 100644 --- a/core/modules/block/custom_block/config/schema/custom_block.schema.yml +++ b/core/modules/block_content/config/schema/block_content.schema.yml @@ -1,6 +1,6 @@ # Schema for the configuration files of the Custom Block module. -custom_block.type.*: +block_content.type.*: type: config_entity label: 'Custom block type settings' mapping: diff --git a/core/modules/block/custom_block/js/custom_block.js b/core/modules/block_content/js/block_content.js similarity index 81% rename from core/modules/block/custom_block/js/custom_block.js rename to core/modules/block_content/js/block_content.js index 8ea33647b128..a8cd785d0826 100644 --- a/core/modules/block/custom_block/js/custom_block.js +++ b/core/modules/block_content/js/block_content.js @@ -1,16 +1,16 @@ /** * @file - * Defines Javascript behaviors for the custom_block module. + * Defines Javascript behaviors for the block_content module. */ (function ($) { "use strict"; - Drupal.behaviors.customBlockDetailsSummaries = { + Drupal.behaviors.blockContentDetailsSummaries = { attach: function (context) { var $context = $(context); - $context.find('.custom-block-form-revision-information').drupalSetSummary(function (context) { + $context.find('.block-content-form-revision-information').drupalSetSummary(function (context) { var $context = $(context); var revisionCheckbox = $context.find('.form-item-revision input'); @@ -25,7 +25,7 @@ return Drupal.t('No revision'); }); - $context.find('fieldset.custom-block-translation-options').drupalSetSummary(function (context) { + $context.find('fieldset.block-content-translation-options').drupalSetSummary(function (context) { var $context = $(context); var translate; var $checkbox = $context.find('.form-item-translation-translate input'); diff --git a/core/modules/block/custom_block/src/CustomBlockAccessController.php b/core/modules/block_content/src/BlockContentAccessController.php similarity index 75% rename from core/modules/block/custom_block/src/CustomBlockAccessController.php rename to core/modules/block_content/src/BlockContentAccessController.php index c1d65be3b184..5709498bb5f5 100644 --- a/core/modules/block/custom_block/src/CustomBlockAccessController.php +++ b/core/modules/block_content/src/BlockContentAccessController.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\CustomBlockAccessController. + * Contains \Drupal\block_content\BlockContentAccessController. */ -namespace Drupal\custom_block; +namespace Drupal\block_content; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityAccessController; @@ -14,7 +14,7 @@ /** * Defines the access controller for the custom block entity type. */ -class CustomBlockAccessController extends EntityAccessController { +class BlockContentAccessController extends EntityAccessController { /** * {@inheritdoc} diff --git a/core/modules/block/custom_block/src/CustomBlockForm.php b/core/modules/block_content/src/BlockContentForm.php similarity index 86% rename from core/modules/block/custom_block/src/CustomBlockForm.php rename to core/modules/block_content/src/BlockContentForm.php index 30f5342d875a..db220d445414 100644 --- a/core/modules/block/custom_block/src/CustomBlockForm.php +++ b/core/modules/block_content/src/BlockContentForm.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\CustomBlockForm. + * Contains \Drupal\block_content\BlockContentForm. */ -namespace Drupal\custom_block; +namespace Drupal\block_content; use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\ContentEntityForm; @@ -18,14 +18,14 @@ /** * Form controller for the custom block edit forms. */ -class CustomBlockForm extends ContentEntityForm { +class BlockContentForm extends ContentEntityForm { /** * The custom block storage. * * @var \Drupal\Core\Entity\EntityStorageInterface */ - protected $customBlockStorage; + protected $blockContentStorage; /** * The language manager. @@ -35,18 +35,18 @@ class CustomBlockForm extends ContentEntityForm { protected $languageManager; /** - * Constructs a CustomBlockForm object. + * Constructs a BlockContentForm object. * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. - * @param \Drupal\Core\Entity\EntityStorageInterface $custom_block_storage + * @param \Drupal\Core\Entity\EntityStorageInterface $block_content_storage * The custom block storage. * @param \Drupal\Core\Language\LanguageManager $language_manager * The language manager. */ - public function __construct(EntityManagerInterface $entity_manager, EntityStorageInterface $custom_block_storage, LanguageManager $language_manager) { + public function __construct(EntityManagerInterface $entity_manager, EntityStorageInterface $block_content_storage, LanguageManager $language_manager) { parent::__construct($entity_manager); - $this->customBlockStorage = $custom_block_storage; + $this->blockContentStorage = $block_content_storage; $this->languageManager = $language_manager; } @@ -57,7 +57,7 @@ public static function create(ContainerInterface $container) { $entity_manager = $container->get('entity.manager'); return new static( $entity_manager, - $entity_manager->getStorage('custom_block'), + $entity_manager->getStorage('block_content'), $container->get('language_manager') ); } @@ -67,13 +67,13 @@ public static function create(ContainerInterface $container) { * * Prepares the custom block object. * - * Fills in a few default values, and then invokes hook_custom_block_prepare() + * Fills in a few default values, and then invokes hook_block_content_prepare() * on all modules. */ protected function prepareEntity() { $block = $this->entity; // Set up default values, if required. - $block_type = entity_load('custom_block_type', $block->bundle()); + $block_type = entity_load('block_content_type', $block->bundle()); if (!$block->isNew()) { $block->setRevisionLog(NULL); } @@ -97,7 +97,7 @@ public function form(array $form, array &$form_state) { $form['#attributes']['class'][0] = drupal_html_class('block-' . $block->bundle() . '-form'); if ($this->moduleHandler->moduleExists('language')) { - $language_configuration = language_get_default_configuration('custom_block', $block->bundle()); + $language_configuration = language_get_default_configuration('block_content', $block->bundle()); // Set the correct default language. if ($block->isNew()) { @@ -128,10 +128,10 @@ public function form(array $form, array &$form_state) { '#open' => $block->isNewRevision(), '#group' => 'advanced', '#attributes' => array( - 'class' => array('custom-block-form-revision-information'), + 'class' => array('block-content-form-revision-information'), ), '#attached' => array( - 'library' => array('custom_block/drupal.custom_block'), + 'library' => array('block_content/drupal.block_content'), ), '#weight' => 20, '#access' => $block->isNewRevision() || $account->hasPermission('administer blocks'), @@ -195,7 +195,7 @@ public function save(array $form, array &$form_state) { $insert = $block->isNew(); $block->save(); $watchdog_args = array('@type' => $block->bundle(), '%info' => $block->label()); - $block_type = entity_load('custom_block_type', $block->bundle()); + $block_type = entity_load('block_content_type', $block->bundle()); $t_args = array('@type' => $block_type->label(), '%info' => $block->label()); if ($insert) { @@ -217,13 +217,13 @@ public function save(array $form, array &$form_state) { $form_state['redirect_route'] = array( 'route_name' => 'block.admin_add', 'route_parameters' => array( - 'plugin_id' => 'custom_block:' . $block->uuid(), + 'plugin_id' => 'block_content:' . $block->uuid(), 'theme' => $theme, ), ); } else { - $form_state['redirect_route']['route_name'] = 'custom_block.list'; + $form_state['redirect_route']['route_name'] = 'block_content.list'; } } else { @@ -242,7 +242,7 @@ public function save(array $form, array &$form_state) { */ public function validateForm(array &$form, array &$form_state) { if ($this->entity->isNew()) { - $exists = $this->customBlockStorage->loadByProperties(array('info' => $form_state['values']['info'])); + $exists = $this->blockContentStorage->loadByProperties(array('info' => $form_state['values']['info'])); if (!empty($exists)) { $this->setFormError('info', $form_state, $this->t('A block with description %name already exists.', array( '%name' => $form_state['values']['info'][0]['value'], diff --git a/core/modules/block/custom_block/src/CustomBlockInterface.php b/core/modules/block_content/src/BlockContentInterface.php similarity index 83% rename from core/modules/block/custom_block/src/CustomBlockInterface.php rename to core/modules/block_content/src/BlockContentInterface.php index d6ef5d58fd56..d6f981c4b0ee 100644 --- a/core/modules/block/custom_block/src/CustomBlockInterface.php +++ b/core/modules/block_content/src/BlockContentInterface.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\Entity\CustomBlockInterface. + * Contains \Drupal\block_content\Entity\BlockContentInterface. */ -namespace Drupal\custom_block; +namespace Drupal\block_content; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityChangedInterface; @@ -13,7 +13,7 @@ /** * Provides an interface defining a custom block entity. */ -interface CustomBlockInterface extends ContentEntityInterface, EntityChangedInterface { +interface BlockContentInterface extends ContentEntityInterface, EntityChangedInterface { /** * Returns the block revision log message. @@ -29,7 +29,7 @@ public function getRevisionLog(); * @param string $info * The block description. * - * @return \Drupal\custom_block\CustomBlockInterface + * @return \Drupal\block_content\BlockContentInterface * The class instance that this method is called on. */ public function setInfo($info); @@ -40,7 +40,7 @@ public function setInfo($info); * @param string $revision_log * The revision log message. * - * @return \Drupal\custom_block\CustomBlockInterface + * @return \Drupal\block_content\BlockContentInterface * The class instance that this method is called on. */ public function setRevisionLog($revision_log); @@ -55,7 +55,7 @@ public function setRevisionLog($revision_log); * @param string $theme * The theme name. * - * @return \Drupal\custom_block\CustomBlockInterface + * @return \Drupal\block_content\BlockContentInterface * The class instance that this method is called on. */ public function setTheme($theme); diff --git a/core/modules/block/custom_block/src/CustomBlockListBuilder.php b/core/modules/block_content/src/BlockContentListBuilder.php similarity index 78% rename from core/modules/block/custom_block/src/CustomBlockListBuilder.php rename to core/modules/block_content/src/BlockContentListBuilder.php index 5df5a1948b51..731f2dac9688 100644 --- a/core/modules/block/custom_block/src/CustomBlockListBuilder.php +++ b/core/modules/block_content/src/BlockContentListBuilder.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\CustomBlockListBuilder. + * Contains \Drupal\block_content\BlockContentListBuilder. */ -namespace Drupal\custom_block; +namespace Drupal\block_content; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityListBuilder; @@ -13,9 +13,9 @@ /** * Defines a class to build a listing of custom block entities. * - * @see \Drupal\custom_block\Entity\CustomBlock + * @see \Drupal\block_content\Entity\BlockContent */ -class CustomBlockListBuilder extends EntityListBuilder { +class BlockContentListBuilder extends EntityListBuilder { /** * {@inheritdoc} @@ -39,7 +39,7 @@ public function buildRow(EntityInterface $entity) { public function getDefaultOperations(EntityInterface $entity) { $operations = parent::getDefaultOperations($entity); if (isset($operations['edit'])) { - $operations['edit']['query']['destination'] = 'admin/structure/block/custom-blocks'; + $operations['edit']['query']['destination'] = 'admin/structure/block/block-content'; } return $operations; } diff --git a/core/modules/block_content/src/BlockContentStorage.php b/core/modules/block_content/src/BlockContentStorage.php new file mode 100644 index 000000000000..f7449e9b842d --- /dev/null +++ b/core/modules/block_content/src/BlockContentStorage.php @@ -0,0 +1,34 @@ +<?php + +/** + * @file + * Contains \Drupal\block_content\BlockContentStorage. + */ + +namespace Drupal\block_content; + +use Drupal\Core\Entity\ContentEntityDatabaseStorage; + +/** + * Provides storage for the 'block_content' entity type. + */ +class BlockContentStorage extends ContentEntityDatabaseStorage { + + /** + * {@inheritdoc} + */ + public function getSchema() { + $schema = parent::getSchema(); + + // Marking the respective fields as NOT NULL makes the indexes more + // performant. + $schema['block_content']['fields']['info']['not null'] = TRUE; + + $schema['block_content']['unique keys'] += array( + 'block_content__info' => array('info'), + ); + + return $schema; + } + +} diff --git a/core/modules/block/custom_block/src/CustomBlockTranslationHandler.php b/core/modules/block_content/src/BlockContentTranslationHandler.php similarity index 73% rename from core/modules/block/custom_block/src/CustomBlockTranslationHandler.php rename to core/modules/block_content/src/BlockContentTranslationHandler.php index 2bdd7f048f07..148e2491b9de 100644 --- a/core/modules/block/custom_block/src/CustomBlockTranslationHandler.php +++ b/core/modules/block_content/src/BlockContentTranslationHandler.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\CustomBlockTranslationHandler. + * Contains \Drupal\block_content\BlockContentTranslationHandler. */ -namespace Drupal\custom_block; +namespace Drupal\block_content; use Drupal\Core\Entity\EntityInterface; use Drupal\content_translation\ContentTranslationHandler; @@ -13,7 +13,7 @@ /** * Defines the translation handler for custom blocks. */ -class CustomBlockTranslationHandler extends ContentTranslationHandler { +class BlockContentTranslationHandler extends ContentTranslationHandler { /** * {@inheritdoc} @@ -26,7 +26,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac '#group' => 'additional_settings', '#weight' => 100, '#attributes' => array( - 'class' => array('custom-block-translation-options'), + 'class' => array('block-content-translation-options'), ), ); } @@ -36,7 +36,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac * {@inheritdoc} */ protected function entityFormTitle(EntityInterface $entity) { - $block_type = entity_load('custom_block_type', $entity->bundle()); + $block_type = entity_load('block_content_type', $entity->bundle()); return t('<em>Edit @type</em> @title', array('@type' => $block_type->label(), '@title' => $entity->label())); } diff --git a/core/modules/block/custom_block/src/CustomBlockTypeForm.php b/core/modules/block_content/src/BlockContentTypeForm.php similarity index 80% rename from core/modules/block/custom_block/src/CustomBlockTypeForm.php rename to core/modules/block_content/src/BlockContentTypeForm.php index 61567f805001..e64bfa3cf66e 100644 --- a/core/modules/block/custom_block/src/CustomBlockTypeForm.php +++ b/core/modules/block_content/src/BlockContentTypeForm.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\CustomBlockTypeForm. + * Contains \Drupal\block_content\BlockContentTypeForm. */ -namespace Drupal\custom_block; +namespace Drupal\block_content; use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityTypeInterface; @@ -13,7 +13,7 @@ /** * Base form for category edit forms. */ -class CustomBlockTypeForm extends EntityForm { +class BlockContentTypeForm extends EntityForm { /** * Overrides \Drupal\Core\Entity\EntityForm::form(). @@ -35,7 +35,7 @@ public function form(array $form, array &$form_state) { '#type' => 'machine_name', '#default_value' => $block_type->id(), '#machine_name' => array( - 'exists' => '\Drupal\custom_block\Entity\CustomBlockType::load', + 'exists' => '\Drupal\block_content\Entity\BlockContentType::load', ), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, '#disabled' => !$block_type->isNew(), @@ -62,11 +62,11 @@ public function form(array $form, array &$form_state) { '#group' => 'additional_settings', ); - $language_configuration = language_get_default_configuration('custom_block', $block_type->id()); + $language_configuration = language_get_default_configuration('block_content', $block_type->id()); $form['language']['language_configuration'] = array( '#type' => 'language_configuration', '#entity_information' => array( - 'entity_type' => 'custom_block', + 'entity_type' => 'block_content', 'bundle' => $block_type->id(), ), '#default_value' => $language_configuration, @@ -94,14 +94,14 @@ public function save(array $form, array &$form_state) { $edit_link = \Drupal::linkGenerator()->generateFromUrl($this->t('Edit'), $this->entity->urlInfo()); if ($status == SAVED_UPDATED) { drupal_set_message(t('Custom block type %label has been updated.', array('%label' => $block_type->label()))); - watchdog('custom_block', 'Custom block type %label has been updated.', array('%label' => $block_type->label()), WATCHDOG_NOTICE, $edit_link); + watchdog('block_content', 'Custom block type %label has been updated.', array('%label' => $block_type->label()), WATCHDOG_NOTICE, $edit_link); } else { drupal_set_message(t('Custom block type %label has been added.', array('%label' => $block_type->label()))); - watchdog('custom_block', 'Custom block type %label has been added.', array('%label' => $block_type->label()), WATCHDOG_NOTICE, $edit_link); + watchdog('block_content', 'Custom block type %label has been added.', array('%label' => $block_type->label()), WATCHDOG_NOTICE, $edit_link); } - $form_state['redirect_route']['route_name'] = 'custom_block.type_list'; + $form_state['redirect_route']['route_name'] = 'block_content.type_list'; } } diff --git a/core/modules/block_content/src/BlockContentTypeInterface.php b/core/modules/block_content/src/BlockContentTypeInterface.php new file mode 100644 index 000000000000..cb216316b813 --- /dev/null +++ b/core/modules/block_content/src/BlockContentTypeInterface.php @@ -0,0 +1,17 @@ +<?php + +/** + * @file + * Contains \Drupal\block_content\Entity\BlockContentTypeInterface. + */ + +namespace Drupal\block_content; + +use Drupal\Core\Config\Entity\ConfigEntityInterface; + +/** + * Provides an interface defining a custom block type entity. + */ +interface BlockContentTypeInterface extends ConfigEntityInterface { + +} diff --git a/core/modules/block/custom_block/src/CustomBlockTypeListBuilder.php b/core/modules/block_content/src/BlockContentTypeListBuilder.php similarity index 85% rename from core/modules/block/custom_block/src/CustomBlockTypeListBuilder.php rename to core/modules/block_content/src/BlockContentTypeListBuilder.php index 723ea71e9430..6cfda1df2e7e 100644 --- a/core/modules/block/custom_block/src/CustomBlockTypeListBuilder.php +++ b/core/modules/block_content/src/BlockContentTypeListBuilder.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\CustomBlockTypeListBuilder. + * Contains \Drupal\block_content\BlockContentTypeListBuilder. */ -namespace Drupal\custom_block; +namespace Drupal\block_content; use Drupal\Component\Utility\Xss; use Drupal\Core\Config\Entity\ConfigEntityListBuilder; @@ -14,9 +14,9 @@ /** * Defines a class to build a listing of custom block type entities. * - * @see \Drupal\custom_block\Entity\CustomBlockType + * @see \Drupal\block_content\Entity\BlockContentType */ -class CustomBlockTypeListBuilder extends ConfigEntityListBuilder { +class BlockContentTypeListBuilder extends ConfigEntityListBuilder { /** * {@inheritdoc} diff --git a/core/modules/block/custom_block/src/CustomBlockViewBuilder.php b/core/modules/block_content/src/BlockContentViewBuilder.php similarity index 70% rename from core/modules/block/custom_block/src/CustomBlockViewBuilder.php rename to core/modules/block_content/src/BlockContentViewBuilder.php index 16e11ee27870..0977e9f1eb86 100644 --- a/core/modules/block/custom_block/src/CustomBlockViewBuilder.php +++ b/core/modules/block_content/src/BlockContentViewBuilder.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\CustomBlockViewBuilder. + * Contains \Drupal\block_content\BlockContentViewBuilder. */ -namespace Drupal\custom_block; +namespace Drupal\block_content; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\EntityInterface; @@ -14,7 +14,7 @@ /** * Render controller for custom blocks. */ -class CustomBlockViewBuilder extends EntityViewBuilder { +class BlockContentViewBuilder extends EntityViewBuilder { /** * {@inheritdoc} @@ -23,8 +23,8 @@ protected function alterBuild(array &$build, EntityInterface $entity, EntityView parent::alterBuild($build, $entity, $display, $view_mode, $langcode); // Add contextual links for this custom block. if (!$entity->isNew() && $view_mode == 'full') { - $build['#contextual_links']['custom_block'] = array( - 'route_parameters' => array('custom_block' => $entity->id()), + $build['#contextual_links']['block_content'] = array( + 'route_parameters' => array('block_content' => $entity->id()), 'metadata' => array('changed' => $entity->getChangedTime()), ); } diff --git a/core/modules/block/custom_block/src/Controller/CustomBlockController.php b/core/modules/block_content/src/Controller/BlockContentController.php similarity index 61% rename from core/modules/block/custom_block/src/Controller/CustomBlockController.php rename to core/modules/block_content/src/Controller/BlockContentController.php index e30c42dae171..4716bba56ab0 100644 --- a/core/modules/block/custom_block/src/Controller/CustomBlockController.php +++ b/core/modules/block_content/src/Controller/BlockContentController.php @@ -2,33 +2,33 @@ /** * @file - * Contains \Drupal\custom_block\Controller\CustomBlockController + * Contains \Drupal\block_content\Controller\BlockContentController */ -namespace Drupal\custom_block\Controller; +namespace Drupal\block_content\Controller; use Drupal\Component\Plugin\PluginManagerInterface; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Entity\EntityStorageInterface; -use Drupal\custom_block\CustomBlockTypeInterface; +use Drupal\block_content\BlockContentTypeInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; -class CustomBlockController extends ControllerBase { +class BlockContentController extends ControllerBase { /** * The custom block storage. * * @var \Drupal\Core\Entity\EntityStorageInterface */ - protected $customBlockStorage; + protected $blockContentStorage; /** * The custom block type storage. * * @var \Drupal\Core\Entity\EntityStorageInterface */ - protected $customBlockTypeStorage; + protected $blockContentTypeStorage; /** * {@inheritdoc} @@ -36,22 +36,22 @@ class CustomBlockController extends ControllerBase { public static function create(ContainerInterface $container) { $entity_manager = $container->get('entity.manager'); return new static( - $entity_manager->getStorage('custom_block'), - $entity_manager->getStorage('custom_block_type') + $entity_manager->getStorage('block_content'), + $entity_manager->getStorage('block_content_type') ); } /** - * Constructs a CustomBlock object. + * Constructs a BlockContent object. * - * @param \Drupal\Core\Entity\EntityStorageInterface $custom_block_storage + * @param \Drupal\Core\Entity\EntityStorageInterface $block_content_storage * The custom block storage. - * @param \Drupal\Core\Entity\EntityStorageInterface $custom_block_type_storage + * @param \Drupal\Core\Entity\EntityStorageInterface $block_content_type_storage * The custom block type storage. */ - public function __construct(EntityStorageInterface $custom_block_storage, EntityStorageInterface $custom_block_type_storage) { - $this->customBlockStorage = $custom_block_storage; - $this->customBlockTypeStorage = $custom_block_type_storage; + public function __construct(EntityStorageInterface $block_content_storage, EntityStorageInterface $block_content_type_storage) { + $this->blockContentStorage = $block_content_storage; + $this->blockContentTypeStorage = $block_content_type_storage; } /** @@ -66,19 +66,19 @@ public function __construct(EntityStorageInterface $custom_block_storage, Entity * returns the custom block add page for that custom block type. */ public function add(Request $request) { - $types = $this->customBlockTypeStorage->loadMultiple(); + $types = $this->blockContentTypeStorage->loadMultiple(); if ($types && count($types) == 1) { $type = reset($types); return $this->addForm($type, $request); } - return array('#theme' => 'custom_block_add_list', '#content' => $types); + return array('#theme' => 'block_content_add_list', '#content' => $types); } /** * Presents the custom block creation form. * - * @param \Drupal\custom_block\CustomBlockTypeInterface $custom_block_type + * @param \Drupal\block_content\BlockContentTypeInterface $block_content_type * The custom block type to add. * @param \Symfony\Component\HttpFoundation\Request $request * The current request object. @@ -86,9 +86,9 @@ public function add(Request $request) { * @return array * A form array as expected by drupal_render(). */ - public function addForm(CustomBlockTypeInterface $custom_block_type, Request $request) { - $block = $this->customBlockStorage->create(array( - 'type' => $custom_block_type->id() + public function addForm(BlockContentTypeInterface $block_content_type, Request $request) { + $block = $this->blockContentStorage->create(array( + 'type' => $block_content_type->id() )); if (($theme = $request->query->get('theme')) && in_array($theme, array_keys(list_themes()))) { // We have navigated to this page from the block library and will keep track @@ -102,14 +102,14 @@ public function addForm(CustomBlockTypeInterface $custom_block_type, Request $re /** * Provides the page title for this controller. * - * @param \Drupal\custom_block\CustomBlockTypeInterface $custom_block_type + * @param \Drupal\block_content\BlockContentTypeInterface $block_content_type * The custom block type being added. * * @return string * The page title. */ - public function getAddFormTitle(CustomBlockTypeInterface $custom_block_type) { - return $this->t('Add %type custom block', array('%type' => $custom_block_type->label())); + public function getAddFormTitle(BlockContentTypeInterface $block_content_type) { + return $this->t('Add %type custom block', array('%type' => $block_content_type->label())); } } diff --git a/core/modules/block/custom_block/src/Entity/CustomBlock.php b/core/modules/block_content/src/Entity/BlockContent.php similarity index 78% rename from core/modules/block/custom_block/src/Entity/CustomBlock.php rename to core/modules/block_content/src/Entity/BlockContent.php index a91e01ebb976..630fe5174d59 100644 --- a/core/modules/block/custom_block/src/Entity/CustomBlock.php +++ b/core/modules/block_content/src/Entity/BlockContent.php @@ -2,45 +2,45 @@ /** * @file - * Contains \Drupal\custom_block\Entity\CustomBlock. + * Contains \Drupal\block_content\Entity\BlockContent. */ -namespace Drupal\custom_block\Entity; +namespace Drupal\block_content\Entity; use Drupal\Core\Entity\ContentEntityBase; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\FieldDefinition; -use Drupal\custom_block\CustomBlockInterface; +use Drupal\block_content\BlockContentInterface; /** * Defines the custom block entity class. * * @ContentEntityType( - * id = "custom_block", + * id = "block_content", * label = @Translation("Custom Block"), * bundle_label = @Translation("Custom Block type"), * controllers = { - * "storage" = "Drupal\custom_block\CustomBlockStorage", - * "access" = "Drupal\custom_block\CustomBlockAccessController", - * "list_builder" = "Drupal\custom_block\CustomBlockListBuilder", - * "view_builder" = "Drupal\custom_block\CustomBlockViewBuilder", + * "storage" = "Drupal\block_content\BlockContentStorage", + * "access" = "Drupal\block_content\BlockContentAccessController", + * "list_builder" = "Drupal\block_content\BlockContentListBuilder", + * "view_builder" = "Drupal\block_content\BlockContentViewBuilder", * "form" = { - * "add" = "Drupal\custom_block\CustomBlockForm", - * "edit" = "Drupal\custom_block\CustomBlockForm", - * "delete" = "Drupal\custom_block\Form\CustomBlockDeleteForm", - * "default" = "Drupal\custom_block\CustomBlockForm" + * "add" = "Drupal\block_content\BlockContentForm", + * "edit" = "Drupal\block_content\BlockContentForm", + * "delete" = "Drupal\block_content\Form\BlockContentDeleteForm", + * "default" = "Drupal\block_content\BlockContentForm" * }, - * "translation" = "Drupal\custom_block\CustomBlockTranslationHandler" + * "translation" = "Drupal\block_content\BlockContentTranslationHandler" * }, * admin_permission = "administer blocks", - * base_table = "custom_block", - * revision_table = "custom_block_revision", + * base_table = "block_content", + * revision_table = "block_content_revision", * links = { - * "canonical" = "custom_block.edit", - * "delete-form" = "custom_block.delete", - * "edit-form" = "custom_block.edit", - * "admin-form" = "custom_block.type_edit" + * "canonical" = "block_content.edit", + * "delete-form" = "block_content.delete", + * "edit-form" = "block_content.edit", + * "admin-form" = "block_content.type_edit" * }, * fieldable = TRUE, * translatable = TRUE, @@ -51,10 +51,10 @@ * "label" = "info", * "uuid" = "uuid" * }, - * bundle_entity_type = "custom_block_type" + * bundle_entity_type = "block_content_type" * ) */ -class CustomBlock extends ContentEntityBase implements CustomBlockInterface { +class BlockContent extends ContentEntityBase implements BlockContentInterface { /** * The theme the block is being created in. @@ -106,7 +106,7 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { * {@inheritdoc} */ public function getInstances() { - return entity_load_multiple_by_properties('block', array('plugin' => 'custom_block:' . $this->uuid())); + return entity_load_multiple_by_properties('block', array('plugin' => 'block_content:' . $this->uuid())); } /** @@ -116,7 +116,7 @@ public function preSaveRevision(EntityStorageInterface $storage, \stdClass $reco parent::preSaveRevision($storage, $record); if (!$this->isNewRevision() && isset($this->original) && (!isset($record->revision_log) || $record->revision_log === '')) { - // If we are updating an existing custom_block without adding a new + // If we are updating an existing block_content without adding a new // revision and the user did not supply a revision log, keep the existing // one. $record->revision_log = $this->original->getRevisionLog(); @@ -172,7 +172,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['type'] = FieldDefinition::create('entity_reference') ->setLabel(t('Block type')) ->setDescription(t('The block type.')) - ->setSetting('target_type', 'custom_block_type'); + ->setSetting('target_type', 'block_content_type'); $fields['revision_log'] = FieldDefinition::create('string_long') ->setLabel(t('Revision log message')) diff --git a/core/modules/block_content/src/Entity/BlockContentType.php b/core/modules/block_content/src/Entity/BlockContentType.php new file mode 100644 index 000000000000..17a358ef1865 --- /dev/null +++ b/core/modules/block_content/src/Entity/BlockContentType.php @@ -0,0 +1,101 @@ +<?php + +/** + * @file + * Contains \Drupal\block_content\Entity\BlockContentType. + */ + +namespace Drupal\block_content\Entity; + +use Drupal\Core\Config\Entity\ConfigEntityBase; +use Drupal\Core\Config\Entity\ConfigEntityBundleBase; +use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\block_content\BlockContentTypeInterface; + +/** + * Defines the custom block type entity. + * + * @ConfigEntityType( + * id = "block_content_type", + * label = @Translation("Custom block type"), + * controllers = { + * "form" = { + * "default" = "Drupal\block_content\BlockContentTypeForm", + * "add" = "Drupal\block_content\BlockContentTypeForm", + * "edit" = "Drupal\block_content\BlockContentTypeForm", + * "delete" = "Drupal\block_content\Form\BlockContentTypeDeleteForm" + * }, + * "list_builder" = "Drupal\block_content\BlockContentTypeListBuilder" + * }, + * admin_permission = "administer blocks", + * config_prefix = "type", + * bundle_of = "block_content", + * entity_keys = { + * "id" = "id", + * "label" = "label" + * }, + * links = { + * "delete-form" = "block_content.type_delete", + * "edit-form" = "block_content.type_edit" + * } + * ) + */ +class BlockContentType extends ConfigEntityBundleBase implements BlockContentTypeInterface { + + /** + * The custom block type ID. + * + * @var string + */ + public $id; + + /** + * The custom block type label. + * + * @var string + */ + public $label; + + /** + * The default revision setting for custom blocks of this type. + * + * @var bool + */ + public $revision; + + /** + * The description of the block type. + * + * @var string + */ + public $description; + + /** + * {@inheritdoc} + */ + public function postSave(EntityStorageInterface $storage, $update = TRUE) { + parent::postSave($storage, $update); + + if (!$update && !$this->isSyncing()) { + entity_invoke_bundle_hook('create', 'block_content', $this->id()); + if (!$this->isSyncing()) { + block_content_add_body_field($this->id); + } + } + elseif ($this->getOriginalId() != $this->id) { + entity_invoke_bundle_hook('rename', 'block_content', $this->getOriginalId(), $this->id); + } + } + + /** + * {@inheritdoc} + */ + public static function postDelete(EntityStorageInterface $storage, array $entities) { + parent::postDelete($storage, $entities); + + foreach ($entities as $entity) { + entity_invoke_bundle_hook('delete', 'block_content', $entity->id()); + } + } + +} diff --git a/core/modules/block/custom_block/src/Form/CustomBlockDeleteForm.php b/core/modules/block_content/src/Form/BlockContentDeleteForm.php similarity index 77% rename from core/modules/block/custom_block/src/Form/CustomBlockDeleteForm.php rename to core/modules/block_content/src/Form/BlockContentDeleteForm.php index 11d393575b85..35c0386a0f39 100644 --- a/core/modules/block/custom_block/src/Form/CustomBlockDeleteForm.php +++ b/core/modules/block_content/src/Form/BlockContentDeleteForm.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\block\Form\CustomBlockDeleteForm. + * Contains \Drupal\block\Form\BlockContentDeleteForm. */ -namespace Drupal\custom_block\Form; +namespace Drupal\block_content\Form; use Drupal\Core\Entity\ContentEntityConfirmFormBase; use Drupal\Core\Url; @@ -13,7 +13,7 @@ /** * Provides a confirmation form for deleting a custom block entity. */ -class CustomBlockDeleteForm extends ContentEntityConfirmFormBase { +class BlockContentDeleteForm extends ContentEntityConfirmFormBase { /** * {@inheritdoc} @@ -56,8 +56,8 @@ public function buildForm(array $form, array &$form_state) { public function submit(array $form, array &$form_state) { $this->entity->delete(); drupal_set_message($this->t('Custom block %label has been deleted.', array('%label' => $this->entity->label()))); - watchdog('custom_block', 'Custom block %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE); - $form_state['redirect_route'] = new Url('custom_block.list'); + watchdog('block_content', 'Custom block %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE); + $form_state['redirect_route'] = new Url('block_content.list'); } } diff --git a/core/modules/block/custom_block/src/Form/CustomBlockTypeDeleteForm.php b/core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php similarity index 82% rename from core/modules/block/custom_block/src/Form/CustomBlockTypeDeleteForm.php rename to core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php index c57d2ad2fe0d..7e196eec9eed 100644 --- a/core/modules/block/custom_block/src/Form/CustomBlockTypeDeleteForm.php +++ b/core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\Form\CustomBlockTypeDeleteForm. + * Contains \Drupal\block_content\Form\BlockContentTypeDeleteForm. */ -namespace Drupal\custom_block\Form; +namespace Drupal\block_content\Form; use Drupal\Core\Entity\EntityConfirmFormBase; use Drupal\Core\Entity\Query\QueryFactory; @@ -15,7 +15,7 @@ /** * Provides a confirmation form for deleting a custom block type entity. */ -class CustomBlockTypeDeleteForm extends EntityConfirmFormBase { +class BlockContentTypeDeleteForm extends EntityConfirmFormBase { /** * The query factory to create entity queries. @@ -54,7 +54,7 @@ public function getQuestion() { * {@inheritdoc} */ public function getCancelRoute() { - return new Url('custom_block.type_list'); + return new Url('block_content.type_list'); } /** @@ -68,7 +68,7 @@ public function getConfirmText() { * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { - $blocks = $this->queryFactory->get('custom_block')->condition('type', $this->entity->id())->execute(); + $blocks = $this->queryFactory->get('block_content')->condition('type', $this->entity->id())->execute(); if (!empty($blocks)) { $caption = '<p>' . format_plural(count($blocks), '%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', '%label is used by @count custom blocks on your site. You may not remove %label until you have removed all of the %label custom blocks.', array('%label' => $this->entity->label())) . '</p>'; $form['description'] = array('#markup' => $caption); @@ -85,7 +85,7 @@ public function buildForm(array $form, array &$form_state) { public function submit(array $form, array &$form_state) { $this->entity->delete(); drupal_set_message(t('Custom block type %label has been deleted.', array('%label' => $this->entity->label()))); - watchdog('custom_block', 'Custom block type %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE); + watchdog('block_content', 'Custom block type %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE); $form_state['redirect_route'] = $this->getCancelRoute(); } diff --git a/core/modules/block/custom_block/src/Plugin/Block/CustomBlockBlock.php b/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php similarity index 88% rename from core/modules/block/custom_block/src/Plugin/Block/CustomBlockBlock.php rename to core/modules/block_content/src/Plugin/Block/BlockContentBlock.php index 5ef3ec275f9e..9f3d92dbb068 100644 --- a/core/modules/block/custom_block/src/Plugin/Block/CustomBlockBlock.php +++ b/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\Plugin\Block\CustomBlockBlock. + * Contains \Drupal\block_content\Plugin\Block\BlockContentBlock. */ -namespace Drupal\custom_block\Plugin\Block; +namespace Drupal\block_content\Plugin\Block; use Drupal\block\BlockBase; use Drupal\block\BlockManagerInterface; @@ -20,13 +20,13 @@ * Defines a generic custom block type. * * @Block( - * id = "custom_block", + * id = "block_content", * admin_label = @Translation("Custom block"), * category = @Translation("Custom"), - * derivative = "Drupal\custom_block\Plugin\Derivative\CustomBlock" + * derivative = "Drupal\block_content\Plugin\Derivative\BlockContent" * ) */ -class CustomBlockBlock extends BlockBase implements ContainerFactoryPluginInterface { +class BlockContentBlock extends BlockBase implements ContainerFactoryPluginInterface { /** * The Plugin Block Manager. @@ -57,7 +57,7 @@ class CustomBlockBlock extends BlockBase implements ContainerFactoryPluginInterf protected $account; /** - * Constructs a new CustomBlockBlock. + * Constructs a new BlockContentBlock. * * @param array $configuration * A configuration array containing information about the plugin instance. @@ -121,9 +121,9 @@ public function defaultConfiguration() { * Adds body and description fields to the block configuration form. */ public function blockForm($form, &$form_state) { - $form['custom_block']['view_mode'] = array( + $form['block_content']['view_mode'] = array( '#type' => 'select', - '#options' => $this->entityManager->getViewModeOptions('custom_block'), + '#options' => $this->entityManager->getViewModeOptions('block_content'), '#title' => t('View mode'), '#description' => t('Output the block in this view mode.'), '#default_value' => $this->configuration['view_mode'] @@ -138,7 +138,7 @@ public function blockForm($form, &$form_state) { public function blockSubmit($form, &$form_state) { // Invalidate the block cache to update custom block-based derivatives. if ($this->moduleHandler->moduleExists('block')) { - $this->configuration['view_mode'] = $form_state['values']['custom_block']['view_mode']; + $this->configuration['view_mode'] = $form_state['values']['block_content']['view_mode']; $this->blockManager->clearCachedDefinitions(); } } @@ -148,7 +148,7 @@ public function blockSubmit($form, &$form_state) { */ public function build() { $uuid = $this->getDerivativeId(); - if ($block = entity_load_by_uuid('custom_block', $uuid)) { + if ($block = entity_load_by_uuid('block_content', $uuid)) { return entity_view($block, $this->configuration['view_mode']); } else { diff --git a/core/modules/block_content/src/Plugin/Derivative/BlockContent.php b/core/modules/block_content/src/Plugin/Derivative/BlockContent.php new file mode 100644 index 000000000000..a7c17849be1e --- /dev/null +++ b/core/modules/block_content/src/Plugin/Derivative/BlockContent.php @@ -0,0 +1,28 @@ +<?php + +/** + * @file + * Contains \Drupal\block_content\Plugin\Derivative\BlockContent. + */ + +namespace Drupal\block_content\Plugin\Derivative; + +use Drupal\Component\Plugin\Derivative\DerivativeBase; +use Drupal\Core\Plugin\Discovery\ContainerDerivativeInterface; + +/** + * Retrieves block plugin definitions for all custom blocks. + */ +class BlockContent extends DerivativeBase { + /** + * {@inheritdoc} + */ + public function getDerivativeDefinitions($base_plugin_definition) { + $block_contents = entity_load_multiple('block_content'); + foreach ($block_contents as $block_content) { + $this->derivatives[$block_content->uuid()] = $base_plugin_definition; + $this->derivatives[$block_content->uuid()]['admin_label'] = $block_content->label(); + } + return parent::getDerivativeDefinitions($base_plugin_definition); + } +} diff --git a/core/modules/block/custom_block/src/Plugin/Menu/LocalAction/CustomBlockAddLocalAction.php b/core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php similarity index 76% rename from core/modules/block/custom_block/src/Plugin/Menu/LocalAction/CustomBlockAddLocalAction.php rename to core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php index af9b359ef015..e22425e0d101 100644 --- a/core/modules/block/custom_block/src/Plugin/Menu/LocalAction/CustomBlockAddLocalAction.php +++ b/core/modules/block_content/src/Plugin/Menu/LocalAction/BlockContentAddLocalAction.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\Plugin\Menu\LocalAction\CustomBlockAddLocalAction. + * Contains \Drupal\block_content\Plugin\Menu\LocalAction\BlockContentAddLocalAction. */ -namespace Drupal\custom_block\Plugin\Menu\LocalAction; +namespace Drupal\block_content\Plugin\Menu\LocalAction; use Drupal\Core\Menu\LocalActionDefault; use Symfony\Cmf\Component\Routing\RouteObjectInterface; @@ -14,7 +14,7 @@ /** * Modifies the 'Add custom block' local action. */ -class CustomBlockAddLocalAction extends LocalActionDefault { +class BlockContentAddLocalAction extends LocalActionDefault { /** * {@inheritdoc} @@ -26,12 +26,12 @@ public function getOptions(Request $request) { $options['query']['theme'] = $request->attributes->get('theme'); } // Adds a destination on custom block listing. - if ($request->attributes->get(RouteObjectInterface::ROUTE_NAME) == 'custom_block.list') { - $options['query']['destination'] = 'admin/structure/block/custom-blocks'; + if ($request->attributes->get(RouteObjectInterface::ROUTE_NAME) == 'block_content.list') { + $options['query']['destination'] = 'admin/structure/block/block-content'; } // Adds a destination on custom block listing. - if ($request->attributes->get(RouteObjectInterface::ROUTE_NAME) == 'custom_block.list') { - $options['query']['destination'] = 'admin/structure/block/custom-blocks'; + if ($request->attributes->get(RouteObjectInterface::ROUTE_NAME) == 'block_content.list') { + $options['query']['destination'] = 'admin/structure/block/block-content'; } return $options; } diff --git a/core/modules/block/custom_block/src/Tests/CustomBlockCacheTagsTest.php b/core/modules/block_content/src/Tests/BlockContentCacheTagsTest.php similarity index 73% rename from core/modules/block/custom_block/src/Tests/CustomBlockCacheTagsTest.php rename to core/modules/block_content/src/Tests/BlockContentCacheTagsTest.php index cfd87a957c22..52c32861984f 100644 --- a/core/modules/block/custom_block/src/Tests/CustomBlockCacheTagsTest.php +++ b/core/modules/block_content/src/Tests/BlockContentCacheTagsTest.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\Tests\CustomBlockCacheTagsTest. + * Contains \Drupal\block_content\Tests\BlockContentCacheTagsTest. */ -namespace Drupal\custom_block\Tests; +namespace Drupal\block_content\Tests; use Drupal\Core\Entity\EntityInterface; use Drupal\system\Tests\Entity\EntityCacheTagsTestBase; @@ -13,12 +13,12 @@ /** * Tests the Custom Block entity's cache tags. */ -class CustomBlockCacheTagsTest extends EntityCacheTagsTestBase { +class BlockContentCacheTagsTest extends EntityCacheTagsTestBase { /** * {@inheritdoc} */ - public static $modules = array('custom_block'); + public static $modules = array('block_content'); /** * {@inheritdoc} @@ -32,7 +32,7 @@ public static function getInfo() { */ protected function createEntity() { // Create a "Llama" custom block. - $custom_block = entity_create('custom_block', array( + $block_content = entity_create('block_content', array( 'info' => 'Llama', 'type' => 'basic', 'body' => array( @@ -40,9 +40,9 @@ protected function createEntity() { 'format' => 'plain_text', ), )); - $custom_block->save(); + $block_content->save(); - return $custom_block; + return $block_content; } /** diff --git a/core/modules/block/custom_block/src/Tests/CustomBlockCreationTest.php b/core/modules/block_content/src/Tests/BlockContentCreationTest.php similarity index 82% rename from core/modules/block/custom_block/src/Tests/CustomBlockCreationTest.php rename to core/modules/block_content/src/Tests/BlockContentCreationTest.php index 0ae892a66339..dd98507edc28 100644 --- a/core/modules/block/custom_block/src/Tests/CustomBlockCreationTest.php +++ b/core/modules/block_content/src/Tests/BlockContentCreationTest.php @@ -2,18 +2,18 @@ /** * @file - * Contains \Drupal\custom_block\Tests\CustomBlockCreationTest. + * Contains \Drupal\block_content\Tests\BlockContentCreationTest. */ -namespace Drupal\custom_block\Tests; +namespace Drupal\block_content\Tests; use Drupal\Core\Database\Database; -use Drupal\custom_block\Entity\CustomBlock; +use Drupal\block_content\Entity\BlockContent; /** * Tests creating and saving a block. */ -class CustomBlockCreationTest extends CustomBlockTestBase { +class BlockContentCreationTest extends BlockContentTestBase { /** * Modules to enable. @@ -22,7 +22,7 @@ class CustomBlockCreationTest extends CustomBlockTestBase { * * @var array */ - public static $modules = array('custom_block_test', 'dblog'); + public static $modules = array('block_content_test', 'dblog'); /** * Declares test information. @@ -46,10 +46,10 @@ protected function setUp() { /** * Creates a "Basic page" block and verifies its consistency in the database. */ - public function testCustomBlockCreation() { + public function testBlockContentCreation() { // Add a new view mode and verify if it is selected as expected. $this->drupalLogin($this->drupalCreateUser(array('administer display modes'))); - $this->drupalGet('admin/structure/display-modes/view/add/custom_block'); + $this->drupalGet('admin/structure/display-modes/view/add/block_content'); $edit = array( 'id' => 'test_view_mode', 'label' => 'Test View Mode', @@ -72,18 +72,18 @@ public function testCustomBlockCreation() { )), 'Basic block created.'); // Change the view mode. - $view_mode['settings[custom_block][view_mode]'] = 'test_view_mode'; + $view_mode['settings[block_content][view_mode]'] = 'test_view_mode'; $this->drupalPostForm(NULL, $view_mode, t('Save block')); // Go to the configure page and verify that the new view mode is correct. $this->drupalGet('admin/structure/block/manage/testblock'); - $this->assertFieldByXPath('//select[@name="settings[custom_block][view_mode]"]/option[@selected="selected"]/@value', 'test_view_mode', 'View mode changed to Test View Mode'); + $this->assertFieldByXPath('//select[@name="settings[block_content][view_mode]"]/option[@selected="selected"]/@value', 'test_view_mode', 'View mode changed to Test View Mode'); // Test the available view mode options. - $this->assertOption('edit-settings-custom-block-view-mode', 'default', 'The default view mode is available.'); + $this->assertOption('edit-settings-block-content-view-mode', 'default', 'The default view mode is available.'); // Check that the block exists in the database. - $blocks = entity_load_multiple_by_properties('custom_block', array('info' => $edit['info[0][value]'])); + $blocks = entity_load_multiple_by_properties('block_content', array('info' => $edit['info[0][value]'])); $block = reset($blocks); $this->assertTrue($block, 'Custom Block found in database.'); @@ -104,7 +104,7 @@ public function testCustomBlockCreation() { * Creates a custom block from defaults and ensures that the 'basic block' * type is being used. */ - public function testDefaultCustomBlockCreation() { + public function testDefaultBlockContentCreation() { $edit = array(); $edit['info[0][value]'] = $this->randomName(8); $edit['body[0][value]'] = $this->randomName(16); @@ -118,7 +118,7 @@ public function testDefaultCustomBlockCreation() { )), 'Basic block created.'); // Check that the block exists in the database. - $blocks = entity_load_multiple_by_properties('custom_block', array('info' => $edit['info[0][value]'])); + $blocks = entity_load_multiple_by_properties('block_content', array('info' => $edit['info[0][value]'])); $block = reset($blocks); $this->assertTrue($block, 'Default Custom Block found in database.'); } @@ -129,7 +129,7 @@ public function testDefaultCustomBlockCreation() { public function testFailedBlockCreation() { // Create a block. try { - $this->createCustomBlock('fail_creation'); + $this->createBlockContent('fail_creation'); $this->fail('Expected exception has not been thrown.'); } catch (\Exception $e) { @@ -138,7 +138,7 @@ public function testFailedBlockCreation() { if (Database::getConnection()->supportsTransactions()) { // Check that the block does not exist in the database. - $id = db_select('custom_block', 'b') + $id = db_select('block_content', 'b') ->fields('b', array('id')) ->condition('info', 'fail_creation') ->execute() @@ -147,7 +147,7 @@ public function testFailedBlockCreation() { } else { // Check that the block exists in the database. - $id = db_select('custom_block', 'b') + $id = db_select('block_content', 'b') ->fields('b', array('id')) ->condition('info', 'fail_creation') ->execute() @@ -177,11 +177,11 @@ public function testBlockDelete() { 'settings[label]' => $edit['info[0][value]'], 'region' => 'sidebar_first', ); - $block = entity_load('custom_block', 1); - $url = 'admin/structure/block/add/custom_block:' . $block->uuid() . '/' . \Drupal::config('system.theme')->get('default'); + $block = entity_load('block_content', 1); + $url = 'admin/structure/block/add/block_content:' . $block->uuid() . '/' . \Drupal::config('system.theme')->get('default'); $this->drupalPostForm($url, $instance, t('Save block')); - $block = CustomBlock::load(1); + $block = BlockContent::load(1); // Test getInstances method. $this->assertEqual(1, count($block->getInstances())); diff --git a/core/modules/block/custom_block/src/Tests/CustomBlockFieldTest.php b/core/modules/block_content/src/Tests/BlockContentFieldTest.php similarity index 77% rename from core/modules/block/custom_block/src/Tests/CustomBlockFieldTest.php rename to core/modules/block_content/src/Tests/BlockContentFieldTest.php index 63a891149c74..65c08c57c9f1 100644 --- a/core/modules/block/custom_block/src/Tests/CustomBlockFieldTest.php +++ b/core/modules/block_content/src/Tests/BlockContentFieldTest.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\Tests\CustomBlockFieldTest. + * Contains \Drupal\block_content\Tests\BlockContentFieldTest. */ -namespace Drupal\custom_block\Tests; +namespace Drupal\block_content\Tests; /** * Tests the block edit functionality. @@ -13,14 +13,14 @@ * @todo Consider removing this test when https://drupal.org/node/1822000 is * fixed. */ -class CustomBlockFieldTest extends CustomBlockTestBase { +class BlockContentFieldTest extends BlockContentTestBase { /** * Modules to enable. * * @var array */ - public static $modules = array('block', 'custom_block', 'link'); + public static $modules = array('block', 'block_content', 'link'); /** * The created field. @@ -39,7 +39,7 @@ class CustomBlockFieldTest extends CustomBlockTestBase { /** * The block type. * - * @var \Drupal\custom_block\Entity\CustomBlockType + * @var \Drupal\block_content\Entity\BlockContentType */ protected $blockType; @@ -61,12 +61,12 @@ public static function getInfo() { public function testBlockFields() { $this->drupalLogin($this->adminUser); - $this->blockType = $this->createCustomBlockType('link'); + $this->blockType = $this->createBlockContentType('link'); // Create a field with settings to validate. $this->field = entity_create('field_config', array( 'name' => drupal_strtolower($this->randomName()), - 'entity_type' => 'custom_block', + 'entity_type' => 'block_content', 'type' => 'link', 'cardinality' => 2, )); @@ -79,12 +79,12 @@ public function testBlockFields() { ), )); $this->instance->save(); - entity_get_form_display('custom_block', 'link', 'default') + entity_get_form_display('block_content', 'link', 'default') ->setComponent($this->field->getName(), array( 'type' => 'link_default', )) ->save(); - entity_get_display('custom_block', 'link', 'default') + entity_get_display('block_content', 'link', 'default') ->setComponent($this->field->getName(), array( 'type' => 'link', 'label' => 'hidden', @@ -99,8 +99,8 @@ public function testBlockFields() { $this->field->getName() . '[0][title]' => 'Example.com' ); $this->drupalPostForm(NULL, $edit, t('Save')); - $block = entity_load('custom_block', 1); - $url = 'admin/structure/block/add/custom_block:' . $block->uuid() . '/' . \Drupal::config('system.theme')->get('default'); + $block = entity_load('block_content', 1); + $url = 'admin/structure/block/add/block_content:' . $block->uuid() . '/' . \Drupal::config('system.theme')->get('default'); // Place the block. $instance = array( 'id' => drupal_strtolower($edit['info[0][value]']), diff --git a/core/modules/block/custom_block/src/Tests/CustomBlockListTest.php b/core/modules/block_content/src/Tests/BlockContentListTest.php similarity index 91% rename from core/modules/block/custom_block/src/Tests/CustomBlockListTest.php rename to core/modules/block_content/src/Tests/BlockContentListTest.php index 8bded49d6eb7..048fdfb62577 100644 --- a/core/modules/block/custom_block/src/Tests/CustomBlockListTest.php +++ b/core/modules/block_content/src/Tests/BlockContentListTest.php @@ -2,26 +2,26 @@ /** * @file - * Contains \Drupal\custom_block\Tests\CustomBlockListTest. + * Contains \Drupal\block_content\Tests\BlockContentListTest. */ -namespace Drupal\custom_block\Tests; +namespace Drupal\block_content\Tests; use Drupal\simpletest\WebTestBase; /** * Tests the listing of custom blocks. * - * @see \Drupal\block\CustomBlockListBuilder + * @see \Drupal\block\BlockContentListBuilder */ -class CustomBlockListTest extends WebTestBase { +class BlockContentListTest extends WebTestBase { /** * Modules to enable. * * @var array */ - public static $modules = array('block', 'custom_block', 'config_translation'); + public static $modules = array('block', 'block_content', 'config_translation'); public static function getInfo() { return array( @@ -36,7 +36,7 @@ public static function getInfo() { */ public function testListing() { $this->drupalLogin($this->drupalCreateUser(array('administer blocks', 'translate configuration'))); - $this->drupalGet('admin/structure/block/custom-blocks'); + $this->drupalGet('admin/structure/block/block-content'); // Test for the page title. $this->assertTitle(t('Custom block library') . ' | Drupal'); @@ -82,7 +82,7 @@ public function testListing() { // Edit the entity using the operations link. $blocks = $this->container ->get('entity.manager') - ->getStorage('custom_block') + ->getStorage('block_content') ->loadByProperties(array('info' => $label)); $block = reset($blocks); if (!empty($block)) { diff --git a/core/modules/block/custom_block/src/Tests/CustomBlockPageViewTest.php b/core/modules/block_content/src/Tests/BlockContentPageViewTest.php similarity index 67% rename from core/modules/block/custom_block/src/Tests/CustomBlockPageViewTest.php rename to core/modules/block_content/src/Tests/BlockContentPageViewTest.php index fafb357be516..b8edb114cde1 100644 --- a/core/modules/block/custom_block/src/Tests/CustomBlockPageViewTest.php +++ b/core/modules/block_content/src/Tests/BlockContentPageViewTest.php @@ -2,22 +2,22 @@ /** * @file - * Contains \Drupal\custom_block\Tests\CustomBlockPageViewTest. + * Contains \Drupal\block_content\Tests\BlockContentPageViewTest. */ -namespace Drupal\custom_block\Tests; +namespace Drupal\block_content\Tests; /** * Tests the block edit functionality. */ -class CustomBlockPageViewTest extends CustomBlockTestBase { +class BlockContentPageViewTest extends BlockContentTestBase { /** * Modules to enable. * * @var array */ - public static $modules = array('block', 'custom_block', 'custom_block_test'); + public static $modules = array('block', 'block_content', 'block_content_test'); /** * Declares test information. @@ -35,10 +35,10 @@ public static function getInfo() { */ public function testPageEdit() { $this->drupalLogin($this->adminUser); - $block = $this->createCustomBlock(); + $block = $this->createBlockContent(); // Attempt to view the block. - $this->drupalGet('custom-block/' . $block->id()); + $this->drupalGet('block-content/' . $block->id()); // Assert response was '200' and not '403 Access denied'. $this->assertResponse('200', 'User was able the view the block'); diff --git a/core/modules/block/custom_block/src/Tests/CustomBlockRevisionsTest.php b/core/modules/block_content/src/Tests/BlockContentRevisionsTest.php similarity index 87% rename from core/modules/block/custom_block/src/Tests/CustomBlockRevisionsTest.php rename to core/modules/block_content/src/Tests/BlockContentRevisionsTest.php index b2be3c491f54..0de498f9799e 100644 --- a/core/modules/block/custom_block/src/Tests/CustomBlockRevisionsTest.php +++ b/core/modules/block_content/src/Tests/BlockContentRevisionsTest.php @@ -2,15 +2,15 @@ /** * @file - * Contains \Drupal\custom_block\Tests\CustomBlockRevisionsTest. + * Contains \Drupal\block_content\Tests\BlockContentRevisionsTest. */ -namespace Drupal\custom_block\Tests; +namespace Drupal\block_content\Tests; /** * Tests the block revision functionality. */ -class CustomBlockRevisionsTest extends CustomBlockTestBase { +class BlockContentRevisionsTest extends BlockContentTestBase { /** * Stores blocks created during the test. @@ -42,7 +42,7 @@ protected function setUp() { parent::setUp(); // Create initial block. - $block = $this->createCustomBlock('initial'); + $block = $this->createBlockContent('initial'); $blocks = array(); $logs = array(); @@ -74,7 +74,7 @@ public function testRevisions() { foreach ($blocks as $delta => $revision_id) { // Confirm the correct revision text appears. - $loaded = entity_revision_load('custom_block', $revision_id); + $loaded = entity_revision_load('block_content', $revision_id); // Verify revision log is the same. $this->assertEqual($loaded->getRevisionLog(), $logs[$delta], format_string('Correct log message found for revision !revision', array( '!revision' => $loaded->getRevisionId(), @@ -97,7 +97,7 @@ public function testRevisions() { // Verify that the non-default revision id is greater than the default // revision id. - $default_revision = entity_load('custom_block', $loaded->id()); + $default_revision = entity_load('block_content', $loaded->id()); $this->assertTrue($loaded->getRevisionId() > $default_revision->getRevisionId(), 'Revision id is greater than default revision id.'); } diff --git a/core/modules/block/custom_block/src/Tests/CustomBlockSaveTest.php b/core/modules/block_content/src/Tests/BlockContentSaveTest.php similarity index 68% rename from core/modules/block/custom_block/src/Tests/CustomBlockSaveTest.php rename to core/modules/block_content/src/Tests/BlockContentSaveTest.php index bae766abc8d2..03d08577d6e9 100644 --- a/core/modules/block/custom_block/src/Tests/CustomBlockSaveTest.php +++ b/core/modules/block_content/src/Tests/BlockContentSaveTest.php @@ -2,25 +2,25 @@ /** * @file - * Contains \Drupal\custom_block\Tests\CustomBlockSaveTest. + * Contains \Drupal\block_content\Tests\BlockContentSaveTest. */ -namespace Drupal\custom_block\Tests; +namespace Drupal\block_content\Tests; use Drupal\Core\Language\Language; -use Drupal\custom_block\Entity\CustomBlock; +use Drupal\block_content\Entity\BlockContent; /** * Tests block save related functionality. */ -class CustomBlockSaveTest extends CustomBlockTestBase { +class BlockContentSaveTest extends BlockContentTestBase { /** * Modules to enable. * * @var array */ - public static $modules = array('custom_block_test'); + public static $modules = array('block_content_test'); /** * Declares test information. @@ -28,7 +28,7 @@ class CustomBlockSaveTest extends CustomBlockTestBase { public static function getInfo() { return array( 'name' => 'Custom Block save', - 'description' => 'Test $custom_block->save() for saving content.', + 'description' => 'Test $block_content->save() for saving content.', 'group' => 'Custom Block', ); } @@ -47,7 +47,7 @@ protected function setUp() { */ public function testImport() { // Custom block ID must be a number that is not in the database. - $max_id = db_query('SELECT MAX(id) FROM {custom_block}')->fetchField(); + $max_id = db_query('SELECT MAX(id) FROM {block_content}')->fetchField(); $test_id = $max_id + mt_rand(1000, 1000000); $info = $this->randomName(8); $block_array = array( @@ -56,7 +56,7 @@ public function testImport() { 'type' => 'basic', 'id' => $test_id ); - $block = entity_create('custom_block', $block_array); + $block = entity_create('block_content', $block_array); $block->enforceIsNew(TRUE); $block->save(); @@ -64,7 +64,7 @@ public function testImport() { $this->assertEqual($block->id(), $test_id, 'Block imported using provide id'); // Test the import saved. - $block_by_id = CustomBlock::load($test_id); + $block_by_id = BlockContent::load($test_id); $this->assertTrue($block_by_id, 'Custom block load by block ID.'); $this->assertIdentical($block_by_id->body->value, $block_array['body']['value']); } @@ -76,7 +76,7 @@ public function testImport() { */ public function testDeterminingChanges() { // Initial creation. - $block = $this->createCustomBlock('test_changes'); + $block = $this->createBlockContent('test_changes'); $this->assertEqual($block->getChangedTime(), REQUEST_TIME, 'Creating a block sets default "changed" timestamp.'); // Update the block without applying changes. @@ -87,14 +87,14 @@ public function testDeterminingChanges() { $block->setInfo('updated'); $block->save(); - // The hook implementations custom_block_test_custom_block_presave() and - // custom_block_test_custom_block_update() determine changes and change the + // The hook implementations block_content_test_block_content_presave() and + // block_content_test_block_content_update() determine changes and change the // title as well as programatically set the 'changed' timestamp. $this->assertEqual($block->label(), 'updated_presave_update', 'Changes have been determined.'); $this->assertEqual($block->getChangedTime(), 979534800, 'Saving a custom block uses "changed" timestamp set in presave hook.'); // Test the static block load cache to be cleared. - $block = CustomBlock::load($block->id()); + $block = BlockContent::load($block->id()); $this->assertEqual($block->label(), 'updated_presave', 'Static cache has been cleared.'); } @@ -102,16 +102,16 @@ public function testDeterminingChanges() { * Tests saving a block on block insert. * * This test ensures that a block has been fully saved when - * hook_custom_block_insert() is invoked, so that the block can be saved again + * hook_block_content_insert() is invoked, so that the block can be saved again * in a hook implementation without errors. * * @see block_test_block_insert() */ - public function testCustomBlockSaveOnInsert() { - // custom_block_test_custom_block_insert() triggers a save on insert if the + public function testBlockContentSaveOnInsert() { + // block_content_test_block_content_insert() triggers a save on insert if the // title equals 'new'. - $block = $this->createCustomBlock('new'); - $this->assertEqual($block->label(), 'CustomBlock ' . $block->id(), 'Custom block saved on block insert.'); + $block = $this->createBlockContent('new'); + $this->assertEqual($block->label(), 'BlockContent ' . $block->id(), 'Custom block saved on block insert.'); } } diff --git a/core/modules/block/custom_block/src/Tests/CustomBlockTestBase.php b/core/modules/block_content/src/Tests/BlockContentTestBase.php similarity index 67% rename from core/modules/block/custom_block/src/Tests/CustomBlockTestBase.php rename to core/modules/block_content/src/Tests/BlockContentTestBase.php index cf731fceae88..4f77de4eb08c 100644 --- a/core/modules/block/custom_block/src/Tests/CustomBlockTestBase.php +++ b/core/modules/block_content/src/Tests/BlockContentTestBase.php @@ -2,17 +2,17 @@ /** * @file - * Contains \Drupal\custom_block\Tests\CustomBlockTestBase. + * Contains \Drupal\block_content\Tests\BlockContentTestBase. */ -namespace Drupal\custom_block\Tests; +namespace Drupal\block_content\Tests; use Drupal\simpletest\WebTestBase; /** * Sets up page and article content types. */ -abstract class CustomBlockTestBase extends WebTestBase { +abstract class BlockContentTestBase extends WebTestBase { /** * Profile to use. @@ -40,7 +40,7 @@ abstract class CustomBlockTestBase extends WebTestBase { * * @var array */ - public static $modules = array('block', 'custom_block'); + public static $modules = array('block', 'block_content'); /** * Sets the test up. @@ -59,19 +59,19 @@ protected function setUp() { * @param string $bundle * (optional) Bundle name. Defaults to 'basic'. * - * @return \Drupal\custom_block\Entity\CustomBlock + * @return \Drupal\block_content\Entity\BlockContent * Created custom block. */ - protected function createCustomBlock($title = FALSE, $bundle = 'basic') { + protected function createBlockContent($title = FALSE, $bundle = 'basic') { $title = ($title ? : $this->randomName()); - if ($custom_block = entity_create('custom_block', array( + if ($block_content = entity_create('block_content', array( 'info' => $title, 'type' => $bundle, 'langcode' => 'en' ))) { - $custom_block->save(); + $block_content->save(); } - return $custom_block; + return $block_content; } /** @@ -80,11 +80,11 @@ protected function createCustomBlock($title = FALSE, $bundle = 'basic') { * @param string $label * The block type label. * - * @return \Drupal\custom_block\Entity\CustomBlockType + * @return \Drupal\block_content\Entity\BlockContentType * Created custom block type. */ - protected function createCustomBlockType($label) { - $bundle = entity_create('custom_block_type', array( + protected function createBlockContentType($label) { + $bundle = entity_create('block_content_type', array( 'id' => $label, 'label' => $label, 'revision' => FALSE diff --git a/core/modules/block/custom_block/src/Tests/CustomBlockTranslationUITest.php b/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php similarity index 77% rename from core/modules/block/custom_block/src/Tests/CustomBlockTranslationUITest.php rename to core/modules/block_content/src/Tests/BlockContentTranslationUITest.php index 761936e97a1e..35cf5ecff4f7 100644 --- a/core/modules/block/custom_block/src/Tests/CustomBlockTranslationUITest.php +++ b/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php @@ -2,18 +2,18 @@ /** * @file - * Contains \Drupal\custom_block\Tests\CustomBlockTranslationUITest. + * Contains \Drupal\block_content\Tests\BlockContentTranslationUITest. */ -namespace Drupal\custom_block\Tests; +namespace Drupal\block_content\Tests; use Drupal\content_translation\Tests\ContentTranslationUITest; -use Drupal\custom_block\Entity\CustomBlock; +use Drupal\block_content\Entity\BlockContent; /** * Tests the Custom Block Translation UI. */ -class CustomBlockTranslationUITest extends ContentTranslationUITest { +class BlockContentTranslationUITest extends ContentTranslationUITest { /** * The name of the test block. @@ -30,7 +30,7 @@ class CustomBlockTranslationUITest extends ContentTranslationUITest { 'content_translation', 'block', 'field_ui', - 'custom_block' + 'block_content' ); /** @@ -48,7 +48,7 @@ public static function getInfo() { * Overrides \Drupal\simpletest\WebTestBase::setUp(). */ public function setUp() { - $this->entityTypeId = 'custom_block'; + $this->entityTypeId = 'block_content'; $this->bundle = 'basic'; $this->name = drupal_strtolower($this->randomName()); $this->testLanguageSelector = FALSE; @@ -63,7 +63,7 @@ public function getTranslatorPermissions() { 'translate any entity', 'access administration pages', 'administer blocks', - 'administer custom_block fields' + 'administer block_content fields' )); } @@ -77,19 +77,19 @@ public function getTranslatorPermissions() { * (optional) Bundle name. When no value is given, defaults to * $this->bundle. Defaults to FALSE. * - * @return \Drupal\custom_block\Entity\CustomBlock + * @return \Drupal\block_content\Entity\BlockContent * Created custom block. */ - protected function createCustomBlock($title = FALSE, $bundle = FALSE) { + protected function createBlockContent($title = FALSE, $bundle = FALSE) { $title = ($title ? : $this->randomName()); $bundle = ($bundle ? : $this->bundle); - $custom_block = entity_create('custom_block', array( + $block_content = entity_create('block_content', array( 'info' => $title, 'type' => $bundle, 'langcode' => 'en' )); - $custom_block->save(); - return $custom_block; + $block_content->save(); + return $block_content; } /** @@ -119,7 +119,7 @@ protected function getEditValues($values, $langcode, $new = FALSE) { public function testDisabledBundle() { // Create a bundle that does not have translation enabled. $disabled_bundle = $this->randomName(); - $bundle = entity_create('custom_block_type', array( + $bundle = entity_create('block_content_type', array( 'id' => $disabled_bundle, 'label' => $disabled_bundle, 'revision' => FALSE @@ -127,14 +127,14 @@ public function testDisabledBundle() { $bundle->save(); // Create a node for each bundle. - $enabled_custom_block = $this->createCustomBlock(); - $disabled_custom_block = $this->createCustomBlock(FALSE, $bundle->id()); + $enabled_block_content = $this->createBlockContent(); + $disabled_block_content = $this->createBlockContent(FALSE, $bundle->id()); // Make sure that only a single row was inserted into the // {content_translation} table. $rows = db_query('SELECT * FROM {content_translation}')->fetchAll(); $this->assertEqual(1, count($rows)); - $this->assertEqual($enabled_custom_block->id(), reset($rows)->entity_id); + $this->assertEqual($enabled_block_content->id(), reset($rows)->entity_id); } } diff --git a/core/modules/block/custom_block/src/Tests/CustomBlockTypeTest.php b/core/modules/block_content/src/Tests/BlockContentTypeTest.php similarity index 79% rename from core/modules/block/custom_block/src/Tests/CustomBlockTypeTest.php rename to core/modules/block_content/src/Tests/BlockContentTypeTest.php index c9c918701a70..fc20f0c0a82e 100644 --- a/core/modules/block/custom_block/src/Tests/CustomBlockTypeTest.php +++ b/core/modules/block_content/src/Tests/BlockContentTypeTest.php @@ -2,15 +2,15 @@ /** * @file - * Contains \Drupal\custom_block\Tests\CustomBlockTypeTest. + * Contains \Drupal\block_content\Tests\BlockContentTypeTest. */ -namespace Drupal\custom_block\Tests; +namespace Drupal\block_content\Tests; /** * Tests related to custom block types. */ -class CustomBlockTypeTest extends CustomBlockTestBase { +class BlockContentTypeTest extends BlockContentTestBase { /** * Modules to enable. @@ -26,7 +26,7 @@ class CustomBlockTypeTest extends CustomBlockTestBase { */ protected $permissions = array( 'administer blocks', - 'administer custom_block fields' + 'administer block_content fields' ); /** @@ -34,7 +34,7 @@ class CustomBlockTypeTest extends CustomBlockTestBase { */ public static function getInfo() { return array( - 'name' => 'CustomBlock types', + 'name' => 'Custom Block types', 'description' => 'Ensures that custom block type functions work correctly.', 'group' => 'Custom Block', ); @@ -43,11 +43,11 @@ public static function getInfo() { /** * Tests creating a block type programmatically and via a form. */ - public function testCustomBlockTypeCreation() { + public function testBlockContentTypeCreation() { // Create a block type programmaticaly. - $type = $this->createCustomBlockType('other'); + $type = $this->createBlockContentType('other'); - $block_type = entity_load('custom_block_type', 'other'); + $block_type = entity_load('block_content_type', 'other'); $this->assertTrue($block_type, 'The new block type has been created.'); // Login a test user. @@ -61,8 +61,8 @@ public function testCustomBlockTypeCreation() { 'id' => 'foo', 'label' => 'title for foo', ); - $this->drupalPostForm('admin/structure/block/custom-blocks/types/add', $edit, t('Save')); - $block_type = entity_load('custom_block_type', 'foo'); + $this->drupalPostForm('admin/structure/block/block-content/types/add', $edit, t('Save')); + $block_type = entity_load('block_content_type', 'foo'); $this->assertTrue($block_type, 'The new block type has been created.'); // Check that the block type was created in site default language. @@ -73,12 +73,12 @@ public function testCustomBlockTypeCreation() { /** * Tests editing a block type using the UI. */ - public function testCustomBlockTypeEditing() { + public function testBlockContentTypeEditing() { $this->drupalLogin($this->adminUser); // We need two block types to prevent /block/add redirecting. - $this->createCustomBlockType('other'); + $this->createBlockContentType('other'); - $field_definition = \Drupal::entityManager()->getFieldDefinitions('custom_block', 'other')['body']; + $field_definition = \Drupal::entityManager()->getFieldDefinitions('block_content', 'other')['body']; $this->assertEqual($field_definition->getLabel(), 'Body', 'Body field was found.'); // Verify that title and body fields are displayed. @@ -90,7 +90,8 @@ public function testCustomBlockTypeEditing() { $edit = array( 'label' => 'Bar', ); - $this->drupalPostForm('admin/structure/block/custom-blocks/manage/basic', $edit, t('Save')); + $this->drupalPostForm('admin/structure/block/block-content/manage/basic', $edit, t('Save')); + \Drupal::entityManager()->clearCachedFieldDefinitions(); $this->drupalGet('block/add'); $this->assertRaw('Bar', 'New name was displayed.'); @@ -98,9 +99,9 @@ public function testCustomBlockTypeEditing() { $this->assertEqual(url('block/add/basic', array('absolute' => TRUE)), $this->getUrl(), 'Original machine name was used in URL.'); // Remove the body field. - $this->drupalPostForm('admin/structure/block/custom-blocks/manage/basic/fields/custom_block.basic.body/delete', array(), t('Delete')); + $this->drupalPostForm('admin/structure/block/block-content/manage/basic/fields/block_content.basic.body/delete', array(), t('Delete')); // Resave the settings for this type. - $this->drupalPostForm('admin/structure/block/custom-blocks/manage/basic', array(), t('Save')); + $this->drupalPostForm('admin/structure/block/block-content/manage/basic', array(), t('Save')); // Check that the body field doesn't exist. $this->drupalGet('block/add/basic'); $this->assertNoRaw('Body', 'Body field was not found.'); @@ -109,16 +110,16 @@ public function testCustomBlockTypeEditing() { /** * Tests deleting a block type that still has content. */ - public function testCustomBlockTypeDeletion() { + public function testBlockContentTypeDeletion() { // Create a block type programmatically. - $type = $this->createCustomBlockType('foo'); + $type = $this->createBlockContentType('foo'); $this->drupalLogin($this->adminUser); // Add a new block of this type. - $block = $this->createCustomBlock(FALSE, 'foo'); + $block = $this->createBlockContent(FALSE, 'foo'); // Attempt to delete the block type, which should not be allowed. - $this->drupalGet('admin/structure/block/custom-blocks/manage/' . $type->id() . '/delete'); + $this->drupalGet('admin/structure/block/block-content/manage/' . $type->id() . '/delete'); $this->assertRaw( t('%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', array('%label' => $type->label())), 'The block type will not be deleted until all blocks of that type are removed.' @@ -128,7 +129,7 @@ public function testCustomBlockTypeDeletion() { // Delete the block. $block->delete(); // Attempt to delete the block type, which should now be allowed. - $this->drupalGet('admin/structure/block/custom-blocks/manage/' . $type->id() . '/delete'); + $this->drupalGet('admin/structure/block/block-content/manage/' . $type->id() . '/delete'); $this->assertRaw( t('Are you sure you want to delete %type?', array('%type' => $type->id())), 'The block type is available for deletion.' @@ -139,16 +140,16 @@ public function testCustomBlockTypeDeletion() { /** * Tests that redirects work as expected when multiple block types exist. */ - public function testsCustomBlockAddTypes() { + public function testsBlockContentAddTypes() { $this->drupalLogin($this->adminUser); // Create two block types programmatically. - $type = $this->createCustomBlockType('foo'); - $type = $this->createCustomBlockType('bar'); + $type = $this->createBlockContentType('foo'); + $type = $this->createBlockContentType('bar'); // Get the custom block storage. $storage = $this->container ->get('entity.manager') - ->getStorage('custom_block'); + ->getStorage('block_content'); // Enable all themes. theme_enable(array('bartik', 'seven')); @@ -182,7 +183,7 @@ public function testsCustomBlockAddTypes() { $blocks = $storage->loadByProperties(array('info' => $edit['info[0][value]'])); if (!empty($blocks)) { $block = reset($blocks); - $destination = 'admin/structure/block/add/custom_block:' . $block->uuid() . '/' . $theme; + $destination = 'admin/structure/block/add/block_content:' . $block->uuid() . '/' . $theme; $this->assertUrl(url($destination, array('absolute' => TRUE))); $this->drupalPostForm(NULL, array(), t('Save block')); $this->assertUrl(url("admin/structure/block/list/$theme", array('absolute' => TRUE, 'query' => array('block-placement' => drupal_html_class($edit['info[0][value]']))))); @@ -195,14 +196,14 @@ public function testsCustomBlockAddTypes() { // Test that adding a block from the 'custom blocks list' doesn't send you // to the block configure form. - $this->drupalGet('admin/structure/block/custom-blocks'); + $this->drupalGet('admin/structure/block/block-content'); $this->clickLink(t('Add custom block')); $this->clickLink('foo'); $edit = array('info[0][value]' => $this->randomName(8)); $this->drupalPostForm(NULL, $edit, t('Save')); $blocks = $storage->loadByProperties(array('info' => $edit['info[0][value]'])); if (!empty($blocks)) { - $destination = 'admin/structure/block/custom-blocks'; + $destination = 'admin/structure/block/block-content'; $this->assertUrl(url($destination, array('absolute' => TRUE))); } else { diff --git a/core/modules/block/custom_block/src/Tests/PageEditTest.php b/core/modules/block_content/src/Tests/PageEditTest.php similarity index 84% rename from core/modules/block/custom_block/src/Tests/PageEditTest.php rename to core/modules/block_content/src/Tests/PageEditTest.php index 8062fb52be87..3c3512503808 100644 --- a/core/modules/block/custom_block/src/Tests/PageEditTest.php +++ b/core/modules/block_content/src/Tests/PageEditTest.php @@ -2,17 +2,17 @@ /** * @file - * Contains \Drupal\custom_block\Tests\PageEditTest. + * Contains \Drupal\block_content\Tests\PageEditTest. */ -namespace Drupal\custom_block\Tests; +namespace Drupal\block_content\Tests; use Drupal\Core\Language\Language; /** * Tests the block edit functionality. */ -class PageEditTest extends CustomBlockTestBase { +class PageEditTest extends BlockContentTestBase { /** * Declares test information. @@ -40,8 +40,8 @@ public function testPageEdit() { $this->drupalPostForm('block/add/basic', $edit, t('Save')); // Check that the block exists in the database. - $blocks = \Drupal::entityQuery('custom_block')->condition('info', $edit['info[0][value]'])->execute(); - $block = entity_load('custom_block', reset($blocks)); + $blocks = \Drupal::entityQuery('block_content')->condition('info', $edit['info[0][value]'])->execute(); + $block = entity_load('block_content', reset($blocks)); $this->assertTrue($block, 'Custom block found in database.'); // Load the edit page. @@ -65,7 +65,7 @@ public function testPageEdit() { $this->drupalPostForm(NULL, $edit, t('Save')); // Ensure that the block revision has been created. - $revised_block = entity_load('custom_block', $block->id(), TRUE); + $revised_block = entity_load('block_content', $block->id(), TRUE); $this->assertNotIdentical($block->getRevisionId(), $revised_block->getRevisionId(), 'A new revision has been created.'); // Test deleting the block. diff --git a/core/modules/block/custom_block/templates/custom-block-add-list.html.twig b/core/modules/block_content/templates/block-content-add-list.html.twig similarity index 91% rename from core/modules/block/custom_block/templates/custom-block-add-list.html.twig rename to core/modules/block_content/templates/block-content-add-list.html.twig index d2af8e8b6afb..e5a5d972ce62 100644 --- a/core/modules/block/custom_block/templates/custom-block-add-list.html.twig +++ b/core/modules/block_content/templates/block-content-add-list.html.twig @@ -9,7 +9,7 @@ * - link: A link to add a block of this type. * - description: A description of this custom block type. * - * @see template_preprocess_custom_block_add_list() + * @see template_preprocess_block_content_add_list() * * @ingroup themeable */ diff --git a/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.info.yml b/core/modules/block_content/tests/modules/block_content_test/block_content_test.info.yml similarity index 100% rename from core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.info.yml rename to core/modules/block_content/tests/modules/block_content_test/block_content_test.info.yml diff --git a/core/modules/block_content/tests/modules/block_content_test/block_content_test.module b/core/modules/block_content/tests/modules/block_content_test/block_content_test.module new file mode 100644 index 000000000000..d714cb20e237 --- /dev/null +++ b/core/modules/block_content/tests/modules/block_content_test/block_content_test.module @@ -0,0 +1,68 @@ +<?php + +/** + * @file + * A dummy module for testing custom block related hooks. + * + * This is a dummy module that implements custom block related hooks to test API + * interaction with the block_content module. + */ + +use Drupal\block_content\Entity\BlockContent; + +/** + * Implements hook_block_content_view(). + */ +function block_content_test_block_content_view(array &$build, BlockContent $block_content, $view_mode) { + // Add extra content. + $build['extra_content'] = array( + '#markup' => '<blink>Yowser</blink>', + ); +} + +/** + * Implements hook_block_content_presave(). + */ +function block_content_test_block_content_presave(BlockContent $block_content) { + if ($block_content->label() == 'testing_block_content_presave') { + $block_content->setInfo($block_content->label() .'_presave'); + } + // Determine changes. + if (!empty($block_content->original) && $block_content->original->label() == 'test_changes') { + if ($block_content->original->label() != $block_content->label()) { + $block_content->setInfo($block_content->label() .'_presave'); + // Drupal 1.0 release. + $block_content->changed = 979534800; + } + } +} + +/** + * Implements hook_block_content_update(). + */ +function block_content_test_block_content_update(BlockContent $block_content) { + // Determine changes on update. + if (!empty($block_content->original) && $block_content->original->label() == 'test_changes') { + if ($block_content->original->label() != $block_content->label()) { + $block_content->setInfo($block_content->label() .'_update'); + } + } +} + +/** + * Implements hook_block_content_insert(). + * + * This tests saving a block_content on block_content insert. + * + * @see \Drupal\block_content\Tests\BlockContentSaveTest::testBlockContentSaveOnInsert() + */ +function block_content_test_block_content_insert(BlockContent $block_content) { + // Set the block_content title to the block_content ID and save. + if ($block_content->label() == 'new') { + $block_content->setInfo('BlockContent ' . $block_content->id()); + $block_content->save(); + } + if ($block_content->label() == 'fail_creation') { + throw new Exception('Test exception for rollback.'); + } +} diff --git a/core/modules/block_content/tests/modules/block_content_test/block_content_test.routing.yml b/core/modules/block_content/tests/modules/block_content_test/block_content_test.routing.yml new file mode 100644 index 000000000000..c25abf959483 --- /dev/null +++ b/core/modules/block_content/tests/modules/block_content_test/block_content_test.routing.yml @@ -0,0 +1,6 @@ +block_content_test.block_content_view: + path: '/block-content/{block_content}' + defaults: + _entity_view: 'block_content' + requirements: + _entity_access: 'block_content.view' diff --git a/core/modules/block_content/tests/src/Menu/BlockContentLocalTasksTest.php b/core/modules/block_content/tests/src/Menu/BlockContentLocalTasksTest.php new file mode 100644 index 000000000000..c98927800c62 --- /dev/null +++ b/core/modules/block_content/tests/src/Menu/BlockContentLocalTasksTest.php @@ -0,0 +1,94 @@ +<?php + +/** + * @file + * Contains \Drupal\block_content\Tests\Menu\BlockContentLocalTasksTest. + */ + +namespace Drupal\block_content\Tests\Menu; + +use Drupal\Tests\Core\Menu\LocalTaskIntegrationTest; +use Symfony\Component\DependencyInjection\ContainerBuilder; + +/** + * Tests existence of block_content local tasks. + * + * @group Drupal + * @group Block + */ +class BlockContentLocalTasksTest extends LocalTaskIntegrationTest { + + public static function getInfo() { + return array( + 'name' => 'Custom Block local tasks test', + 'description' => 'Test block_content local tasks.', + 'group' => 'Block', + ); + } + + public function setUp() { + $this->directoryList = array( + 'block' => 'core/modules/block', + 'block_content' => 'core/modules/block_content', + ); + parent::setUp(); + + $config_factory = $this->getConfigFactoryStub(array('system.theme' => array( + 'default' => 'test_c', + ))); + + $themes = array(); + $themes['test_a'] = (object) array( + 'status' => 0, + ); + $themes['test_b'] = (object) array( + 'status' => 1, + 'info' => array( + 'name' => 'test_b', + ), + ); + $themes['test_c'] = (object) array( + 'status' => 1, + 'info' => array( + 'name' => 'test_c', + ), + ); + $theme_handler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface'); + $theme_handler->expects($this->any()) + ->method('listInfo') + ->will($this->returnValue($themes)); + + $container = new ContainerBuilder(); + $container->set('config.factory', $config_factory); + $container->set('theme_handler', $theme_handler); + \Drupal::setContainer($container); + } + + /** + * Checks block_content listing local tasks. + * + * @dataProvider getBlockContentListingRoutes + */ + public function testBlockContentListLocalTasks($route) { + $this->assertLocalTasks($route, array( + 0 => array( + 'block.admin_display', + 'block_content.list', + ), + 1 => array( + 'block_content.list_sub', + 'block_content.type_list', + ), + )); + } + + /** + * Provides a list of routes to test. + */ + public function getBlockContentListingRoutes() { + return array( + array('block_content.list', 'block_content.type_list'), + ); + } + +} diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php index acb56469a234..116275bf1821 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php @@ -27,7 +27,7 @@ class ConfigTranslationListUiTest extends WebTestBase { 'block', 'config_translation', 'contact', - 'custom_block', + 'block_content', 'field', 'field_ui', 'menu_ui', @@ -62,7 +62,7 @@ public function setUp() { 'administer blocks', 'administer contact forms', 'administer content types', - 'administer custom_block fields', + 'administer block_content fields', 'administer filters', 'administer menu', 'administer node fields', @@ -187,20 +187,20 @@ protected function doVocabularyListTest() { /** * Tests the custom block listing for the translate operation. */ - public function doCustomBlockTypeListTest() { + public function doCustomContentTypeListTest() { // Create a test custom block type to decouple looking for translate // operations link so this does not test more than necessary. - $custom_block_type = entity_create('custom_block_type', array( + $block_content_type = entity_create('block_content_type', array( 'id' => Unicode::strtolower($this->randomName(16)), 'label' => $this->randomName(), 'revision' => FALSE )); - $custom_block_type->save(); + $block_content_type->save(); // Get the custom block type listing. - $this->drupalGet('admin/structure/block/custom-blocks/types'); + $this->drupalGet('admin/structure/block/block-content/types'); - $translate_link = 'admin/structure/block/custom-blocks/manage/' . $custom_block_type->id() . '/translate'; + $translate_link = 'admin/structure/block/block-content/manage/' . $block_content_type->id() . '/translate'; // Test if the link to translate the custom block type is on the page. $this->assertLinkByHref($translate_link); @@ -404,8 +404,8 @@ public function doFieldListTest() { 'field' => 'node.' . $content_type->id() . '.body', ), array( - 'list' => 'admin/structure/block/custom-blocks/manage/basic/fields', - 'field' => 'custom_block.basic.body', + 'list' => 'admin/structure/block/block-content/manage/basic/fields', + 'field' => 'block_content.basic.body', ), ); @@ -466,7 +466,7 @@ public function testTranslateOperationInListUi() { $this->doBlockListTest(); $this->doMenuListTest(); $this->doVocabularyListTest(); - $this->doCustomBlockTypeListTest(); + $this->doCustomContentTypeListTest(); $this->doContactFormsListTest(); $this->doContentTypeListTest(); $this->doFormatsListTest(); diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_custom_block.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_custom_block.yml index 709d1ea39554..c7dd4ab3871d 100644 --- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_custom_block.yml +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_custom_block.yml @@ -14,7 +14,7 @@ process: source: format 'body.value': body destination: - plugin: entity:custom_block + plugin: entity:block_content migration_dependencies: required: - d6_filter_format diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/process/d6/BlockPluginId.php b/core/modules/migrate_drupal/src/Plugin/migrate/process/d6/BlockPluginId.php index 3f205b2b644b..663b9e6eb7bf 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/process/d6/BlockPluginId.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/process/d6/BlockPluginId.php @@ -32,14 +32,14 @@ class BlockPluginId extends ProcessPluginBase implements ContainerFactoryPluginI /** * @var \Drupal\Core\Entity\EntityStorageInterface */ - protected $customBlockStorage; + protected $blockContentStorage; /** * {@inheritdoc} */ public function __construct(array $configuration, $plugin_id, array $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, MigratePluginManager $process_plugin_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->customBlockStorage = $storage; + $this->blockContentStorage = $storage; $this->migration = $migration; $this->processPluginManager = $process_plugin_manager; } @@ -54,7 +54,7 @@ public static function create(ContainerInterface $container, array $configuratio $plugin_id, $plugin_definition, $migration, - $entity_manager->getDefinition('custom_block') ? $entity_manager->getStorage('custom_block') : NULL, + $entity_manager->getDefinition('block_content') ? $entity_manager->getStorage('block_content') : NULL, $container->get('plugin.manager.migrate.process') ); } @@ -80,11 +80,11 @@ public function transform($value, MigrateExecutable $migrate_executable, Row $ro $value = "system_menu_block:$delta"; break; case 'block': - if ($this->customBlockStorage) { + if ($this->blockContentStorage) { $block_ids = $this->processPluginManager ->createInstance('migration', array('migration' => 'd6_custom_block'), $this->migration) ->transform($delta, $migrate_executable, $row, $destination_property); - $value = 'custom_block:' . $this->customBlockStorage->load($block_ids[0])->uuid(); + $value = 'block_content:' . $this->blockContentStorage->load($block_ids[0])->uuid(); } else { throw new MigrateSkipRowException(); diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateCustomBlockTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockContentTest.php similarity index 84% rename from core/modules/migrate_drupal/src/Tests/d6/MigrateCustomBlockTest.php rename to core/modules/migrate_drupal/src/Tests/d6/MigrateBlockContentTest.php index d48acaf44b2e..4c78605f61a5 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateCustomBlockTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockContentTest.php @@ -2,22 +2,22 @@ /** * @file - * Contains \Drupal\migrate_drupal\Tests\d6\MigrateCustomBlockTest. + * Contains \Drupal\migrate_drupal\Tests\d6\MigrateBlockContentTest. */ namespace Drupal\migrate_drupal\Tests\d6; use Drupal\Core\Language\Language; -use Drupal\custom_block\Entity\CustomBlock; +use Drupal\block_content\Entity\BlockContent; use Drupal\migrate\MigrateExecutable; use Drupal\migrate_drupal\Tests\MigrateDrupalTestBase; /** * Tests the Drupal 6 custom block to Drupal 8 migration. */ -class MigrateCustomBlockTest extends MigrateDrupalTestBase { +class MigrateBlockContentTest extends MigrateDrupalTestBase { - static $modules = array('block', 'custom_block'); + static $modules = array('block', 'block_content'); /** * {@inheritdoc} @@ -54,8 +54,8 @@ public function setUp() { * Tests the Drupal 6 custom block to Drupal 8 migration. */ public function testBlockMigration() { - /** @var CustomBlock $block */ - $block = entity_load('custom_block', 1); + /** @var BlockContent $block */ + $block = entity_load('block_content', 1); $this->assertEqual('My block 1', $block->label()); $this->assertEqual(1, $block->getRevisionId()); $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time()); @@ -63,7 +63,7 @@ public function testBlockMigration() { $this->assertEqual('<h3>My first custom block body</h3>', $block->body->value); $this->assertEqual('full_html', $block->body->format); - $block = entity_load('custom_block', 2); + $block = entity_load('block_content', 2); $this->assertEqual('My block 2', $block->label()); $this->assertEqual(2, $block->getRevisionId()); $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time()); diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockTest.php index bb79dc6134db..800e78493cdc 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateBlockTest.php @@ -25,7 +25,7 @@ class MigrateBlockTest extends MigrateDrupalTestBase { 'views', 'comment', 'menu_ui', - 'custom_block', + 'block_content', 'node', ); @@ -48,8 +48,8 @@ public function setUp() { $entities = array( entity_create('menu', array('id' => 'primary-links')), entity_create('menu', array('id' => 'secondary-links')), - entity_create('custom_block', array('id' => 1, 'type' => 'basic', 'info' => $this->randomName(8))), - entity_create('custom_block', array('id' => 2, 'type' => 'basic', 'info' => $this->randomName(8))), + entity_create('block_content', array('id' => 1, 'type' => 'basic', 'info' => $this->randomName(8))), + entity_create('block_content', array('id' => 2, 'type' => 'basic', 'info' => $this->randomName(8))), ); foreach ($entities as $entity) { $entity->enforceIsNew(TRUE); diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateDrupal6Test.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateDrupal6Test.php index adcf35b01a4d..79f11da968bd 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateDrupal6Test.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateDrupal6Test.php @@ -26,7 +26,7 @@ class MigrateDrupal6Test extends MigrateFullDrupalTestBase { 'book', 'comment', 'contact', - 'custom_block', + 'block_content', 'datetime', 'dblog', 'file', @@ -235,7 +235,7 @@ protected function getTestClassesList() { __NAMESPACE__ . '\MigrateCommentVariableInstance', __NAMESPACE__ . '\MigrateContactCategoryTest', __NAMESPACE__ . '\MigrateContactConfigsTest', - __NAMESPACE__ . '\MigrateCustomBlockTest', + __NAMESPACE__ . '\MigrateBlockContentTest', __NAMESPACE__ . '\MigrateDateFormatTest', __NAMESPACE__ . '\MigrateDblogConfigsTest', __NAMESPACE__ . '\MigrateFieldConfigsTest', diff --git a/core/modules/quickedit/js/quickedit.js b/core/modules/quickedit/js/quickedit.js index 924469461360..98a7e27dad86 100644 --- a/core/modules/quickedit/js/quickedit.js +++ b/core/modules/quickedit/js/quickedit.js @@ -434,7 +434,7 @@ * @param Object contextualLink * An object with the following properties: * - String entityID: a Quick Edit entity identifier, e.g. "node/1" or - * "custom_block/5". + * "block_content/5". * - String entityInstanceID: a Quick Edit entity instance identifier, * e.g. 0, 1 or n (depending on whether it's the first, second, or n+1st * instance of this entity). diff --git a/core/profiles/standard/standard.info.yml b/core/profiles/standard/standard.info.yml index 3f8116b1805e..70297392c11c 100644 --- a/core/profiles/standard/standard.info.yml +++ b/core/profiles/standard/standard.info.yml @@ -15,7 +15,7 @@ dependencies: - contextual - contact - datetime - - custom_block + - block_content - quickedit - editor - entity_reference diff --git a/core/themes/seven/seven.theme b/core/themes/seven/seven.theme index c3e7a32af80c..34c165dee686 100644 --- a/core/themes/seven/seven.theme +++ b/core/themes/seven/seven.theme @@ -136,11 +136,11 @@ function seven_node_add_list($variables) { } /** - * Overrides theme_custom_block_add_list(). + * Overrides theme_block_content_add_list(). * * Displays the list of available custom block types for creation. */ -function seven_custom_block_add_list($variables) { +function seven_block_content_add_list($variables) { $output = ''; if (!empty($variables['types'])) { $output = '<ul class="admin-list">'; @@ -150,7 +150,7 @@ function seven_custom_block_add_list($variables) { $content .= '<div class="description">' . Xss::filterAdmin($type['description']) . '</div>'; $options = $type['localized_options']; $options['html'] = TRUE; - $output .= \Drupal::l($content, 'custom_block.add_form', array('custom_block_type' => $id), $options); + $output .= \Drupal::l($content, 'block_content.add_form', array('block_content_type' => $id), $options); $output .= '</li>'; } $output .= '</ul>'; -- GitLab