Commit 9aa63fd1 authored by catch's avatar catch

Issue #2723583 by mchampsee, valthebald: Remove entity_load* usage for block entity type

parent d429cd25
......@@ -109,12 +109,12 @@ function block_themes_installed($theme_list) {
*/
function block_theme_initialize($theme) {
// Initialize theme's blocks if none already registered.
$has_blocks = entity_load_multiple_by_properties('block', array('theme' => $theme));
$has_blocks = \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(array('theme' => $theme));
if (!$has_blocks) {
$default_theme = \Drupal::config('system.theme')->get('default');
// Apply only to new theme's visible regions.
$regions = system_region_list($theme, REGIONS_VISIBLE);
$default_theme_blocks = entity_load_multiple_by_properties('block', array('theme' => $default_theme));
$default_theme_blocks = \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(array('theme' => $default_theme));
foreach ($default_theme_blocks as $default_theme_block_id => $default_theme_block) {
if (strpos($default_theme_block_id, $default_theme . '_') === 0) {
$id = str_replace($default_theme, $theme, $default_theme_block_id);
......@@ -141,7 +141,7 @@ function block_rebuild() {
if ($data->status) {
$regions = system_region_list($theme);
/** @var \Drupal\block\BlockInterface[] $blocks */
$blocks = entity_load_multiple_by_properties('block', ['theme' => $theme]);
$blocks = \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(['theme' => $theme]);
foreach ($blocks as $block_id => $block) {
// Disable blocks in invalid regions.
$region = $block->getRegion();
......
......@@ -14,6 +14,7 @@
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Plugin\ContextAwarePluginInterface;
use Drupal\Core\Render\Element;
use Drupal\block\Entity\Block;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......@@ -186,7 +187,7 @@ protected static function buildPreRenderableBlock($entity, ModuleHandlerInterfac
* A render array with a #pre_render callback to render the block.
*/
public static function lazyBuilder($entity_id, $view_mode) {
return static::buildPreRenderableBlock(entity_load('block', $entity_id), \Drupal::service('module_handler'));
return static::buildPreRenderableBlock(Block::load($entity_id), \Drupal::service('module_handler'));
}
/**
......
......@@ -113,7 +113,7 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) {
* {@inheritdoc}
*/
public function getInstances() {
return entity_load_multiple_by_properties('block', array('plugin' => 'block_content:' . $this->uuid()));
return \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(array('plugin' => 'block_content:' . $this->uuid()));
}
/**
......
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