diff --git a/core/modules/block/block.install b/core/modules/block/block.install index b1fc925..5e9a026 100644 --- a/core/modules/block/block.install +++ b/core/modules/block/block.install @@ -190,23 +190,23 @@ function block_update_8005() { * Enable the Custom Block module. */ function block_update_8006() { - update_module_enable(array('custom_block')); + update_module_enable(array('block_custom')); } /** - * Migrate {block_custom} to {custom_block}. + * Migrate {block_custom} to {block_custom}. * - * Note this table now resides in custom_block_schema() but for 7.x to 8.x - * upgrades, changes must be made from block module as custom_block module is + * Note this table now resides in block_custom_schema() but for 7.x to 8.x + * upgrades, changes must be made from block module as block_custom module is * only enabled during upgrade process. */ function block_update_8007() { - // Populate the {custom_block} and {custom_block_revision} table. + // Populate the {block_custom} and {block_custom_revision} table. $results = db_select('block_custom', 'bc')->fields('bc')->execute(); $uuid = new Uuid(); $execute = FALSE; - $block_insert = db_insert('custom_block')->fields(array( + $block_insert = db_insert('block_custom')->fields(array( 'id', 'uuid', 'info', @@ -214,7 +214,7 @@ function block_update_8007() { 'langcode', 'type' )); - $revision_insert = db_insert('custom_block_revision')->fields(array( + $revision_insert = db_insert('block_custom_revision')->fields(array( 'id', 'revision_id', 'log', @@ -259,7 +259,7 @@ function block_update_8008() { $body_field = array( 'field_name' => 'block_body', 'type' => 'text_with_summary', - 'entity_types' => array('custom_block'), + 'entity_types' => array('block_custom'), 'module' => 'text', 'cardinality' => 1, ); @@ -267,7 +267,7 @@ function block_update_8008() { $instance = array( 'field_name' => 'block_body', - 'entity_type' => 'custom_block', + 'entity_type' => 'block_custom', 'bundle' => 'basic', 'label' => 'Block body', 'widget' => array('type' => 'text_textarea_with_summary'), @@ -313,7 +313,7 @@ function block_update_8008() { ); // This is a core update and no contrib modules are enabled yet, so // we can assume default field storage for a faster update. - _update_7000_field_sql_storage_write('custom_block', 'basic', $block->bid, $block->bid, 'block_body', $data); + _update_7000_field_sql_storage_write('block_custom', 'basic', $block->bid, $block->bid, 'block_body', $data); $sandbox['last'] = $block->bid; $sandbox['count'] += 1; diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 18b9d27..1814bb1 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -57,9 +57,9 @@ function block_help($path, $arg) { $output .= '
' . t('When working with blocks, remember that all themes do not implement the same regions, or display regions in the same way. Blocks are positioned on a per-theme basis. Users with the Administer blocks permission can disable blocks. Disabled blocks are listed on the Blocks administration page, but are not displayed in any region.', array('@block' => 'http://drupal.org/documentation/modules/block', '@blocks' => url('admin/structure/block'))) . '
'; $output .= '
' . t('Controlling visibility') . '
'; $output .= '
' . t('Blocks can be configured to be visible only on certain pages, only to users of certain roles, or only on pages displaying certain content types. Some dynamic blocks, such as those generated by modules, will be displayed only on certain pages.', array('@content-type' => url('admin/structure/types'), '@user' => url('user'))) . '
'; - if (module_exists('custom_block')) { + if (module_exists('block_custom')) { $output .= '
' . t('Creating custom blocks') . '
'; - $output .= '
' . t('Users with the Administer blocks permission can add custom blocks, which are then listed on the Blocks administration page. Once created, custom blocks behave just like default and module-generated blocks.', array('@blocks' => url('admin/structure/block'), '@block-add' => url('admin/structure/block/list/block_plugin_ui:' . config('system.theme')->get('default') . '/add/custom_blocks'))) . '
'; + $output .= '
' . t('Users with the Administer blocks permission can add custom blocks, which are then listed on the Blocks administration page. Once created, custom blocks behave just like default and module-generated blocks.', array('@blocks' => url('admin/structure/block'), '@block-add' => url('admin/structure/block/list/block_plugin_ui:' . config('system.theme')->get('default') . '/add/block_customs'))) . '
'; } $output .= ''; return $output; diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockLoadHooksTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockLoadHooksTest.php deleted file mode 100644 index 717d659..0000000 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockLoadHooksTest.php +++ /dev/null @@ -1,70 +0,0 @@ - 'Custom Block load hooks', - 'description' => 'Test the hooks invoked when a custom block is being loaded.', - 'group' => 'Custom Block', - ); - } - - /** - * Tests that hook_custom_block_load() is invoked correctly. - */ - public function testHookCustomBlockLoad() { - $other_bundle = $this->createCustomBlockType('other'); - // Create some sample articles and pages. - $custom_block1 = $this->createCustomBlock(); - $custom_block2 = $this->createCustomBlock(); - $custom_block3 = $this->createCustomBlock(); - $custom_block4 = $this->createCustomBlock(FALSE, $other_bundle->id()); - - // Check that when a set of custom blocks that only contains basic blocks is - // loaded, the properties added to the custom block by - // custom_block_test_load_custom_block() correctly reflect the expected - // values. - $custom_blocks = entity_load_multiple_by_properties('custom_block', array('type' => 'basic')); - $loaded_custom_block = end($custom_blocks); - $this->assertEqual($loaded_custom_block->custom_block_test_loaded_ids, array( - $custom_block1->id->value, - $custom_block2->id->value, - $custom_block3->id->value - ), 'hook_custom_block_load() received the correct list of custom_block IDs the first time it was called.'); - $this->assertEqual($loaded_custom_block->custom_block_test_loaded_types, array('basic'), 'hook_custom_block_load() received the correct list of custom block types the first time it was called.'); - - // Now, as part of the same page request, load a set of custom_blocks that contain - // both basic and other bundle, and make sure the parameters passed to - // custom_block_test_custom_block_load() are correctly updated. - $custom_blocks = entity_load_multiple('custom_block', entity_query('custom_block')->execute(), TRUE); - $loaded_custom_block = end($custom_blocks); - $this->assertEqual($loaded_custom_block->custom_block_test_loaded_ids, array( - $custom_block1->id->value, - $custom_block2->id->value, - $custom_block3->id->value, - $custom_block4->id->value - ), 'hook_custom_block_load() received the correct list of custom_block IDs the second time it was called.'); - $this->assertEqual($loaded_custom_block->custom_block_test_loaded_types, array('basic', 'other'), 'hook_custom_block_load() received the correct list of custom_block types the second time it was called.'); - } -} diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php index e9c5f18..3cb3372 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php @@ -16,7 +16,7 @@ class BlockTest extends WebTestBase { * * @var array */ - public static $modules = array('block', 'custom_block', 'test_page_test'); + public static $modules = array('block', 'block_custom', 'test_page_test'); protected $regions; protected $adminUser; @@ -169,7 +169,7 @@ public function testCustomBlockFormat() { ); $this->drupalPost('block/add/basic', $values, t('Save')); // Load the block up from the database. - $blocks = entity_load_multiple('custom_block'); + $blocks = entity_load_multiple('block_custom'); $loaded_block = end($blocks); $custom_block['machine_name'] = $info; $custom_block['label'] = $this->randomName(8); diff --git a/core/modules/block/custom_block/custom_block.admin.inc b/core/modules/block_custom/block_custom.admin.inc similarity index 67% rename from core/modules/block/custom_block/custom_block.admin.inc rename to core/modules/block_custom/block_custom.admin.inc index 3451e5d..9bbe525 100644 --- a/core/modules/block/custom_block/custom_block.admin.inc +++ b/core/modules/block_custom/block_custom.admin.inc @@ -5,7 +5,7 @@ * Admin page callbacks for the custom block module. */ -use Drupal\custom_block\Plugin\Core\Entity\CustomBlockType; +use Drupal\block_custom\Plugin\Core\Entity\CustomBlockType; /** * Page callback: Lists custom block types. @@ -13,10 +13,10 @@ * @return array * A build array in the format expected by drupal_render(). * - * @see custom_block_menu() + * @see block_custom_menu() */ -function custom_block_type_list() { - return drupal_container()->get('plugin.manager.entity')->getListController('custom_block_type')->render(); +function block_custom_type_list() { + return drupal_container()->get('plugin.manager.entity')->getListController('block_custom_type')->render(); } /** @@ -25,41 +25,41 @@ function custom_block_type_list() { * @return array * A form array as expected by drupal_render(). * - * @see custom_block_menu() + * @see block_custom_menu() */ -function custom_block_type_add() { - $block_type = entity_create('custom_block_type', array()); +function block_custom_type_add() { + $block_type = entity_create('block_custom_type', array()); return entity_get_form($block_type); } /** * Page callback: Presents the custom block type edit form. * - * @param \Drupal\custom_block\Plugin\Core\Entity\CustomBlockType $block_type + * @param \Drupal\block_custom\Plugin\Core\Entity\CustomBlockType $block_type * The custom block type to edit. * * @return array * A form array as expected by drupal_render(). * - * @see custom_block_menu() + * @see block_custom_menu() */ -function custom_block_type_edit(CustomBlockType $block_type) { +function block_custom_type_edit(CustomBlockType $block_type) { return entity_get_form($block_type); } /** * Page callback: Form constructor for the custom block type deletion form. * - * @param \Drupal\custom_block\Plugin\Core\Entity\CustomBlockType $block_type + * @param \Drupal\block_custom\Plugin\Core\Entity\CustomBlockType $block_type * The custom block type to be deleted. * - * @see custom_block_menu() - * @see custom_block_type_delete_form_submit() + * @see block_custom_menu() + * @see block_custom_type_delete_form_submit() * * @ingroup forms */ -function custom_block_type_delete_form($form, &$form_state, CustomBlockType $block_type) { - $form_state['custom_block_type'] = $block_type; +function block_custom_type_delete_form($form, &$form_state, CustomBlockType $block_type) { + $form_state['block_custom_type'] = $block_type; $form['id'] = array( '#type' => 'value', '#value' => $block_type->id(), @@ -67,7 +67,7 @@ function custom_block_type_delete_form($form, &$form_state, CustomBlockType $blo $message = t('Are you sure you want to delete %label?', array('%label' => $block_type->label())); - $blocks = entity_query('custom_block')->condition('type', $block_type->id())->execute(); + $blocks = entity_query('block_custom')->condition('type', $block_type->id())->execute(); if (!empty($blocks)) { drupal_set_title($message, PASS_THROUGH); $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' => $block_type->label())) . '

'; @@ -85,14 +85,14 @@ function custom_block_type_delete_form($form, &$form_state, CustomBlockType $blo } /** - * Form submission handler for custom_block_type_delete_form(). + * Form submission handler for block_custom_type_delete_form(). */ -function custom_block_type_delete_form_submit($form, &$form_state) { - $block_type = $form_state['custom_block_type']; +function block_custom_type_delete_form_submit($form, &$form_state) { + $block_type = $form_state['block_custom_type']; $block_type->delete(); drupal_set_message(t('Custom block type %label has been deleted.', array('%label' => $block_type->label()))); - watchdog('custom_block', 'Custom block type %label has been deleted.', array('%label' => $block_type->label()), WATCHDOG_NOTICE); + watchdog('block_custom', 'Custom block type %label has been deleted.', array('%label' => $block_type->label()), WATCHDOG_NOTICE); $form_state['redirect'] = 'admin/structure/custom-blocks'; } diff --git a/core/modules/block/custom_block/custom_block.info.yml b/core/modules/block_custom/block_custom.info.yml similarity index 100% rename from core/modules/block/custom_block/custom_block.info.yml rename to core/modules/block_custom/block_custom.info.yml diff --git a/core/modules/block/custom_block/custom_block.install b/core/modules/block_custom/block_custom.install similarity index 89% rename from core/modules/block/custom_block/custom_block.install rename to core/modules/block_custom/block_custom.install index 0e87811..ab0293f 100644 --- a/core/modules/block/custom_block/custom_block.install +++ b/core/modules/block_custom/block_custom.install @@ -8,16 +8,16 @@ /** * Implements hook_schema(). */ -function custom_block_schema() { +function block_custom_schema() { $schema = array(); - $schema['custom_block'] = array( + $schema['block_custom'] = array( 'description' => 'Stores contents of custom-made blocks.', 'fields' => array( 'id' => array( 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, - 'description' => "The block's {custom_block}.id.", + 'description' => "The block's {block_custom}.id.", ), 'uuid' => array( 'description' => 'Unique Key: Universally unique identifier for this entity.', @@ -66,14 +66,14 @@ function custom_block_schema() { 'info' => array('info'), ), 'foreign keys' => array( - 'custom_block_revision' => array( - 'table' => 'custom_block_revision', + 'block_custom_revision' => array( + 'table' => 'block_custom_revision', 'columns' => array('revision_id' => 'revision_id'), ), ), ); - $schema['custom_block_revision'] = array( + $schema['block_custom_revision'] = array( 'description' => 'Stores contents of custom-made blocks.', 'fields' => array( 'id' => array( @@ -81,7 +81,7 @@ function custom_block_schema() { 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - 'description' => "The block's {custom_block}.id.", + 'description' => "The block's {block_custom}.id.", ), // Defaults to NULL in order to avoid a brief period of potential // deadlocks on the index. @@ -113,16 +113,16 @@ function custom_block_schema() { /** * Implements hook_schema_0(). */ -function custom_block_schema_0() { +function block_custom_schema_0() { $schema = array(); - $schema['custom_block'] = array( + $schema['block_custom'] = array( 'description' => 'Stores contents of custom-made blocks.', 'fields' => array( 'id' => array( 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, - 'description' => "The block's {custom_block}.id.", + 'description' => "The block's {block_custom}.id.", ), 'uuid' => array( 'description' => 'Unique Key: Universally unique identifier for this entity.', @@ -171,14 +171,14 @@ function custom_block_schema_0() { 'info' => array('info'), ), 'foreign keys' => array( - 'custom_block_revision' => array( - 'table' => 'custom_block_revision', + 'block_custom_revision' => array( + 'table' => 'block_custom_revision', 'columns' => array('revision_id' => 'revision_id'), ), ), ); - $schema['custom_block_revision'] = array( + $schema['block_custom_revision'] = array( 'description' => 'Stores contents of custom-made blocks.', 'fields' => array( 'id' => array( @@ -186,7 +186,7 @@ function custom_block_schema_0() { 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - 'description' => "The block's {custom_block}.id.", + 'description' => "The block's {block_custom}.id.", ), // Defaults to NULL in order to avoid a brief period of potential // deadlocks on the index. diff --git a/core/modules/block/custom_block/custom_block.js b/core/modules/block_custom/block_custom.js similarity index 88% rename from core/modules/block/custom_block/custom_block.js rename to core/modules/block_custom/block_custom.js index fb0905a..f787779 100644 --- a/core/modules/block/custom_block/custom_block.js +++ b/core/modules/block_custom/block_custom.js @@ -1,6 +1,6 @@ /** * @file - * Defines Javascript behaviors for the custom_block module. + * Defines Javascript behaviors for the block_custom module. */ (function ($) { @@ -10,7 +10,7 @@ Drupal.behaviors.customBlockDetailsSummaries = { attach: function (context) { var $context = $(context); - $context.find('.custom-block-form-revision-information').drupalSetSummary(function (context) { + $context.find('.block-custom-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-custom-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/custom_block.module b/core/modules/block_custom/block_custom.module similarity index 67% rename from core/modules/block/custom_block/custom_block.module rename to core/modules/block_custom/block_custom.module index a3ce18c..90bc50b 100644 --- a/core/modules/block/custom_block/custom_block.module +++ b/core/modules/block_custom/block_custom.module @@ -5,15 +5,15 @@ * Allows the creaation of custom blocks through the user interface. */ -use Drupal\custom_block\Plugin\Core\Entity\CustomBlockType; -use Drupal\custom_block\Plugin\Core\Entity\CustomBlock; -use Drupal\custom_block\Plugin\block\block\CustomBlockBlock; +use Drupal\block_custom\Plugin\Core\Entity\CustomBlockType; +use Drupal\block_custom\Plugin\Core\Entity\CustomBlock; +use Drupal\block_custom\Plugin\block\block\CustomBlockBlock; use Drupal\block\Plugin\Core\Entity\Block; /** * Implements hook_menu_local_tasks(). */ -function custom_block_menu_local_tasks(&$data, $router_item, $root_path) { +function block_custom_menu_local_tasks(&$data, $router_item, $root_path) { // Add the "Add custom block" action link to the theme-specific block library // listing page. // @todo This should just be $root_path == 'admin/structure/block/list/%/add' @@ -32,86 +32,86 @@ function custom_block_menu_local_tasks(&$data, $router_item, $root_path) { /** * Implements hook_menu(). */ -function custom_block_menu() { +function block_custom_menu() { $items['admin/structure/custom-blocks'] = array( 'title' => 'Custom block types', 'description' => 'Manage custom block types.', - 'page callback' => 'custom_block_type_list', + 'page callback' => 'block_custom_type_list', 'access arguments' => array('administer blocks'), - 'file' => 'custom_block.admin.inc', + 'file' => 'block_custom.admin.inc', ); $items['admin/structure/custom-blocks/add'] = array( 'title' => 'Add custom block type', - 'page callback' => 'custom_block_type_add', + 'page callback' => 'block_custom_type_add', 'access arguments' => array('administer blocks'), 'type' => MENU_LOCAL_ACTION, 'weight' => 1, - 'file' => 'custom_block.admin.inc', + 'file' => 'block_custom.admin.inc', ); - $items['admin/structure/custom-blocks/manage/%custom_block_type'] = array( + $items['admin/structure/custom-blocks/manage/%block_custom_type'] = array( 'title' => 'Edit custom block type', 'title callback' => 'entity_page_label', 'title arguments' => array(4), - 'page callback' => 'custom_block_type_edit', + 'page callback' => 'block_custom_type_edit', 'page arguments' => array(4), 'access arguments' => array('administer blocks'), - 'file' => 'custom_block.admin.inc', + 'file' => 'block_custom.admin.inc', ); - $items['admin/structure/custom-blocks/manage/%custom_block_type/edit'] = array( + $items['admin/structure/custom-blocks/manage/%block_custom_type/edit'] = array( 'title' => 'Edit', 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10, ); - $items['admin/structure/custom-blocks/manage/%custom_block_type/delete'] = array( + $items['admin/structure/custom-blocks/manage/%block_custom_type/delete'] = array( 'title' => 'Delete', 'page callback' => 'drupal_get_form', - 'page arguments' => array('custom_block_type_delete_form', 4), + 'page arguments' => array('block_custom_type_delete_form', 4), 'access arguments' => array('administer blocks'), 'type' => MENU_LOCAL_TASK, 'weight' => 10, - 'file' => 'custom_block.admin.inc', + 'file' => 'block_custom.admin.inc', ); $items['block/add'] = array( 'title' => 'Add custom block', - 'page callback' => 'custom_block_add_page', + 'page callback' => 'block_custom_add_page', 'access arguments' => array('administer blocks'), - 'file' => 'custom_block.pages.inc', + 'file' => 'block_custom.pages.inc', ); - $items['block/add/%custom_block_type'] = array( + $items['block/add/%block_custom_type'] = array( 'title callback' => 'entity_page_label', 'title arguments' => array(2), - 'page callback' => 'custom_block_add', + 'page callback' => 'block_custom_add', 'page arguments' => array(2), 'access arguments' => array('administer blocks'), 'description' => 'Add custom block', - 'file' => 'custom_block.pages.inc', + 'file' => 'block_custom.pages.inc', ); // There has to be a base-item in order for contextual links to work. - $items['block/%custom_block'] = array( + $items['block/%block_custom'] = array( 'title' => 'Edit', - 'page callback' => 'custom_block_edit', + 'page callback' => 'block_custom_edit', 'page arguments' => array(1), 'access callback' => 'entity_page_access', 'access arguments' => array(1, 'update'), - 'file' => 'custom_block.pages.inc', + 'file' => 'block_custom.pages.inc', ); - $items['block/%custom_block/edit'] = array( + $items['block/%block_custom/edit'] = array( 'title' => 'Edit', 'weight' => 0, 'type' => MENU_DEFAULT_LOCAL_TASK, 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, ); - $items['block/%custom_block/delete'] = array( + $items['block/%block_custom/delete'] = array( 'title' => 'Delete', 'page callback' => 'drupal_get_form', - 'page arguments' => array('custom_block_delete_form', 1), + 'page arguments' => array('block_custom_delete_form', 1), 'access callback' => 'entity_page_access', 'access arguments' => array(1, 'delete'), 'weight' => 1, 'type' => MENU_LOCAL_TASK, 'context' => MENU_CONTEXT_INLINE, - 'file' => 'custom_block.pages.inc', + 'file' => 'block_custom.pages.inc', ); return $items; } @@ -119,14 +119,14 @@ function custom_block_menu() { /** * Implements hook_theme(). */ -function custom_block_theme($existing, $type, $theme, $path) { +function block_custom_theme($existing, $type, $theme, $path) { return array( - 'custom_block_block' => array( + 'block_block_custom' => array( 'variables' => array('body' => NULL, 'format' => NULL), ), - 'custom_block_add_list' => array( + 'block_custom_add_list' => array( 'variables' => array('content' => NULL), - 'file' => 'custom_block.pages.inc', + 'file' => 'block_custom.pages.inc', ), ); } @@ -136,7 +136,7 @@ function custom_block_theme($existing, $type, $theme, $path) { * * @ingroup themeable */ -function theme_custom_block_block($variables) { +function theme_block_block_custom($variables) { $body = $variables['body']; $format = $variables['format']; @@ -149,11 +149,11 @@ function theme_custom_block_block($variables) { * @param int $id * The ID of the custom block type to load. * - * @return Drupal\custom_block\Plugin\Core\Entity\CustomBlockType|false + * @return Drupal\block_custom\Plugin\Core\Entity\CustomBlockType|false * A CustomBlockType object or FALSE if the requested $id does not exist. */ -function custom_block_type_load($id) { - return entity_load('custom_block_type', $id); +function block_custom_type_load($id) { + return entity_load('block_custom_type', $id); } /** @@ -162,31 +162,31 @@ function custom_block_type_load($id) { * @param int $id * The id of the custom block. * - * @return Drupal\custom_block\Plugin\Core\Entity\CustomBlock|false + * @return Drupal\block_custom\Plugin\Core\Entity\CustomBlock|false * A CustomBlock object or FALSE if the requested $id does not exist. */ -function custom_block_load($id) { - return entity_load('custom_block', $id); +function block_custom_load($id) { + return entity_load('block_custom', $id); } /** * Implements hook_entity_info_alter(). */ -function custom_block_entity_info_alter(&$types) { +function block_custom_entity_info_alter(&$types) { // Add a translation handler for fields if the language module is enabled. if (module_exists('language')) { - $types['custom_block']['translation']['custom_block'] = TRUE; + $types['block_custom']['translation']['block_custom'] = TRUE; } } /** * Implements hook_entity_bundle_info(). */ -function custom_block_entity_bundle_info() { +function block_custom_entity_bundle_info() { $bundles = array(); - foreach (config_get_storage_names_with_prefix('custom_block.type.') as $config_name) { + foreach (config_get_storage_names_with_prefix('block_custom.type.') as $config_name) { $config = config($config_name); - $bundles['custom_block'][$config->get('id')] = array( + $bundles['block_custom'][$config->get('id')] = array( 'label' => $config->get('label'), 'admin' => array( 'path' => 'admin/structure/custom-blocks/manage/%', @@ -201,8 +201,8 @@ function custom_block_entity_bundle_info() { /** * Implements hook_entity_view_mode_info(). */ -function custom_block_entity_view_mode_info() { - $view_modes['custom_block']['full'] = array( +function block_custom_entity_view_mode_info() { + $view_modes['block_custom']['full'] = array( 'label' => t('Full'), ); return $view_modes; @@ -219,22 +219,22 @@ function custom_block_entity_view_mode_info() { * @return array() * Body field instance. */ -function custom_block_add_body_field($block_type_id, $label = 'Block body') { +function block_custom_add_body_field($block_type_id, $label = 'Block body') { // Add or remove the body field, as needed. $field = field_info_field('block_body'); - $instance = field_info_instance('custom_block', 'block_body', $block_type_id); + $instance = field_info_instance('block_custom', 'block_body', $block_type_id); if (empty($field)) { $field = array( 'field_name' => 'block_body', 'type' => 'text_with_summary', - 'entity_types' => array('custom_block'), + 'entity_types' => array('block_custom'), ); $field = field_create_field($field); } if (empty($instance)) { $instance = array( 'field_name' => 'block_body', - 'entity_type' => 'custom_block', + 'entity_type' => 'block_custom', 'bundle' => $block_type_id, 'label' => $label, 'widget' => array('type' => 'text_textarea_with_summary'), @@ -243,7 +243,7 @@ function custom_block_add_body_field($block_type_id, $label = 'Block body') { $instance = field_create_instance($instance); // Assign display settings for 'default' view mode. - entity_get_display('custom_block', $block_type_id, 'default') + entity_get_display('block_custom', $block_type_id, 'default') ->setComponent('block_body', array( 'label' => 'hidden', 'type' => 'text_default', @@ -257,17 +257,17 @@ function custom_block_add_body_field($block_type_id, $label = 'Block body') { /** * Implements hook_form_FORM_ID_alter() for block_plugin_ui(). */ -function custom_block_form_block_plugin_ui_alter(&$form, $form_state) { +function block_custom_form_block_plugin_ui_alter(&$form, $form_state) { foreach ($form['left']['plugin_library']['#rows'] as $plugin_id => &$row) { // @todo Clean up when http://drupal.org/node/1874498 lands. if (strpos($plugin_id, ':') === FALSE) { continue; } list($base, $derivative) = explode(':', $plugin_id); - if ($base !== 'custom_block') { + if ($base !== 'block_custom') { continue; } - $custom_block = entity_load_by_uuid('custom_block', $derivative); + $custom_block = entity_load_by_uuid('block_custom', $derivative); $row['1']['data']['#links']['edit'] = array( 'title' => t('Edit'), 'href' => 'block/' . $custom_block->id() . '/edit' @@ -278,7 +278,7 @@ function custom_block_form_block_plugin_ui_alter(&$form, $form_state) { /** * Implements hook_admin_paths(). */ -function custom_block_admin_paths() { +function block_custom_admin_paths() { $paths = array( 'block/add' => TRUE, 'block/add/*' => TRUE, @@ -292,11 +292,11 @@ function custom_block_admin_paths() { /** * Implements hook_block_view_alter(). */ -function custom_block_block_view_alter(array &$build, Block $block) { +function block_block_custom_view_alter(array &$build, Block $block) { // Add contextual links for custom blocks. if ($block->getPlugin() instanceof CustomBlockBlock) { // Move contextual links from inner content to outer wrapper. - $build['#contextual_links']['custom_block'] = $build['content']['#contextual_links']['custom_block']; - unset($build['content']['#contextual_links']['custom_block']); + $build['#contextual_links']['block_custom'] = $build['content']['#contextual_links']['block_custom']; + unset($build['content']['#contextual_links']['block_custom']); } } diff --git a/core/modules/block/custom_block/custom_block.pages.inc b/core/modules/block_custom/block_custom.pages.inc similarity index 73% rename from core/modules/block/custom_block/custom_block.pages.inc rename to core/modules/block_custom/block_custom.pages.inc index 439030e..f7ee1c3 100644 --- a/core/modules/block/custom_block/custom_block.pages.inc +++ b/core/modules/block_custom/block_custom.pages.inc @@ -5,8 +5,8 @@ * Provides page callbacks for custom blocks. */ -use Drupal\custom_block\Plugin\Core\Entity\CustomBlockType; -use Drupal\custom_block\Plugin\Core\Entity\CustomBlock; +use Drupal\block_custom\Plugin\Core\Entity\CustomBlockType; +use Drupal\block_custom\Plugin\Core\Entity\CustomBlock; use Symfony\Component\HttpFoundation\RedirectResponse; /** @@ -17,9 +17,9 @@ * if there is only one custom block type defined for the site, the function * returns the custom block add page for that custom block type. * - * @see custom_block_menu() + * @see block_custom_menu() */ -function custom_block_add_page() { +function block_custom_add_page() { $options = array(); $request = drupal_container()->get('request'); if (($theme = $request->attributes->get('theme')) && in_array($theme, array_keys(list_themes()))) { @@ -30,13 +30,13 @@ function custom_block_add_page() { 'query' => array('theme' => $theme) ); } - $types = entity_load_multiple('custom_block_type'); + $types = entity_load_multiple('block_custom_type'); if ($types && count($types) == 1) { $type = reset($types); - return custom_block_add($type); + return block_custom_add($type); } - return array('#theme' => 'custom_block_add_list', '#content' => $types); + return array('#theme' => 'block_custom_add_list', '#content' => $types); } /** @@ -46,11 +46,11 @@ function custom_block_add_page() { * An associative array containing: * - content: An array of block types. * - * @see custom_block_add_page() + * @see block_custom_add_page() * * @ingroup themeable */ -function theme_custom_block_add_list($variables) { +function theme_block_custom_add_list($variables) { $content = $variables['content']; $output = ''; @@ -69,19 +69,19 @@ function theme_custom_block_add_list($variables) { /** * Page callback: Presents the custom block creation form. * - * @param Drupal\custom_block\Plugin\Core\Entity\CustomBlockType $block_type + * @param Drupal\block_custom\Plugin\Core\Entity\CustomBlockType $block_type * The custom block type to add. * * @return array * A form array as expected by drupal_render(). * - * @see custom_block_menu() + * @see block_custom_menu() */ -function custom_block_add(CustomBlockType $block_type) { +function block_custom_add(CustomBlockType $block_type) { drupal_set_title(t('Add %type custom block', array( '%type' => $block_type->label() )), PASS_THROUGH); - $block = entity_create('custom_block', array( + $block = entity_create('block_custom', array( 'type' => $block_type->id() )); $options = array(); @@ -98,15 +98,15 @@ function custom_block_add(CustomBlockType $block_type) { /** * Page callback: Presents the custom block edit form. * - * @param Drupal\custom_block\Plugin\Core\Entity\CustomBlock $block + * @param Drupal\block_custom\Plugin\Core\Entity\CustomBlock $block * The custom block to edit. * * @return array * A form array as expected by drupal_render(). * - * @see custom_block_menu() + * @see block_custom_menu() */ -function custom_block_edit(CustomBlock $block) { +function block_custom_edit(CustomBlock $block) { drupal_set_title(t('Edit custom block %label', array('%label' => $block->label())), PASS_THROUGH); return entity_get_form($block); } @@ -114,16 +114,16 @@ function custom_block_edit(CustomBlock $block) { /** * Page callback: Form constructor for the custom block deletion form. * - * @param Drupal\custom_block\Plugin\Core\Entity\CustomBlock $block + * @param Drupal\block_custom\Plugin\Core\Entity\CustomBlock $block * The custom block to be deleted. * - * @see custom_block_menu() - * @see custom_block_delete_form_submit() + * @see block_custom_menu() + * @see block_custom_delete_form_submit() * * @ingroup forms */ -function custom_block_delete_form($form, &$form_state, CustomBlock $block) { - $form_state['custom_block'] = $block; +function block_custom_delete_form($form, &$form_state, CustomBlock $block) { + $form_state['block_custom'] = $block; $form['id'] = array( '#type' => 'value', '#value' => $block->id(), @@ -139,15 +139,15 @@ function custom_block_delete_form($form, &$form_state, CustomBlock $block) { } /** - * Form submission handler for custom_block_delete_form(). + * Form submission handler for block_custom_delete_form(). */ -function custom_block_delete_form_submit($form, &$form_state) { +function block_custom_delete_form_submit($form, &$form_state) { // @todo Delete all configured instances of the block. - $block = $form_state['custom_block']; + $block = $form_state['block_custom']; $block->delete(); drupal_set_message(t('Custom block %label has been deleted.', array('%label' => $block->label()))); - watchdog('custom_block', 'Custom block %label has been deleted.', array('%label' => $block->label()), WATCHDOG_NOTICE); + watchdog('block_custom', 'Custom block %label has been deleted.', array('%label' => $block->label()), WATCHDOG_NOTICE); $form_state['redirect'] = 'admin/structure/block'; } diff --git a/core/modules/block/custom_block/config/custom_block.type.basic.yml b/core/modules/block_custom/config/block_custom.type.basic.yml similarity index 100% rename from core/modules/block/custom_block/config/custom_block.type.basic.yml rename to core/modules/block_custom/config/block_custom.type.basic.yml diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockAccessController.php b/core/modules/block_custom/lib/Drupal/block_custom/CustomBlockAccessController.php similarity index 93% rename from core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockAccessController.php rename to core/modules/block_custom/lib/Drupal/block_custom/CustomBlockAccessController.php index 01421f2..752fbd9 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockAccessController.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/CustomBlockAccessController.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\CustomBlockAccessController. + * Contains \Drupal\block_custom\CustomBlockAccessController. */ -namespace Drupal\custom_block; +namespace Drupal\block_custom; use Drupal\Core\Entity\EntityInterface; use Drupal\user\Plugin\Core\Entity\User; diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php b/core/modules/block_custom/lib/Drupal/block_custom/CustomBlockFormController.php similarity index 90% rename from core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php rename to core/modules/block_custom/lib/Drupal/block_custom/CustomBlockFormController.php index 0094c42..2a3f780 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/CustomBlockFormController.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\CustomBlockFormController. + * Contains \Drupal\block_custom\CustomBlockFormController. */ -namespace Drupal\custom_block; +namespace Drupal\block_custom; use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Entity\EntityInterface; @@ -21,12 +21,12 @@ class CustomBlockFormController extends EntityFormControllerNG { * * 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_custom_prepare() * on all modules. */ protected function prepareEntity(EntityInterface $block) { // Set up default values, if required. - $block_type = entity_load('custom_block_type', $block->type->value); + $block_type = entity_load('block_custom_type', $block->type->value); // If this is a new custom block, fill in the default values. if (isset($block->id->value)) { $block->set('log', NULL); @@ -34,7 +34,7 @@ protected function prepareEntity(EntityInterface $block) { // Always use the default revision setting. $block->setNewRevision($block_type->revision); - module_invoke_all('custom_block_prepare', $block); + module_invoke_all('block_custom_prepare', $block); } /** @@ -64,7 +64,7 @@ public function form(array $form, array &$form_state, EntityInterface $block) { '#description' => t('A brief description of your block. Used on the Blocks administration page.', array('@overview' => url('admin/structure/block'))), ); - $language_configuration = module_invoke('language', 'get_default_configuration', 'custom_block', $block->type->value); + $language_configuration = module_invoke('language', 'get_default_configuration', 'block_custom', $block->type->value); // Set the correct default language. if ($block->isNew() && !empty($language_configuration['langcode'])) { @@ -98,7 +98,7 @@ public function form(array $form, array &$form_state, EntityInterface $block) { 'class' => array('custom-block-form-revision-information'), ), '#attached' => array( - 'js' => array(drupal_get_path('module', 'custom_block') . '/custom_block.js'), + 'js' => array(drupal_get_path('module', 'block_custom') . '/block_custom.js'), ), '#weight' => 20, '#access' => $block->isNewRevision() || user_access('administer blocks'), @@ -162,7 +162,7 @@ public function save(array $form, array &$form_state) { $insert = empty($block->id->value); $block->save(); $watchdog_args = array('@type' => $block->bundle(), '%info' => $block->label()); - $block_type = entity_load('custom_block_type', $block->type->value); + $block_type = entity_load('block_custom_type', $block->type->value); $t_args = array('@type' => $block_type->label(), '%info' => $block->label()); if ($insert) { @@ -179,10 +179,10 @@ public function save(array $form, array &$form_state) { $form_state['id'] = $block->id->value; if ($insert) { if ($theme = $block->getTheme()) { - $form_state['redirect'] = 'admin/structure/block/add/custom_block:' . $block->uuid->value . '/' . $theme; + $form_state['redirect'] = 'admin/structure/block/add/block_custom:' . $block->uuid->value . '/' . $theme; } else { - $form_state['redirect'] = 'admin/structure/block/add/custom_block:' . $block->uuid->value . '/' . config('system.theme')->get('default'); + $form_state['redirect'] = 'admin/structure/block/add/block_custom:' . $block->uuid->value . '/' . config('system.theme')->get('default'); } } else { diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php b/core/modules/block_custom/lib/Drupal/block_custom/CustomBlockRenderController.php similarity index 82% rename from core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php rename to core/modules/block_custom/lib/Drupal/block_custom/CustomBlockRenderController.php index 00fa8ec..773c674 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/CustomBlockRenderController.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\CustomBlockRenderController. + * Contains \Drupal\block_custom\CustomBlockRenderController. */ -namespace Drupal\custom_block; +namespace Drupal\block_custom; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityRenderController; @@ -23,7 +23,7 @@ protected function alterBuild(array &$build, EntityInterface $entity, EntityDisp parent::alterBuild($build, $entity, $display, $view_mode, $langcode); // Add contextual links for this custom block. if (!empty($entity->id->value) && $view_mode == 'full') { - $build['#contextual_links']['custom_block'] = array('block', array($entity->id())); + $build['#contextual_links']['block_custom'] = array('block', array($entity->id())); } } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockStorageController.php b/core/modules/block_custom/lib/Drupal/block_custom/CustomBlockStorageController.php similarity index 92% rename from core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockStorageController.php rename to core/modules/block_custom/lib/Drupal/block_custom/CustomBlockStorageController.php index 87ff2d5..125bfe5 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockStorageController.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/CustomBlockStorageController.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\CustomBlockStorageController. + * Contains \Drupal\block_custom\CustomBlockStorageController. */ -namespace Drupal\custom_block; +namespace Drupal\block_custom; use Drupal\Core\Entity\DatabaseStorageControllerNG; use Drupal\Core\Entity\EntityInterface; @@ -23,7 +23,7 @@ class CustomBlockStorageController extends DatabaseStorageControllerNG { */ protected function preSaveRevision(\stdClass $record, EntityInterface $entity) { if ($entity->isNewRevision()) { - // When inserting either a new custom block or a new custom_block + // When inserting either a new custom block or a new block_custom // revision, $entity->log must be set because {block_custom_revision}.log // is a text column and therefore cannot have a default value. However, // it might not be set at this point (for example, if the user submitting @@ -36,7 +36,7 @@ protected function preSaveRevision(\stdClass $record, EntityInterface $entity) { } } elseif (!isset($record->log) || $record->log === '') { - // If we are updating an existing custom_block without adding a new + // If we are updating an existing block_custom without adding a new // revision, we need to make sure $entity->log is unset whenever it is // empty. As long as $entity->log is unset, drupal_write_record() will not // attempt to update the existing database column when re-saving the @@ -58,7 +58,7 @@ protected function attachLoad(&$blocks, $load_revision = FALSE) { } // Besides the list of blocks, pass one additional argument to - // hook_custom_block_load(), containing a list of block types that were + // hook_block_custom_load(), containing a list of block types that were // loaded. $this->hookLoadArguments = array($types); parent::attachLoad($blocks, $load_revision); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTranslationController.php b/core/modules/block_custom/lib/Drupal/block_custom/CustomBlockTranslationController.php similarity index 89% rename from core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTranslationController.php rename to core/modules/block_custom/lib/Drupal/block_custom/CustomBlockTranslationController.php index a8848c7..e27985a 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTranslationController.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/CustomBlockTranslationController.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\CustomBlockTranslationController. + * Contains \Drupal\block_custom\CustomBlockTranslationController. */ -namespace Drupal\custom_block; +namespace Drupal\block_custom; use Drupal\Core\Entity\EntityInterface; use Drupal\translation_entity\EntityTranslationControllerNG; @@ -43,7 +43,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac * Overrides EntityTranslationController::entityFormTitle(). */ protected function entityFormTitle(EntityInterface $entity) { - $block_type = entity_load('custom_block_type', $entity->type->value); + $block_type = entity_load('block_custom_type', $entity->type->value); return t('Edit @type @title', array('@type' => $block_type->label(), '@title' => $entity->label())); } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php b/core/modules/block_custom/lib/Drupal/block_custom/CustomBlockTypeFormController.php similarity index 90% rename from core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php rename to core/modules/block_custom/lib/Drupal/block_custom/CustomBlockTypeFormController.php index 77664e9..8ad68f0 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/CustomBlockTypeFormController.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\CustomBlockTypeFormController. + * Contains \Drupal\block_custom\CustomBlockTypeFormController. */ -namespace Drupal\custom_block; +namespace Drupal\block_custom; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityFormController; @@ -33,7 +33,7 @@ public function form(array $form, array &$form_state, EntityInterface $block_typ '#type' => 'machine_name', '#default_value' => $block_type->id(), '#machine_name' => array( - 'exists' => 'custom_block_type_load', + 'exists' => 'block_custom_type_load', ), '#disabled' => !$block_type->isNew(), ); @@ -61,11 +61,11 @@ public function form(array $form, array &$form_state, EntityInterface $block_typ '#group' => 'additional_settings', ); - $language_configuration = language_get_default_configuration('custom_block', $block_type->id()); + $language_configuration = language_get_default_configuration('block_custom', $block_type->id()); $form['language']['language_configuration'] = array( '#type' => 'language_configuration', '#entity_information' => array( - 'entity_type' => 'custom_block', + 'entity_type' => 'block_custom', 'bundle' => $block_type->id(), ), '#default_value' => $language_configuration, @@ -93,11 +93,11 @@ public function save(array $form, array &$form_state) { $uri = $block_type->uri(); 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, l(t('Edit'), $uri['path'] . '/edit')); + watchdog('block_custom', 'Custom block type %label has been updated.', array('%label' => $block_type->label()), WATCHDOG_NOTICE, l(t('Edit'), $uri['path'] . '/edit')); } 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, l(t('Edit'), $uri['path'] . '/edit')); + watchdog('block_custom', 'Custom block type %label has been added.', array('%label' => $block_type->label()), WATCHDOG_NOTICE, l(t('Edit'), $uri['path'] . '/edit')); } $form_state['redirect'] = 'admin/structure/custom-blocks'; diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeListController.php b/core/modules/block_custom/lib/Drupal/block_custom/CustomBlockTypeListController.php similarity index 94% rename from core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeListController.php rename to core/modules/block_custom/lib/Drupal/block_custom/CustomBlockTypeListController.php index 8ef270c..2837234 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeListController.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/CustomBlockTypeListController.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\CustomBlockTypeListController. + * Contains \Drupal\block_custom\CustomBlockTypeListController. */ -namespace Drupal\custom_block; +namespace Drupal\block_custom; use Drupal\Core\Config\Entity\ConfigEntityListController; use Drupal\Core\Entity\EntityInterface; diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeStorageController.php b/core/modules/block_custom/lib/Drupal/block_custom/CustomBlockTypeStorageController.php similarity index 70% rename from core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeStorageController.php rename to core/modules/block_custom/lib/Drupal/block_custom/CustomBlockTypeStorageController.php index 1c8cbc2..b688659 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeStorageController.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/CustomBlockTypeStorageController.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\CustomBlockTypeStorageController. + * Contains \Drupal\block_custom\CustomBlockTypeStorageController. */ -namespace Drupal\custom_block; +namespace Drupal\block_custom; use Drupal\Core\Config\Entity\ConfigStorageController; use Drupal\Core\Entity\EntityInterface; @@ -22,11 +22,11 @@ protected function postSave(EntityInterface $entity, $update) { parent::postSave($entity, $update); if (!$update) { - field_attach_create_bundle('custom_block', $entity->id()); - custom_block_add_body_field($entity->id()); + field_attach_create_bundle('block_custom', $entity->id()); + block_custom_add_body_field($entity->id()); } elseif ($entity->original->id() != $entity->id()) { - field_attach_rename_bundle('custom_block', $entity->original->id(), $entity->id()); + field_attach_rename_bundle('block_custom', $entity->original->id(), $entity->id()); } } @@ -37,7 +37,7 @@ protected function postDelete($entities) { parent::postDelete($entities); foreach ($entities as $entity) { - field_attach_delete_bundle('custom_block', $entity->id()); + field_attach_delete_bundle('block_custom', $entity->id()); } } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php b/core/modules/block_custom/lib/Drupal/block_custom/Plugin/Core/Entity/CustomBlock.php similarity index 87% rename from core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php rename to core/modules/block_custom/lib/Drupal/block_custom/Plugin/Core/Entity/CustomBlock.php index c84a761..6b51776 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/Plugin/Core/Entity/CustomBlock.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\Plugin\Core\Entity\CustomBlock. + * Contains \Drupal\block_custom\Plugin\Core\Entity\CustomBlock. */ -namespace Drupal\custom_block\Plugin\Core\Entity; +namespace Drupal\block_custom\Plugin\Core\Entity; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityNG; @@ -16,20 +16,20 @@ * Defines the custom block entity class. * * @Plugin( - * id = "custom_block", + * id = "block_custom", * label = @Translation("Custom Block"), * bundle_label = @Translation("Custom Block type"), - * module = "custom_block", - * controller_class = "Drupal\custom_block\CustomBlockStorageController", - * access_controller_class = "Drupal\custom_block\CustomBlockAccessController", - * render_controller_class = "Drupal\custom_block\CustomBlockRenderController", + * module = "block_custom", + * controller_class = "Drupal\block_custom\CustomBlockStorageController", + * access_controller_class = "Drupal\block_custom\CustomBlockAccessController", + * render_controller_class = "Drupal\block_custom\CustomBlockRenderController", * form_controller_class = { - * "default" = "Drupal\custom_block\CustomBlockFormController" + * "default" = "Drupal\block_custom\CustomBlockFormController" * }, - * translation_controller_class = "Drupal\custom_block\CustomBlockTranslationController", - * base_table = "custom_block", - * revision_table = "custom_block_revision", - * menu_base_path = "block/%custom_block", + * translation_controller_class = "Drupal\block_custom\CustomBlockTranslationController", + * base_table = "block_custom", + * revision_table = "block_custom_revision", + * menu_base_path = "block/%block_custom", * fieldable = TRUE, * entity_keys = { * "id" = "id", diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlockType.php b/core/modules/block_custom/lib/Drupal/block_custom/Plugin/Core/Entity/CustomBlockType.php similarity index 75% rename from core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlockType.php rename to core/modules/block_custom/lib/Drupal/block_custom/Plugin/Core/Entity/CustomBlockType.php index 991fbc5..bc49edc 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlockType.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/Plugin/Core/Entity/CustomBlockType.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\Plugin\Core\Entity\CustomBlockType. + * Contains \Drupal\block_custom\Plugin\Core\Entity\CustomBlockType. */ -namespace Drupal\custom_block\Plugin\Core\Entity; +namespace Drupal\block_custom\Plugin\Core\Entity; use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\Component\Annotation\Plugin; @@ -15,15 +15,15 @@ * Defines the custom block type entity. * * @Plugin( - * id = "custom_block_type", + * id = "block_custom_type", * label = @Translation("Custom block type"), - * module = "custom_block", - * controller_class = "Drupal\custom_block\CustomBlockTypeStorageController", - * list_controller_class = "Drupal\custom_block\CustomBlockTypeListController", + * module = "block_custom", + * controller_class = "Drupal\block_custom\CustomBlockTypeStorageController", + * list_controller_class = "Drupal\block_custom\CustomBlockTypeListController", * form_controller_class = { - * "default" = "Drupal\custom_block\CustomBlockTypeFormController" + * "default" = "Drupal\block_custom\CustomBlockTypeFormController" * }, - * config_prefix = "custom_block.type", + * config_prefix = "block_custom.type", * entity_keys = { * "id" = "id", * "label" = "label", diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php b/core/modules/block_custom/lib/Drupal/block_custom/Plugin/Derivative/CustomBlock.php similarity index 89% rename from core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php rename to core/modules/block_custom/lib/Drupal/block_custom/Plugin/Derivative/CustomBlock.php index 592f150..f882aae 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Derivative/CustomBlock.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/Plugin/Derivative/CustomBlock.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\Plugin\Derivative\CustomBlock. + * Contains \Drupal\block_custom\Plugin\Derivative\CustomBlock. */ -namespace Drupal\custom_block\Plugin\Derivative; +namespace Drupal\block_custom\Plugin\Derivative; use Drupal\Component\Plugin\Derivative\DerivativeInterface; @@ -40,7 +40,7 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin * Retrieves custom block definitions from storage. */ public function getDerivativeDefinitions(array $base_plugin_definition) { - $custom_blocks = entity_load_multiple('custom_block'); + $custom_blocks = entity_load_multiple('block_custom'); foreach ($custom_blocks as $custom_block) { $this->derivatives[$custom_block->uuid->value] = $base_plugin_definition; $this->derivatives[$custom_block->uuid->value]['settings'] = array( diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlockBlock.php b/core/modules/block_custom/lib/Drupal/block_custom/Plugin/block/block/CustomBlockBlock.php similarity index 85% rename from core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlockBlock.php rename to core/modules/block_custom/lib/Drupal/block_custom/Plugin/block/block/CustomBlockBlock.php index 9219264..993b89a 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlockBlock.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/Plugin/block/block/CustomBlockBlock.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\Plugin\block\block\CustomBlockBlock. + * Contains \Drupal\block_custom\Plugin\block\block\CustomBlockBlock. */ -namespace Drupal\custom_block\Plugin\block\block; +namespace Drupal\block_custom\Plugin\block\block; use Drupal\block\BlockBase; use Drupal\Component\Annotation\Plugin; @@ -15,10 +15,10 @@ * Defines a generic custom block type. * * @Plugin( - * id = "custom_block", + * id = "block_custom", * admin_label = @Translation("Custom block"), - * module = "custom_block", - * derivative = "Drupal\custom_block\Plugin\Derivative\CustomBlock", + * module = "block_custom", + * derivative = "Drupal\block_custom\Plugin\Derivative\CustomBlock", * settings = { * "status" = TRUE, * "info" = "", @@ -47,11 +47,11 @@ public function getConfig() { */ public function blockForm($form, &$form_state) { $options = array(); - $view_modes = entity_get_view_modes('custom_block'); + $view_modes = entity_get_view_modes('block_custom'); foreach ($view_modes as $view_mode => $detail) { $options[$view_mode] = $detail['label']; } - $form['custom_block']['view_mode'] = array( + $form['block_custom']['view_mode'] = array( '#type' => 'select', '#options' => $options, '#title' => t('View mode'), @@ -78,7 +78,7 @@ public function blockSubmit($form, &$form_state) { public function build() { // @todo Clean up when http://drupal.org/node/1874498 lands. list(, $uuid) = explode(':', $this->getPluginId()); - if ($block = entity_load_by_uuid('custom_block', $uuid)) { + if ($block = entity_load_by_uuid('block_custom', $uuid)) { return entity_view($block, $this->configuration['view_mode']); } else { diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockBuildContentTest.php b/core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockBuildContentTest.php similarity index 85% rename from core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockBuildContentTest.php rename to core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockBuildContentTest.php index cee6ce8..e35ed94 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockBuildContentTest.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockBuildContentTest.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\Tests\CustomBlockBuildContentTest. + * Contains \Drupal\block_custom\Tests\CustomBlockBuildContentTest. */ -namespace Drupal\custom_block\Tests; +namespace Drupal\block_custom\Tests; /** * Test to ensure that a block's content is always rebuilt. @@ -24,7 +24,7 @@ public static function getInfo() { } /** - * Ensures that content is rebuilt in calls to custom_block_build_content(). + * Ensures that content is rebuilt in calls to block_custom_build_content(). */ public function testCustomBlockRebuildContent() { $block = $this->createCustomBlock(); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php b/core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockCreationTest.php similarity index 89% rename from core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php rename to core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockCreationTest.php index ba86c1b..c691d29 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockCreationTest.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\Tests\CustomBlockCreationTest. + * Contains \Drupal\block_custom\Tests\CustomBlockCreationTest. */ -namespace Drupal\custom_block\Tests; +namespace Drupal\block_custom\Tests; use Drupal\Core\Database\Database; @@ -21,7 +21,7 @@ class CustomBlockCreationTest extends CustomBlockTestBase { * * @var array */ - public static $modules = array('custom_block_test', 'dblog'); + public static $modules = array('block_custom_test', 'dblog'); /** * Declares test information. @@ -60,7 +60,7 @@ public function testCustomBlockCreation() { )), 'Basic block created.'); // Check that the block exists in the database. - $blocks = entity_load_multiple_by_properties('custom_block', array('info' => $edit['info'])); + $blocks = entity_load_multiple_by_properties('block_custom', array('info' => $edit['info'])); $block = reset($blocks); $this->assertTrue($block, 'Custom Block found in database.'); } @@ -80,7 +80,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_custom', 'b') ->fields('b', array('id')) ->condition('info', 'fail_creation') ->execute() @@ -89,7 +89,7 @@ public function testFailedBlockCreation() { } else { // Check that the block exists in the database. - $id = db_select('custom_block', 'b') + $id = db_select('block_custom', 'b') ->fields('b', array('id')) ->condition('info', 'fail_creation') ->execute() diff --git a/core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockLoadHooksTest.php b/core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockLoadHooksTest.php new file mode 100644 index 0000000..418c6e6 --- /dev/null +++ b/core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockLoadHooksTest.php @@ -0,0 +1,70 @@ + 'Custom Block load hooks', + 'description' => 'Test the hooks invoked when a custom block is being loaded.', + 'group' => 'Custom Block', + ); + } + + /** + * Tests that hook_block_custom_load() is invoked correctly. + */ + public function testHookCustomBlockLoad() { + $other_bundle = $this->createCustomBlockType('other'); + // Create some sample articles and pages. + $custom_block1 = $this->createCustomBlock(); + $custom_block2 = $this->createCustomBlock(); + $custom_block3 = $this->createCustomBlock(); + $custom_block4 = $this->createCustomBlock(FALSE, $other_bundle->id()); + + // Check that when a set of custom blocks that only contains basic blocks is + // loaded, the properties added to the custom block by + // block_custom_test_load_block_custom() correctly reflect the expected + // values. + $custom_blocks = entity_load_multiple_by_properties('block_custom', array('type' => 'basic')); + $loaded_block_custom = end($custom_blocks); + $this->assertEqual($loaded_block_custom->block_custom_test_loaded_ids, array( + $custom_block1->id->value, + $custom_block2->id->value, + $custom_block3->id->value + ), 'hook_block_custom_load() received the correct list of block_custom IDs the first time it was called.'); + $this->assertEqual($loaded_block_custom->block_custom_test_loaded_types, array('basic'), 'hook_block_custom_load() received the correct list of custom block types the first time it was called.'); + + // Now, as part of the same page request, load a set of block_customs that contain + // both basic and other bundle, and make sure the parameters passed to + // block_custom_test_block_custom_load() are correctly updated. + $custom_blocks = entity_load_multiple('block_custom', entity_query('block_custom')->execute(), TRUE); + $loaded_block_custom = end($custom_blocks); + $this->assertEqual($loaded_block_custom->block_custom_test_loaded_ids, array( + $custom_block1->id->value, + $custom_block2->id->value, + $custom_block3->id->value, + $custom_block4->id->value + ), 'hook_block_custom_load() received the correct list of block_custom IDs the second time it was called.'); + $this->assertEqual($loaded_block_custom->block_custom_test_loaded_types, array('basic', 'other'), 'hook_block_custom_load() received the correct list of block_custom types the second time it was called.'); + } +} diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockPageViewTest.php b/core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockPageViewTest.php similarity index 85% rename from core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockPageViewTest.php rename to core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockPageViewTest.php index 0841fd9..507e62a 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockPageViewTest.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockPageViewTest.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\Tests\CustomBlockPageViewTest. + * Contains \Drupal\block_custom\Tests\CustomBlockPageViewTest. */ -namespace Drupal\custom_block\Tests; +namespace Drupal\block_custom\Tests; /** * Tests the block edit functionality. @@ -27,7 +27,7 @@ class CustomBlockPageViewTest extends CustomBlockTestBase { * * @var array */ - public static $modules = array('block', 'custom_block', 'custom_block_test'); + public static $modules = array('block', 'block_custom', 'block_custom_test'); /** * Declares test information. diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockRevisionsTest.php b/core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockRevisionsTest.php similarity index 91% rename from core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockRevisionsTest.php rename to core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockRevisionsTest.php index b1d1220..8bf5327 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockRevisionsTest.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockRevisionsTest.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\Tests\CustomBlockRevisionsTest. + * Contains \Drupal\block_custom\Tests\CustomBlockRevisionsTest. */ -namespace Drupal\custom_block\Tests; +namespace Drupal\block_custom\Tests; /** * Tests the block revision functionality. @@ -73,7 +73,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_custom', $revision_id); // Verify log is the same. $this->assertEqual($loaded->log->value, $logs[$delta], format_string('Correct log message found for revision !revision', array( '!revision' => $loaded->revision_id->value @@ -96,7 +96,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->value); + $default_revision = entity_load('block_custom', $loaded->id->value); $this->assertTrue($loaded->revision_id->value > $default_revision->revision_id->value, 'Revision id is greater than default revision id.'); } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php b/core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockSaveTest.php similarity index 81% rename from core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php rename to core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockSaveTest.php index 1874ff3..592db05 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockSaveTest.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\Tests\CustomBlockSaveTest. + * Contains \Drupal\block_custom\Tests\CustomBlockSaveTest. */ -namespace Drupal\custom_block\Tests; +namespace Drupal\block_custom\Tests; /** * Tests block save related functionality. @@ -17,7 +17,7 @@ class CustomBlockSaveTest extends CustomBlockTestBase { * * @var array */ - public static $modules = array('custom_block_test'); + public static $modules = array('block_custom_test'); /** * Declares test information. @@ -44,7 +44,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_custom}')->fetchField(); $test_id = $max_id + mt_rand(1000, 1000000); $info = $this->randomName(8); $block = array( @@ -53,7 +53,7 @@ public function testImport() { 'type' => 'basic', 'id' => $test_id ); - $block = entity_create('custom_block', $block); + $block = entity_create('block_custom', $block); $block->enforceIsNew(TRUE); $block->save(); @@ -61,7 +61,7 @@ public function testImport() { $this->assertEqual($block->id->value, $test_id, 'Block imported using provide id'); // Test the import saved. - $block_by_id = custom_block_load($test_id); + $block_by_id = block_custom_load($test_id); $this->assertTrue($block_by_id, 'Custom block load by block ID.'); } @@ -82,13 +82,13 @@ public function testDeterminingChanges() { $block->info->value = '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_custom_test_block_custom_presave() and + // block_custom_test_block_custom_update() determine changes and change the // title. $this->assertEqual($block->label(), 'updated_presave_update', 'Changes have been determined.'); // Test the static block load cache to be cleared. - $block = custom_block_load($block->id->value); + $block = block_custom_load($block->id->value); $this->assertEqual($block->label(), 'updated_presave', 'Static cache has been cleared.'); } @@ -96,13 +96,13 @@ 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_custom_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() tiggers a save on insert if the + // block_custom_test_block_custom_insert() tiggers a save on insert if the // title equals 'new'. $block = $this->createCustomBlock('new'); $this->assertEqual($block->label(), 'CustomBlock ' . $block->id->value, 'Custom block saved on block insert.'); diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTestBase.php b/core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockTestBase.php similarity index 79% rename from core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTestBase.php rename to core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockTestBase.php index 55d6bb9..c0c2592 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTestBase.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockTestBase.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\Tests\CustomBlockTestBase. + * Contains \Drupal\block_custom\Tests\CustomBlockTestBase. */ -namespace Drupal\custom_block\Tests; +namespace Drupal\block_custom\Tests; use Drupal\simpletest\WebTestBase; @@ -40,7 +40,7 @@ * * @var array */ - public static $modules = array('block', 'custom_block'); + public static $modules = array('block', 'block_custom'); /** * Sets the test up. @@ -59,12 +59,12 @@ protected function setUp() { * @param string $bundle * (optional) Bundle name. Defaults to 'basic'. * - * @return Drupal\custom_block\Plugin\Core\Entity\CustomBlock + * @return Drupal\block_custom\Plugin\Core\Entity\CustomBlock * Created custom block. */ protected function createCustomBlock($title = FALSE, $bundle = 'basic') { $title = ($title ? : $this->randomName()); - if ($custom_block = entity_create('custom_block', array( + if ($custom_block = entity_create('block_custom', array( 'info' => $title, 'type' => $bundle, 'langcode' => 'en' @@ -80,11 +80,11 @@ protected function createCustomBlock($title = FALSE, $bundle = 'basic') { * @param string $label * The block type label. * - * @return Drupal\custom_block\Plugin\Core\Entity\CustomBlockType + * @return Drupal\block_custom\Plugin\Core\Entity\CustomBlockType * Created custom block type. */ protected function createCustomBlockType($label) { - $bundle = entity_create('custom_block_type', array( + $bundle = entity_create('block_custom_type', array( 'id' => $label, 'label' => $label, 'revision' => FALSE diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTranslationUITest.php b/core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockTranslationUITest.php similarity index 81% rename from core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTranslationUITest.php rename to core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockTranslationUITest.php index 3ccac91..95353e5 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTranslationUITest.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockTranslationUITest.php @@ -2,13 +2,13 @@ /** * @file - * Contains \Drupal\custom_block\Tests\CustomBlockTranslationUITest. + * Contains \Drupal\block_custom\Tests\CustomBlockTranslationUITest. */ -namespace Drupal\custom_block\Tests; +namespace Drupal\block_custom\Tests; use Drupal\translation_entity\Tests\EntityTranslationUITest; -use Drupal\custom_block\Plugin\Core\Entity\CustomBlock; +use Drupal\block_custom\Plugin\Core\Entity\CustomBlock; /** * Tests the Custom Block Translation UI. @@ -30,7 +30,7 @@ class CustomBlockTranslationUITest extends EntityTranslationUITest { 'translation_entity', 'block', 'field_ui', - 'custom_block' + 'block_custom' ); /** @@ -48,7 +48,7 @@ public static function getInfo() { * Overrides \Drupal\simpletest\WebTestBase::setUp(). */ public function setUp() { - $this->entityType = 'custom_block'; + $this->entityType = 'block_custom'; $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_custom fields' )); } @@ -77,13 +77,13 @@ public function getTranslatorPermissions() { * (optional) Bundle name. When no value is given, defaults to * $this->bundle. Defaults to FALSE. * - * @return Drupal\custom_block\Plugin\Core\Entity\CustomBlock + * @return Drupal\block_custom\Plugin\Core\Entity\CustomBlock * Created custom block. */ protected function createCustomBlock($title = FALSE, $bundle = FALSE) { $title = ($title ? : $this->randomName()); $bundle = ($bundle ? : $this->bundle); - $custom_block = entity_create('custom_block', array( + $custom_block = entity_create('block_custom', array( 'info' => $title, 'type' => $bundle, 'langcode' => 'en' @@ -105,7 +105,7 @@ protected function getNewEntityValues($langcode) { 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_custom_type', array( 'id' => $disabled_bundle, 'label' => $disabled_bundle, 'revision' => FALSE @@ -113,14 +113,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_custom = $this->createCustomBlock(); + $disabled_block_custom = $this->createCustomBlock(FALSE, $bundle->id()); // Make sure that only a single row was inserted into the // {translation_entity} table. $rows = db_query('SELECT * FROM {translation_entity}')->fetchAll(); $this->assertEqual(1, count($rows)); - $this->assertEqual($enabled_custom_block->id(), reset($rows)->entity_id); + $this->assertEqual($enabled_block_custom->id(), reset($rows)->entity_id); } } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php b/core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockTypeTest.php similarity index 93% rename from core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php rename to core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockTypeTest.php index d94e476..64abbd8 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/Tests/CustomBlockTypeTest.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\Tests\CustomBlockTypeTest. + * Contains \Drupal\block_custom\Tests\CustomBlockTypeTest. */ -namespace Drupal\custom_block\Tests; +namespace Drupal\block_custom\Tests; /** * Tests related to custom block types. @@ -26,7 +26,7 @@ class CustomBlockTypeTest extends CustomBlockTestBase { */ protected $permissions = array( 'administer blocks', - 'administer custom_block fields' + 'administer block_custom fields' ); /** @@ -47,7 +47,7 @@ public function testCustomBlockTypeCreation() { // Create a block type programmaticaly. $type = $this->createCustomBlockType('other'); - $block_type = entity_load('custom_block_type', 'other'); + $block_type = entity_load('block_custom_type', 'other'); $this->assertTrue($block_type, 'The new block type has been created.'); // Login a test user. @@ -62,7 +62,7 @@ public function testCustomBlockTypeCreation() { 'label' => 'title for foo', ); $this->drupalPost('admin/structure/custom-blocks/add', $edit, t('Save')); - $block_type = entity_load('custom_block_type', 'foo'); + $block_type = entity_load('block_custom_type', 'foo'); $this->assertTrue($block_type, 'The new block type has been created.'); } @@ -74,7 +74,7 @@ public function testCustomBlockTypeEditing() { // We need two block types to prevent /block/add redirecting. $this->createCustomBlockType('other'); - $instance = field_info_instance('custom_block', 'block_body', 'basic'); + $instance = field_info_instance('block_custom', 'block_body', 'basic'); $this->assertEqual($instance['label'], 'Block body', 'Body field was found.'); // Verify that title and body fields are displayed. diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/PageEditTest.php b/core/modules/block_custom/lib/Drupal/block_custom/Tests/PageEditTest.php similarity index 87% rename from core/modules/block/custom_block/lib/Drupal/custom_block/Tests/PageEditTest.php rename to core/modules/block_custom/lib/Drupal/block_custom/Tests/PageEditTest.php index 3ba7b0b..7c5f607 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/PageEditTest.php +++ b/core/modules/block_custom/lib/Drupal/block_custom/Tests/PageEditTest.php @@ -2,10 +2,10 @@ /** * @file - * Contains \Drupal\custom_block\Tests\PageEditTest. + * Contains \Drupal\block_custom\Tests\PageEditTest. */ -namespace Drupal\custom_block\Tests; +namespace Drupal\block_custom\Tests; /** * Tests the block edit functionality. @@ -39,8 +39,8 @@ public function testPageEdit() { $this->drupalPost('block/add/basic', $edit, t('Save')); // Check that the block exists in the database. - $blocks = entity_query('custom_block')->condition('info', $edit['info'])->execute(); - $block = entity_load('custom_block', reset($blocks)); + $blocks = entity_query('block_custom')->condition('info', $edit['info'])->execute(); + $block = entity_load('block_custom', reset($blocks)); $this->assertTrue($block, 'Custom block found in database.'); // Load the edit page. @@ -64,7 +64,7 @@ public function testPageEdit() { $this->drupalPost(NULL, $edit, t('Save')); // Ensure that the block revision has been created. - $revised_block = entity_load('custom_block', $block->id->value, TRUE); + $revised_block = entity_load('block_custom', $block->id->value, TRUE); $this->assertNotIdentical($block->revision_id->value, $revised_block->revision_id->value, 'A new revision has been created.'); } diff --git a/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.info.yml b/core/modules/block_custom/tests/modules/block_custom_test/block_custom_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_custom/tests/modules/block_custom_test/block_custom_test.info.yml diff --git a/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module b/core/modules/block_custom/tests/modules/block_custom_test/block_custom_test.module similarity index 62% rename from core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module rename to core/modules/block_custom/tests/modules/block_custom_test/block_custom_test.module index a2961fc..92b6b4d 100644 --- a/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module +++ b/core/modules/block_custom/tests/modules/block_custom_test/block_custom_test.module @@ -5,31 +5,31 @@ * 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_custom module. */ -use Drupal\custom_block\Plugin\Core\Entity\CustomBlock; +use Drupal\block_custom\Plugin\Core\Entity\CustomBlock; /** - * Implements hook_custom_block_load(). + * Implements hook_block_custom_load(). */ -function custom_block_test_custom_block_load($custom_blocks, $types) { - // Add properties to each loaded custom_block which record the parameters that +function block_custom_test_block_custom_load($custom_blocks, $types) { + // Add properties to each loaded block_custom which record the parameters that // were passed in to this function, so the tests can check that (a) this hook // was called, and (b) the parameters were what we expected them to be. $ids = array_keys($custom_blocks); ksort($ids); sort($types); foreach ($custom_blocks as $custom_block) { - $custom_block->custom_block_test_loaded_ids = $ids; - $custom_block->custom_block_test_loaded_types = $types; + $custom_block->block_custom_test_loaded_ids = $ids; + $custom_block->block_custom_test_loaded_types = $types; } } /** - * Implements hook_custom_block_view(). + * Implements hook_block_custom_view(). */ -function custom_block_test_custom_block_view(CustomBlock $custom_block, $view_mode) { +function block_custom_test_block_custom_view(CustomBlock $custom_block, $view_mode) { // Add extra content. $custom_block->content['extra_content'] = array( '#markup' => 'Yowser', @@ -37,10 +37,10 @@ function custom_block_test_custom_block_view(CustomBlock $custom_block, $view_mo } /** - * Implements hook_custom_block_presave(). + * Implements hook_block_custom_presave(). */ -function custom_block_test_custom_block_presave(CustomBlock $custom_block) { - if ($custom_block->info->value == 'testing_custom_block_presave') { +function block_custom_test_block_custom_presave(CustomBlock $custom_block) { + if ($custom_block->info->value == 'testing_block_custom_presave') { $custom_block->info->value .= '_presave'; } // Determine changes. @@ -52,9 +52,9 @@ function custom_block_test_custom_block_presave(CustomBlock $custom_block) { } /** - * Implements hook_custom_block_update(). + * Implements hook_block_custom_update(). */ -function custom_block_test_custom_block_update(CustomBlock $custom_block) { +function block_custom_test_block_custom_update(CustomBlock $custom_block) { // Determine changes on update. if (!empty($custom_block->original) && $custom_block->original->info->value == 'test_changes') { if ($custom_block->original->info->value != $custom_block->info->value) { @@ -64,14 +64,14 @@ function custom_block_test_custom_block_update(CustomBlock $custom_block) { } /** - * Implements hook_custom_block_insert(). + * Implements hook_block_custom_insert(). * - * This tests saving a custom_block on custom_block insert. + * This tests saving a block_custom on block_custom insert. * - * @see \Drupal\custom_block\Tests\CustomBlockSaveTest::testCustomBlockSaveOnInsert() + * @see \Drupal\block_custom\Tests\CustomBlockSaveTest::testCustomBlockSaveOnInsert() */ -function custom_block_test_custom_block_insert(CustomBlock $custom_block) { - // Set the custom_block title to the custom_block ID and save. +function block_custom_test_block_custom_insert(CustomBlock $custom_block) { + // Set the block_custom title to the block_custom ID and save. if ($custom_block->info->value == 'new') { $custom_block->info->value = 'CustomBlock ' . $custom_block->id->value; $custom_block->save(); @@ -84,10 +84,10 @@ function custom_block_test_custom_block_insert(CustomBlock $custom_block) { /** * Implements hook_menu(). */ -function custom_block_test_menu() { +function block_custom_test_menu() { $items = array(); // Add a block-view callback. - $items['custom-block/%custom_block'] = array( + $items['custom-block/%block_custom'] = array( 'title callback' => 'entity_page_label', 'title arguments' => array(1), 'page callback' => 'entity_view', diff --git a/core/profiles/standard/standard.info.yml b/core/profiles/standard/standard.info.yml index 8b20a12..252d25a 100644 --- a/core/profiles/standard/standard.info.yml +++ b/core/profiles/standard/standard.info.yml @@ -13,7 +13,7 @@ dependencies: - contextual - contact - datetime - - custom_block + - block_custom - edit - help - image diff --git a/core/themes/seven/template.php b/core/themes/seven/template.php index 147e557..3d24dfa 100644 --- a/core/themes/seven/template.php +++ b/core/themes/seven/template.php @@ -63,11 +63,11 @@ function seven_node_add_list($variables) { } /** - * Overrides theme_custom_block_add_list(). + * Overrides theme_block_custom_add_list(). * * Displays the list of available custom block types for creation. */ -function seven_custom_block_add_list($variables) { +function seven_block_custom_add_list($variables) { $content = $variables['content']; $output = ''; if ($content) {