diff --git a/core/modules/block/block.install b/core/modules/block/block.install
index 4d98a6f..da69b7d 100644
--- a/core/modules/block/block.install
+++ b/core/modules/block/block.install
@@ -4,6 +4,7 @@
* @file
* Install, update and uninstall functions for the block module.
*/
+use Drupal\Component\Uuid\Uuid;
/**
* Implements hook_schema().
@@ -311,7 +312,7 @@ function block_update_8007() {
$uuid = new Uuid();
$execute = FALSE;
- $block_insert = db_insert('custom_block')->fields(
+ $block_insert = db_insert('custom_block')->fields(array(
'id',
'uuid',
'machine_name',
@@ -319,13 +320,13 @@ function block_update_8007() {
'revision_id',
'langcode',
'type'
- );
- $revision_insert = db_insert('custom_block_revision')->fields(
+ ));
+ $revision_insert = db_insert('custom_block_revision')->fields(array(
'id',
'revision_id',
'log',
'info'
- );
+ ));
foreach ($results as $block) {
$custom_block = array(
'id' => $block->bid,
diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module
index 0cd7543..a0cccb2 100644
--- a/core/modules/block/custom_block/custom_block.module
+++ b/core/modules/block/custom_block/custom_block.module
@@ -150,14 +150,14 @@ function custom_block_type_load($id) {
/**
* Loads a custom block.
*
- * @param int $bid
- * The bid of the custom block.
+ * @param int $id
+ * The id of the custom block.
*
* @return Drupal\custom_block\Plugin\Core\Entity\CustomBlock|false
* A CustomBlock object or FALSE if the requested $id does not exist.
*/
-function custom_block_load($bid) {
- return entity_load('custom_block', $bid);
+function custom_block_load($id) {
+ return entity_load('custom_block', $id);
}
/**
diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php
index 1161475..c3957c3 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php
@@ -28,7 +28,7 @@ protected function prepareEntity(EntityInterface $block) {
// Set up default values, if required.
$block_type = entity_load('custom_block_type', $block->type->value);
// If this is a new custom block, fill in the default values.
- if (isset($block->bid->value)) {
+ if (isset($block->id->value)) {
$block->set('log', NULL);
}
// Always use the default revision setting.
@@ -49,7 +49,7 @@ public function form(array $form, array &$form_state, EntityInterface $block) {
// Basic block information.
// These elements are just values so they are not even sent to the client.
- foreach (array('bid', 'vid') as $key) {
+ foreach (array('revision_id', 'id') as $key) {
$form[$key] = array(
'#type' => 'value',
'#value' => $block->$key->value,
@@ -170,7 +170,7 @@ public function submit(array $form, array &$form_state) {
*/
public function save(array $form, array &$form_state) {
$block = $this->getEntity($form_state);
- $insert = empty($block->bid->value);
+ $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);
@@ -185,9 +185,9 @@ public function save(array $form, array &$form_state) {
drupal_set_message(t('@type %info has been updated.', $t_args));
}
- if ($block->bid->value) {
- $form_state['values']['bid'] = $block->bid->value;
- $form_state['bid'] = $block->bid->value;
+ if ($block->id->value) {
+ $form_state['values']['id'] = $block->id->value;
+ $form_state['id'] = $block->id->value;
if ($insert) {
if ($theme = $block->getTheme()) {
$form_state['redirect'] = 'admin/structure/block/add/custom_block:' . $block->machine_name->value . '/' . $theme;
diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php
index de54c84..4a36e49 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php
@@ -22,7 +22,7 @@ class CustomBlockRenderController extends EntityRenderController {
protected function alterBuild(array &$build, EntityInterface $entity, EntityDisplay $display, $view_mode, $langcode = NULL) {
parent::alterBuild($build, $entity, $display, $view_mode, $langcode);
// Add contextual links for this custom block, except when the block.
- if (!empty($entity->bid->value) && $view_mode == 'full') {
+ if (!empty($entity->id->value) && $view_mode == 'full') {
$build['#contextual_links']['custom_block'] = array('block', array($entity->machine_name->value));
}
}
diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockStorageController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockStorageController.php
index 0e70a70..6a3bf05 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockStorageController.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockStorageController.php
@@ -2,7 +2,7 @@
/**
* @file
- * Contains \Drupal\custom_block\CustomBlockStorageController.
+ * tom_block\CustomBlockStorageController.
*/
namespace Drupal\custom_block;
@@ -77,7 +77,7 @@ function postSave(EntityInterface $block, $update) {
* Implements \Drupal\Core\Entity\DataBaseStorageControllerNG::basePropertyDefinitions().
*/
public function baseFieldDefinitions() {
- $properties['bid'] = array(
+ $properties['id'] = array(
'label' => t('ID'),
'description' => t('The custom block ID.'),
'type' => 'integer_field',
@@ -88,7 +88,7 @@ public function baseFieldDefinitions() {
'description' => t('The custom block UUID.'),
'type' => 'string_field',
);
- $properties['vid'] = array(
+ $properties['revision_id'] = array(
'label' => t('Revision ID'),
'description' => t('The revision ID.'),
'type' => 'integer_field',
diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php
index baff249..5688366 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Core/Entity/CustomBlock.php
@@ -33,8 +33,8 @@
* menu_base_path = "block/%custom_block_machine_name",
* fieldable = TRUE,
* entity_keys = {
- * "id" = "bid",
- * "revision" = "vid",
+ * "id" = "id",
+ * "revision" = "revision_id",
* "bundle" = "type",
* "label" = "info",
* "uuid" = "uuid"
@@ -51,14 +51,14 @@ class CustomBlock extends EntityNG implements ContentEntityInterface {
*
* @var \Drupal\Core\Entity\Field\FieldInterface
*/
- public $bid;
+ public $id;
/**
* The block revision ID.
*
* @var \Drupal\Core\Entity\Field\FieldInterface
*/
- public $vid;
+ public $revision_id;
/**
* Indicates whether this is the default block revision.
@@ -128,7 +128,7 @@ class CustomBlock extends EntityNG implements ContentEntityInterface {
* Implements Drupal\Core\Entity\EntityInterface::id().
*/
public function id() {
- return $this->bid->value;
+ return $this->id->value;
}
/**
@@ -143,8 +143,8 @@ public function bundle() {
*/
public function createDuplicate() {
$duplicate = parent::createDuplicate();
- $duplicate->vid->value = NULL;
- $duplicate->bid->value = NULL;
+ $duplicate->revision_id->value = NULL;
+ $duplicate->id->value = NULL;
$duplicate->machine_name->value = NULL;
return $duplicate;
}
@@ -153,7 +153,7 @@ public function createDuplicate() {
* Overrides Drupal\Core\Entity\Entity::getRevisionId().
*/
public function getRevisionId() {
- return $this->vid->value;
+ return $this->revision_id->value;
}
/**
@@ -190,9 +190,9 @@ public function getTheme() {
protected function init() {
parent::init();
// We unset all defined properties, so magic getters apply.
- unset($this->bid);
+ unset($this->id);
unset($this->info);
- unset($this->vid);
+ unset($this->revision_id);
unset($this->log);
unset($this->machine_name);
unset($this->uuid);
diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php
index bfa7f9b..a4cfa66 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/block/block/CustomBlock.php
@@ -82,7 +82,7 @@ public function build() {
else {
return array(
'#markup' => t('Block with name %name does not exist. Add custom block.', array(
- '%name' => $block_id,
+ '%name' => $machine_name,
'!url' => url('block/add')
)),
'#access' => user_access('administer blocks')
diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php
index ab873ac..71ee742 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCreationTest.php
@@ -82,21 +82,21 @@ public function testFailedBlockCreation() {
if (Database::getConnection()->supportsTransactions()) {
// Check that the block does not exist in the database.
- $bid = db_select('custom_block', 'b')
- ->fields('b', array('bid'))
+ $id = db_select('custom_block', 'b')
+ ->fields('b', array('id'))
->condition('info', 'fail_creation')
->execute()
->fetchField();
- $this->assertFalse($bid, 'Transactions supported, and block not found in database.');
+ $this->assertFalse($id, 'Transactions supported, and block not found in database.');
}
else {
// Check that the block exists in the database.
- $bid = db_select('custom_block', 'b')
- ->fields('b', array('bid'))
+ $id = db_select('custom_block', 'b')
+ ->fields('b', array('id'))
->condition('info', 'fail_creation')
->execute()
->fetchField();
- $this->assertTrue($bid, 'Transactions not supported, and block found in database.');
+ $this->assertTrue($id, 'Transactions not supported, and block found in database.');
// Check that the failed rollback was logged.
$records = db_query("SELECT wid FROM {watchdog} WHERE message LIKE 'Explicit rollback failed%'")->fetchAll();
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
index af296f3..717d659 100644
--- 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
@@ -47,10 +47,10 @@ public function testHookCustomBlockLoad() {
// 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_bids, array(
- $custom_block1->bid->value,
- $custom_block2->bid->value,
- $custom_block3->bid->value
+ $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.');
@@ -59,11 +59,11 @@ public function testHookCustomBlockLoad() {
// 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_bids, array(
- $custom_block1->bid->value,
- $custom_block2->bid->value,
- $custom_block3->bid->value,
- $custom_block4->bid->value
+ $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/custom_block/lib/Drupal/custom_block/Tests/CustomBlockRevisionsTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockRevisionsTest.php
index bc19fa4..ac995ea 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockRevisionsTest.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockRevisionsTest.php
@@ -38,7 +38,7 @@ public function setUp() {
$logs = array();
// Get original block.
- $blocks[] = $block->vid->value;
+ $blocks[] = $block->revision_id->value;
$logs[] = '';
// Create three revisions.
@@ -47,7 +47,7 @@ public function setUp() {
$block->setNewRevision(TRUE);
$logs[] = $block->log->value = $this->randomName(32);
$block->save();
- $blocks[] = $block->vid->value;
+ $blocks[] = $block->revision_id->value;
}
$this->blocks = $blocks;
@@ -61,12 +61,12 @@ public function testRevisions() {
$blocks = $this->blocks;
$logs = $this->logs;
- foreach ($blocks as $delta => $vid) {
+ foreach ($blocks as $delta => $revision_id) {
// Confirm the correct revision text appears.
- $loaded = entity_revision_load('custom_block', $vid);
+ $loaded = entity_revision_load('custom_block', $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->vid->value
+ '!revision' => $loaded->revision_id->value
)));
}
@@ -81,12 +81,12 @@ public function testRevisions() {
$loaded->block_body = $this->randomName(8);
$loaded->save();
- $this->drupalGet('block/' . $loaded->bid->value);
+ $this->drupalGet('block/' . $loaded->id->value);
$this->assertNoText($loaded->block_body->value, 'Revision body text is not present on default version of block.');
- // Verify that the non-default revision vid is greater than the default
- // revision vid.
- $default_revision = entity_load('custom_block', $loaded->bid->value);
- $this->assertTrue($loaded->vid->value > $default_revision->vid->value, 'Revision vid is greater than default revision vid.');
+ // Verify that the non-default revision id is greater than the default
+ // revision id.
+ $default_revision = entity_load('custom_block', $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_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php
index 6dc1707..0cf1074 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockSaveTest.php
@@ -43,26 +43,26 @@ public function setUp() {
*/
public function testImport() {
// Custom block ID must be a number that is not in the database.
- $max_bid = db_query('SELECT MAX(bid) FROM {custom_block}')->fetchField();
- $test_bid = $max_bid + mt_rand(1000, 1000000);
+ $max_id = db_query('SELECT MAX(id) FROM {custom_block}')->fetchField();
+ $test_id = $max_id + mt_rand(1000, 1000000);
$info = $this->randomName(8);
$block = array(
'info' => $info,
'machine_name' => $info,
'block_body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->randomName(32)))),
'type' => 'basic',
- 'bid' => $test_bid
+ 'id' => $test_id
);
$block = entity_create('custom_block', $block);
$block->enforceIsNew(TRUE);
$block->save();
- // Verify that block_submit did not wipe the provided bid.
- $this->assertEqual($block->bid->value, $test_bid, 'Block imported using provide bid');
+ // Verify that block_submit did not wipe the provided id.
+ $this->assertEqual($block->id->value, $test_id, 'Block imported using provide id');
// Test the import saved.
- $block_by_bid = custom_block_load($test_bid);
- $this->assertTrue($block_by_bid, 'Custom block load by block ID.');
+ $block_by_id = custom_block_load($test_id);
+ $this->assertTrue($block_by_id, 'Custom block load by block ID.');
}
/**
@@ -88,7 +88,7 @@ public function testDeterminingChanges() {
$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->bid->value);
+ $block = custom_block_load($block->id->value);
$this->assertEqual($block->label(), 'updated_presave', 'Static cache has been cleared.');
}
@@ -105,6 +105,6 @@ public function testCustomBlockSaveOnInsert() {
// custom_block_test_custom_block_insert() tiggers a save on insert if the
// title equals 'new'.
$block = $this->createCustomBlock('new');
- $this->assertEqual($block->label(), 'CustomBlock ' . $block->bid->value, 'Custom block saved on block insert.');
+ $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/PageEditTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/PageEditTest.php
index 4ce012a..ad8246e 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/PageEditTest.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/PageEditTest.php
@@ -27,7 +27,6 @@ public static function getInfo() {
* Sets the test up.
*/
public function setUp() {
- $this->permissions[] = 'view custom blocks';
parent::setUp();
}
@@ -51,17 +50,8 @@ public function testPageEdit() {
$block = entity_load('custom_block', reset($blocks));
$this->assertTrue($block, 'Custom block found in database.');
- // Check that "edit" link points to correct page.
- $this->drupalGet('block/' . $block->machine_name->value);
- $this->clickLink(t('Edit'));
- $edit_url = url("block/" . $block->machine_name->value . "/edit", array('absolute' => TRUE));
- $actual_url = $this->getURL();
- $this->assertEqual($edit_url, $actual_url, 'On edit page.');
-
- // Check that the title and body fields are displayed with the correct values.
- $active = '' . t('(active tab)') . '';
- $link_text = t('!local-task-title!active', array('!local-task-title' => t('Edit'), '!active' => $active));
- $this->assertText(strip_tags($link_text), 0, 'Edit tab found and marked active.');
+ // Load the edit page.
+ $this->drupalGet('block/' . $block->machine_name->value . '/edit');
$this->assertFieldByName($title_key, $edit[$title_key], 'Title field displayed.');
$this->assertFieldByName($body_key, $edit[$body_key], 'Body field displayed.');
@@ -72,11 +62,6 @@ public function testPageEdit() {
// Stay on the current page, without reloading.
$this->drupalPost(NULL, $edit, t('Save'));
- // Check that the title and body fields are displayed with the updated values.
- $this->drupalGet('block/' . $block->machine_name->value);
- $this->assertText($edit[$title_key], 'Title displayed.');
- $this->assertText($edit[$body_key], 'Body displayed.');
-
// Edit the same block, creating a new revision.
$this->drupalGet("block/" . $block->machine_name->value . "/edit");
$edit = array();
@@ -86,7 +71,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->bid->value, TRUE);
- $this->assertNotIdentical($block->vid->value, $revised_block->vid->value, 'A new revision has been created.');
+ $revised_block = entity_load('custom_block', $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.module b/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module
index 83e3f4f..76bccdc 100644
--- a/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module
+++ b/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module
@@ -17,11 +17,11 @@ function custom_block_test_custom_block_load($custom_blocks, $types) {
// Add properties to each loaded custom_block 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.
- $bids = array_keys($custom_blocks);
- ksort($bids);
+ $ids = array_keys($custom_blocks);
+ ksort($ids);
sort($types);
foreach ($custom_blocks as $custom_block) {
- $custom_block->custom_block_test_loaded_bids = $bids;
+ $custom_block->custom_block_test_loaded_ids = $ids;
$custom_block->custom_block_test_loaded_types = $types;
}
}
@@ -73,7 +73,7 @@ function custom_block_test_custom_block_update(CustomBlock $custom_block) {
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->info->value == 'new') {
- $custom_block->info->value = 'CustomBlock '. $custom_block->bid->value;
+ $custom_block->info->value = 'CustomBlock '. $custom_block->id->value;
$custom_block->save();
}
if ($custom_block->info->value == 'fail_creation') {