Commit 5e6c455e authored by alexpott's avatar alexpott

Issue #2321593 by Temoor: Replace all instances of block_load(),...

Issue #2321593 by Temoor: Replace all instances of block_load(), entity_load('block') and entity_load_multiple('block') with static method calls.
parent 5f37ebc4
......@@ -9,6 +9,7 @@
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\system\Entity\Menu;
use Drupal\block\Entity\Block;
/**
* Implements hook_help().
......@@ -298,7 +299,7 @@ function template_preprocess_block(&$variables) {
* Removes deleted role from blocks that use it.
*/
function block_user_role_delete($role) {
foreach (entity_load_multiple('block') as $block) {
foreach (Block::loadMultiple() as $block) {
/** @var $block \Drupal\block\BlockInterface */
$visibility = $block->getVisibility();
if (isset($visibility['user_role']['roles'][$role->id()])) {
......@@ -314,7 +315,7 @@ function block_user_role_delete($role) {
*/
function block_menu_delete(Menu $menu) {
if (!$menu->isSyncing()) {
foreach (entity_load_multiple('block') as $block) {
foreach (Block::loadMultiple() as $block) {
if ($block->get('plugin') == 'system_menu_block:' . $menu->id()) {
$block->delete();
}
......@@ -329,7 +330,7 @@ function block_menu_delete(Menu $menu) {
*/
function block_configurable_language_delete(ConfigurableLanguage $language) {
// Remove the block visibility settings for the deleted language.
foreach (entity_load_multiple('block') as $block) {
foreach (Block::loadMultiple() as $block) {
/** @var $block \Drupal\block\BlockInterface */
$visibility = $block->getVisibility();
if (isset($visibility['language']['langcodes'][$language->id()])) {
......
......@@ -399,7 +399,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
* Form submission handler for the main block administration form.
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$entities = entity_load_multiple('block', array_keys($form_state->getValue('blocks')));
$entities = $this->storage->loadMultiple(array_keys($form_state->getValue('blocks')));
foreach ($entities as $entity_id => $entity) {
$entity_values = $form_state->getValue(array('blocks', $entity_id));
$entity->set('weight', $entity_values['weight']);
......
......@@ -8,6 +8,7 @@
namespace Drupal\block\Tests;
use Drupal\simpletest\WebTestBase;
use Drupal\block\Entity\Block;
/**
* Tests that an active block assigned to a non-existing region triggers the
......@@ -55,7 +56,7 @@ function testBlockInInvalidRegion() {
$this->assertNoRaw($warning_message, 'Disabled block in the invalid region will not trigger the warning.');
// Place disabled test block in the invalid region of the default theme.
$block = entity_load('block', $block->id());
$block = Block::load($block->id());
$block->set('region', 'invalid_region');
$block->save();
......
......@@ -8,6 +8,7 @@
namespace Drupal\block\Tests;
use Drupal\simpletest\WebTestBase;
use Drupal\block\Entity\Block;
/**
* Tests if a block can be configure to be only visibile on a particular
......@@ -104,7 +105,7 @@ public function testLanguageBlockVisibilityLanguageDelete() {
// Check that the language is no longer stored in the configuration after
// it is deleted.
$block = entity_load('block', $block->id());
$block = Block::load($block->id());
$visibility = $block->getVisibility();
$this->assertTrue(empty($visibility['language']['langcodes']['fr']), 'Language is no longer not set in the block configuration after deleting the block.');
}
......
......@@ -10,6 +10,7 @@
use Drupal\Core\Cache\Cache;
use Drupal\simpletest\WebTestBase;
use Drupal\Component\Utility\String;
use Drupal\block\Entity\Block;
/**
* Tests basic block functionality.
......@@ -106,7 +107,7 @@ function testBlock() {
$this->drupalPostForm('admin/structure/block/add/' . $block['id'] . '/' . $block['theme'], array('settings[label]' => $block['settings[label]'], 'id' => $block['id'], 'region' => $block['region']), t('Save block'));
$this->assertText(t('The block configuration has been saved.'), 'Block title set.');
// Check to see if the block was created by checking its configuration.
$instance = entity_load('block', $block['id']);
$instance = Block::load($block['id']);
$this->assertEqual($instance->label(), $block['settings[label]'], 'Stored block title found.');
......
......@@ -13,6 +13,7 @@
use Drupal\simpletest\DrupalUnitTestBase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Drupal\block\Entity\Block;
/**
* Tests the block view builder.
......@@ -79,7 +80,7 @@ public function testBasicRendering() {
$entity->save();
// Test the rendering of a block.
$entity = entity_load('block', 'test_block1');
$entity = Block::load('test_block1');
$output = entity_view($entity, 'block');
$expected = array();
$expected[] = '<div class="block block-block-test" id="block-test-block1">';
......
......@@ -9,6 +9,7 @@
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate_drupal\Tests\MigrateDrupalTestBase;
use Drupal\block\Entity\Block;
/**
* Upgrade block settings to block.block.*.yml.
......@@ -81,8 +82,7 @@ protected function setUp() {
* Test the block settings migration.
*/
public function testBlockMigration() {
/** @var $blocks \Drupal\block\BlockInterface[] */
$blocks = entity_load_multiple('block');
$blocks = Block::loadMultiple();
$this->assertEqual(count($blocks), 8);
// User blocks
......
......@@ -11,6 +11,7 @@
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Core\Database\Database;
use Drupal\Core\Language\LanguageInterface;
use Drupal\block\Entity\Block;
/**
* Tests the invocation of hooks when creating, inserting, loading, updating or
......@@ -101,7 +102,7 @@ public function testBlockHooks() {
));
$_SESSION['entity_crud_hook_test'] = array();
$entity = entity_load('block', $entity->id());
$entity = Block::load($entity->id());
$this->assertHookMessageOrder(array(
'entity_crud_hook_test_entity_load called for type block',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment