diff --git a/core/includes/entity.inc b/core/includes/entity.inc index 69a07d7..d48aa4e 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -538,7 +538,7 @@ function entity_get_display($entity_type, $bundle, $view_mode) { */ function entity_get_form_display($entity_type, $bundle, $form_mode) { // Try loading the entity from configuration. - $entity_form_display = EntityFormDisplay::load($entity_type . '.' . $bundle . '.' . $form_mode); + $entity_form_display = entity_load('entity_form_display', $entity_type . '.' . $bundle . '.' . $form_mode); // If not found, create a fresh entity object. We do not preemptively create // new entity form display configuration entries for each existing entity type diff --git a/core/lib/Drupal/Core/Entity/Controller/EntityController.php b/core/lib/Drupal/Core/Entity/Controller/EntityController.php index ebee7cc..2ecc637 100644 --- a/core/lib/Drupal/Core/Entity/Controller/EntityController.php +++ b/core/lib/Drupal/Core/Entity/Controller/EntityController.php @@ -230,6 +230,18 @@ public function title(RouteMatchInterface $route_match, EntityInterface $_entity } /** + * Provides a generic callback for Configuration Entities. + * + * @return array + * An empty render array. + */ + public function configController() { + // Configuration entities do not have common view concept so default to an + // empty array. + return []; + } + + /** * Provides a generic edit title callback. * * @param \Drupal\Core\Routing\RouteMatchInterface $route_match diff --git a/core/lib/Drupal/Core/Entity/Routing/EmptyRouteProvider.php b/core/lib/Drupal/Core/Entity/Routing/EmptyRouteProvider.php new file mode 100644 index 0000000..a5926bf --- /dev/null +++ b/core/lib/Drupal/Core/Entity/Routing/EmptyRouteProvider.php @@ -0,0 +1,40 @@ +getLinkTemplate('canonical')) { + $entity_type_id = $entity_type->id(); + $route = new Route($link_template); + $route + ->setDefault('_controller', '\Drupal\Core\Entity\Controller\EntityController::configController') + ->setRequirement('_entity_access', "{$entity_type_id}.view") + ->setOption('parameters', [ + $entity_type_id => ['type' => 'entity:' . $entity_type_id], + ]); + $routes->add("entity.{$entity_type_id}.canonical", $route); + } + return $routes; + } + +} diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 2f96a90..0b6ca26 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -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 = \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(array('theme' => $theme)); + $has_blocks = entity_load_multiple_by_properties('block', 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 = \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(array('theme' => $default_theme)); + $default_theme_blocks = entity_load_multiple_by_properties('block', 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 = \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(['theme' => $theme]); + $blocks = entity_load_multiple_by_properties('block', ['theme' => $theme]); foreach ($blocks as $block_id => $block) { // Disable blocks in invalid regions. $region = $block->getRegion(); diff --git a/core/modules/block/src/BlockViewBuilder.php b/core/modules/block/src/BlockViewBuilder.php index d3f501b..3996282 100644 --- a/core/modules/block/src/BlockViewBuilder.php +++ b/core/modules/block/src/BlockViewBuilder.php @@ -14,7 +14,6 @@ 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; /** @@ -187,7 +186,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(Block::load($entity_id), \Drupal::service('module_handler')); + return static::buildPreRenderableBlock(entity_load('block', $entity_id), \Drupal::service('module_handler')); } /** diff --git a/core/modules/block_content/src/Entity/BlockContent.php b/core/modules/block_content/src/Entity/BlockContent.php index 8c22644..e970e07 100644 --- a/core/modules/block_content/src/Entity/BlockContent.php +++ b/core/modules/block_content/src/Entity/BlockContent.php @@ -113,7 +113,7 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { * {@inheritdoc} */ public function getInstances() { - return \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(array('plugin' => 'block_content:' . $this->uuid())); + return entity_load_multiple_by_properties('block', array('plugin' => 'block_content:' . $this->uuid())); } /** diff --git a/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php b/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php index f10080a..77115e6 100644 --- a/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php +++ b/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php @@ -55,7 +55,7 @@ function testExistingFormat() { $this->drupalGet('admin/config/content/formats/manage/filtered_html'); // Ensure no Editor config entity exists yet. - $editor = Editor::load('filtered_html'); + $editor = entity_load('editor', 'filtered_html'); $this->assertFalse($editor, 'No Editor config entity exists yet.'); // Verify the "Text Editor"