diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 37b93bd..ceffa1f 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 .= '
' . 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 Field module help for more information. Once created, custom blocks can be placed like blocks provided by other modules; see the Block module help page for details. For more information, see the online documentation for the Custom Block module.', 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')) . '
'; + $output .= '' . 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 Field module help for more information. Once created, custom blocks can be placed like blocks provided by other modules; see the Block module help page for details. For more information, see the online documentation for the Custom Block module.', 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')) . '
'; $output .= '' . 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.') . '
'; return $output; - case 'custom_block.type_list': + case 'block_content.type_list': $output = '' . 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.') . '
'; 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 f24e16b..d2dc0c4 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/custom_block/custom_block.routing.yml b/core/modules/block_content/block_content.routing.yml similarity index 37% rename from core/modules/block/custom_block/custom_block.routing.yml rename to core/modules/block_content/block_content.routing.yml index cad1f09..b6a1aaf 100644 --- a/core/modules/block/custom_block/custom_block.routing.yml +++ b/core/modules/block_content/block_content.routing.yml @@ -1,80 +1,80 @@ -custom_block.type_list: - path: '/admin/structure/block/custom-blocks/types' +block_content.type_list: + path: '/admin/structure/block/block-content/types' defaults: - _entity_list: 'custom_block_type' + _entity_list: 'block_content_type' _title: 'Edit' requirements: _permission: 'administer blocks' -custom_block.add_page: +block_content.add_page: path: '/block/add' defaults: - _content: '\Drupal\custom_block\Controller\CustomBlockController::add' + _content: '\Drupal\block_content\Controller\BlockContentController::add' _title: 'Add custom block' options: _admin_route: TRUE requirements: _permission: 'administer blocks' -custom_block.add_form: - path: '/block/add/{custom_block_type}' +block_content.add_form: + path: '/block/add/{block_content_type}' defaults: - _content: '\Drupal\custom_block\Controller\CustomBlockController::addForm' - _title_callback: 'Drupal\custom_block\Controller\CustomBlockController::getAddFormTitle' + _content: '\Drupal\block_content\Controller\BlockContentController::addForm' + _title_callback: 'Drupal\block_content\Controller\BlockContentController::getAddFormTitle' options: _admin_route: TRUE requirements: _permission: 'administer blocks' -custom_block.type_delete: - path: '/admin/structure/block/custom-blocks/manage/{custom_block_type}/delete' +block_content.type_delete: + path: '/admin/structure/block/block-content/manage/{block_content_type}/delete' defaults: - _entity_form: 'custom_block_type.delete' + _entity_form: 'block_content_type.delete' _title: 'Delete' requirements: - _entity_access: 'custom_block_type.delete' + _entity_access: 'block_content_type.delete' options: _admin_route: TRUE -custom_block.edit: - path: '/block/{custom_block}' +block_content.edit: + path: '/block/{block_content}' defaults: - _entity_form: 'custom_block.edit' + _entity_form: 'block_content.edit' options: _admin_route: TRUE requirements: - _entity_access: 'custom_block.update' + _entity_access: 'block_content.update' -custom_block.delete: - path: '/block/{custom_block}/delete' +block_content.delete: + path: '/block/{block_content}/delete' defaults: - _entity_form: 'custom_block.delete' + _entity_form: 'block_content.delete' _title: 'Delete' options: _admin_route: TRUE requirements: - _entity_access: 'custom_block.delete' + _entity_access: 'block_content.delete' -custom_block.type_add: - path: '/admin/structure/block/custom-blocks/types/add' +block_content.type_add: + path: '/admin/structure/block/block-content/types/add' defaults: - _entity_form: 'custom_block_type.add' + _entity_form: 'block_content_type.add' _title: 'Add' requirements: _permission: 'administer blocks' -custom_block.type_edit: - path: '/admin/structure/block/custom-blocks/manage/{custom_block_type}' +block_content.type_edit: + path: '/admin/structure/block/block-content/manage/{block_content_type}' defaults: - _entity_form: 'custom_block_type.edit' + _entity_form: 'block_content_type.edit' _title: 'Edit' requirements: - _entity_access: 'custom_block_type.update' + _entity_access: 'block_content_type.update' -custom_block.list: - path: '/admin/structure/block/custom-blocks' +block_content.list: + path: '/admin/structure/block/block-content' defaults: _title: 'Custom block library' - _entity_list: 'custom_block' + _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/custom_block/config/install/entity.view_mode.custom_block.full.yml b/core/modules/block_content/config/install/entity.view_mode.block_content.full.yml similarity index 45% rename from core/modules/block/custom_block/config/install/entity.view_mode.custom_block.full.yml rename to core/modules/block_content/config/install/entity.view_mode.block_content.full.yml index 2987629..c558d54 100644 --- a/core/modules/block/custom_block/config/install/entity.view_mode.custom_block.full.yml +++ b/core/modules/block_content/config/install/entity.view_mode.block_content.full.yml @@ -1,8 +1,8 @@ -id: custom_block.full +id: block_content.full label: Full status: false cache: true -targetEntityType: custom_block +targetEntityType: block_content dependencies: module: - - custom_block + - 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 b655239..d241494 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 8ea3364..a8cd785 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 c1d65be..5709498 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 30f5342..db220d4 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 d6ef5d5..d6f981c 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 5df5a19..731f2da 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/custom_block/src/CustomBlockStorage.php b/core/modules/block_content/src/BlockContentStorage.php similarity index 45% rename from core/modules/block/custom_block/src/CustomBlockStorage.php rename to core/modules/block_content/src/BlockContentStorage.php index b7b8711..f7449e9 100644 --- a/core/modules/block/custom_block/src/CustomBlockStorage.php +++ b/core/modules/block_content/src/BlockContentStorage.php @@ -2,17 +2,17 @@ /** * @file - * Contains \Drupal\custom_block\CustomBlockStorage. + * Contains \Drupal\block_content\BlockContentStorage. */ -namespace Drupal\custom_block; +namespace Drupal\block_content; use Drupal\Core\Entity\ContentEntityDatabaseStorage; /** - * Provides storage for the 'custom_block' entity type. + * Provides storage for the 'block_content' entity type. */ -class CustomBlockStorage extends ContentEntityDatabaseStorage { +class BlockContentStorage extends ContentEntityDatabaseStorage { /** * {@inheritdoc} @@ -22,10 +22,10 @@ public function getSchema() { // Marking the respective fields as NOT NULL makes the indexes more // performant. - $schema['custom_block']['fields']['info']['not null'] = TRUE; + $schema['block_content']['fields']['info']['not null'] = TRUE; - $schema['custom_block']['unique keys'] += array( - 'custom_block__info' => array('info'), + $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 2bdd7f0..148e249 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('Edit @type @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 61567f8..e64bfa3 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/custom_block/src/CustomBlockTypeInterface.php b/core/modules/block_content/src/BlockContentTypeInterface.php similarity index 47% rename from core/modules/block/custom_block/src/CustomBlockTypeInterface.php rename to core/modules/block_content/src/BlockContentTypeInterface.php index 53bfe1b..cb21631 100644 --- a/core/modules/block/custom_block/src/CustomBlockTypeInterface.php +++ b/core/modules/block_content/src/BlockContentTypeInterface.php @@ -2,16 +2,16 @@ /** * @file - * Contains \Drupal\custom_block\Entity\CustomBlockTypeInterface. + * Contains \Drupal\block_content\Entity\BlockContentTypeInterface. */ -namespace Drupal\custom_block; +namespace Drupal\block_content; use Drupal\Core\Config\Entity\ConfigEntityInterface; /** * Provides an interface defining a custom block type entity. */ -interface CustomBlockTypeInterface extends ConfigEntityInterface { +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 723ea71..6cfda1d 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 16e11ee..0977e9f 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 e30c42d..4716bba 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 a91e01e..630fe51 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/custom_block/src/Entity/CustomBlockType.php b/core/modules/block_content/src/Entity/BlockContentType.php similarity index 46% rename from core/modules/block/custom_block/src/Entity/CustomBlockType.php rename to core/modules/block_content/src/Entity/BlockContentType.php index 65dd974..17a358e 100644 --- a/core/modules/block/custom_block/src/Entity/CustomBlockType.php +++ b/core/modules/block_content/src/Entity/BlockContentType.php @@ -2,45 +2,45 @@ /** * @file - * Contains \Drupal\custom_block\Entity\CustomBlockType. + * Contains \Drupal\block_content\Entity\BlockContentType. */ -namespace Drupal\custom_block\Entity; +namespace Drupal\block_content\Entity; use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\Core\Config\Entity\ConfigEntityBundleBase; use Drupal\Core\Entity\EntityStorageInterface; -use Drupal\custom_block\CustomBlockTypeInterface; +use Drupal\block_content\BlockContentTypeInterface; /** * Defines the custom block type entity. * * @ConfigEntityType( - * id = "custom_block_type", + * id = "block_content_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" + * "default" = "Drupal\block_content\BlockContentTypeForm", + * "add" = "Drupal\block_content\BlockContentTypeForm", + * "edit" = "Drupal\block_content\BlockContentTypeForm", + * "delete" = "Drupal\block_content\Form\BlockContentTypeDeleteForm" * }, - * "list_builder" = "Drupal\custom_block\CustomBlockTypeListBuilder" + * "list_builder" = "Drupal\block_content\BlockContentTypeListBuilder" * }, * admin_permission = "administer blocks", * config_prefix = "type", - * bundle_of = "custom_block", + * bundle_of = "block_content", * entity_keys = { * "id" = "id", * "label" = "label" * }, * links = { - * "delete-form" = "custom_block.type_delete", - * "edit-form" = "custom_block.type_edit" + * "delete-form" = "block_content.type_delete", + * "edit-form" = "block_content.type_edit" * } * ) */ -class CustomBlockType extends ConfigEntityBundleBase implements CustomBlockTypeInterface { +class BlockContentType extends ConfigEntityBundleBase implements BlockContentTypeInterface { /** * The custom block type ID. @@ -77,10 +77,25 @@ 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()) { - custom_block_add_body_field($this->id); + 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 11d3935..35c0386 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 c57d2ad..7e196ee 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 = '' . 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())) . '
'; $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 5ef3ec2..9f3d92d 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/custom_block/src/Plugin/Derivative/CustomBlock.php b/core/modules/block_content/src/Plugin/Derivative/BlockContent.php similarity index 47% rename from core/modules/block/custom_block/src/Plugin/Derivative/CustomBlock.php rename to core/modules/block_content/src/Plugin/Derivative/BlockContent.php index f93b413..a7c1784 100644 --- a/core/modules/block/custom_block/src/Plugin/Derivative/CustomBlock.php +++ b/core/modules/block_content/src/Plugin/Derivative/BlockContent.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\Plugin\Derivative\CustomBlock. + * Contains \Drupal\block_content\Plugin\Derivative\BlockContent. */ -namespace Drupal\custom_block\Plugin\Derivative; +namespace Drupal\block_content\Plugin\Derivative; use Drupal\Component\Plugin\Derivative\DerivativeBase; use Drupal\Core\Plugin\Discovery\ContainerDerivativeInterface; @@ -13,15 +13,15 @@ /** * Retrieves block plugin definitions for all custom blocks. */ -class CustomBlock extends DerivativeBase { +class BlockContent 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(); + $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 af9b359..e22425e 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 cfd87a9..52c3286 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 0ae892a..dd98507 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 63a8911..65c08c5 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 8bded49..048fdfb 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 fafb357..b8edb11 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 b2be3c4..0de498f 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 bae766a..03d0857 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 cf731fc..4f77de4 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 @@ * * @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 761936e..35cf5ec 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 c9c9187..fc20f0c 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 8062fb5..3c35125 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 d2af8e8..e5a5d97 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/custom_block/tests/modules/custom_block_test/custom_block_test.module b/core/modules/block_content/tests/modules/block_content_test/block_content_test.module similarity index 23% rename from core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module rename to core/modules/block_content/tests/modules/block_content_test/block_content_test.module index 65e9c56..d714cb2 100644 --- a/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module +++ b/core/modules/block_content/tests/modules/block_content_test/block_content_test.module @@ -5,15 +5,15 @@ * 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. + * interaction with the block_content module. */ -use Drupal\custom_block\Entity\CustomBlock; +use Drupal\block_content\Entity\BlockContent; /** - * Implements hook_custom_block_view(). + * Implements hook_block_content_view(). */ -function custom_block_test_custom_block_view(array &$build, CustomBlock $custom_block, $view_mode) { +function block_content_test_block_content_view(array &$build, BlockContent $block_content, $view_mode) { // Add extra content. $build['extra_content'] = array( '#markup' => '', @@ -21,48 +21,48 @@ function custom_block_test_custom_block_view(array &$build, CustomBlock $custom_ } /** - * Implements hook_custom_block_presave(). + * Implements hook_block_content_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'); +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($custom_block->original) && $custom_block->original->label() == 'test_changes') { - if ($custom_block->original->label() != $custom_block->label()) { - $custom_block->setInfo($custom_block->label() .'_presave'); + 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. - $custom_block->changed = 979534800; + $block_content->changed = 979534800; } } } /** - * Implements hook_custom_block_update(). + * Implements hook_block_content_update(). */ -function custom_block_test_custom_block_update(CustomBlock $custom_block) { +function block_content_test_block_content_update(BlockContent $block_content) { // 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'); + 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_custom_block_insert(). + * Implements hook_block_content_insert(). * - * This tests saving a custom_block on custom_block insert. + * This tests saving a block_content on block_content insert. * - * @see \Drupal\custom_block\Tests\CustomBlockSaveTest::testCustomBlockSaveOnInsert() + * @see \Drupal\block_content\Tests\BlockContentSaveTest::testBlockContentSaveOnInsert() */ -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(); +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 ($custom_block->label() == 'fail_creation') { + if ($block_content->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_content/tests/modules/block_content_test/block_content_test.routing.yml similarity index 15% rename from core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.routing.yml rename to core/modules/block_content/tests/modules/block_content_test/block_content_test.routing.yml index a7ca068..c25abf9 100644 --- a/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.routing.yml +++ b/core/modules/block_content/tests/modules/block_content_test/block_content_test.routing.yml @@ -1,6 +1,6 @@ -custom_block_test.custom_block_view: - path: '/custom-block/{custom_block}' +block_content_test.block_content_view: + path: '/block-content/{block_content}' defaults: - _entity_view: 'custom_block' + _entity_view: 'block_content' requirements: - _entity_access: 'custom_block.view' + _entity_access: 'block_content.view' diff --git a/core/modules/block/custom_block/tests/src/Menu/CustomBlockLocalTasksTest.php b/core/modules/block_content/tests/src/Menu/BlockContentLocalTasksTest.php similarity index 27% rename from core/modules/block/custom_block/tests/src/Menu/CustomBlockLocalTasksTest.php rename to core/modules/block_content/tests/src/Menu/BlockContentLocalTasksTest.php index d04ad15..c989278 100644 --- a/core/modules/block/custom_block/tests/src/Menu/CustomBlockLocalTasksTest.php +++ b/core/modules/block_content/tests/src/Menu/BlockContentLocalTasksTest.php @@ -2,25 +2,26 @@ /** * @file - * Contains \Drupal\custom_block\Tests\Menu\CustomBlockLocalTasksTest. + * Contains \Drupal\block_content\Tests\Menu\BlockContentLocalTasksTest. */ -namespace Drupal\custom_block\Tests\Menu; +namespace Drupal\block_content\Tests\Menu; use Drupal\Tests\Core\Menu\LocalTaskIntegrationTest; +use Symfony\Component\DependencyInjection\ContainerBuilder; /** - * Tests existence of custom_block local tasks. + * Tests existence of block_content local tasks. * * @group Drupal * @group Block */ -class CustomBlockLocalTasksTest extends LocalTaskIntegrationTest { +class BlockContentLocalTasksTest extends LocalTaskIntegrationTest { public static function getInfo() { return array( 'name' => 'Custom Block local tasks test', - 'description' => 'Test custom_block local tasks.', + 'description' => 'Test block_content local tasks.', 'group' => 'Block', ); } @@ -28,36 +29,65 @@ public static function getInfo() { public function setUp() { $this->directoryList = array( 'block' => 'core/modules/block', - 'custom_block' => 'core/modules/block/custom_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 custom_block listing local tasks. + * Checks block_content listing local tasks. * - * @dataProvider getCustomBlockListingRoutes + * @dataProvider getBlockContentListingRoutes */ - public function testCustomBlockListLocalTasks($route) { - // + public function testBlockContentListLocalTasks($route) { $this->assertLocalTasks($route, array( 0 => array( 'block.admin_display', - 'custom_block.list', + 'block_content.list', ), 1 => array( - 'custom_block.list_sub', - 'custom_block.type_list', - ) + 'block_content.list_sub', + 'block_content.type_list', + ), )); } /** * Provides a list of routes to test. */ - public function getCustomBlockListingRoutes() { + public function getBlockContentListingRoutes() { return array( - array('custom_block.list', 'custom_block.type_list'), + 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 acb5646..116275b 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 709d1ea..c7dd4ab 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 3f205b2..663b9e6 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 d48acaf..4c78605 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('