Loading core/lib/Drupal/Core/Block/BlockPluginInterface.php +13 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,19 @@ public function access(AccountInterface $account, $return_as_object = FALSE); */ public function build(); /** * Whether to render blocks in a placeholder. * * When blocks of this type are rendered, indicate whether they should be * rendered in a placeholder or not. In general, blocks that attach libraries * and/or render entities should be placeholdered to optimize various aspects * of rendering performance. * * @return bool * Whether to placeholder blocks of this plugin type. */ public function createPlaceholder(): bool; /** * Sets a particular value in the block settings. * Loading core/lib/Drupal/Core/Block/BlockPluginTrait.php +7 −0 Original line number Diff line number Diff line Loading @@ -296,4 +296,11 @@ public function setInPreview(bool $in_preview): void { $this->inPreview = $in_preview; } /** * {@inheritdoc} */ public function createPlaceholder(): bool { return FALSE; } } core/lib/Drupal/Core/Menu/Plugin/Block/LocalActionsBlock.php +7 −0 Original line number Diff line number Diff line Loading @@ -83,4 +83,11 @@ public function build() { return $local_actions; } /** * {@inheritdoc} */ public function createPlaceholder(): bool { return TRUE; } } core/lib/Drupal/Core/Menu/Plugin/Block/LocalTasksBlock.php +7 −0 Original line number Diff line number Diff line Loading @@ -165,4 +165,11 @@ public function blockSubmit($form, FormStateInterface $form_state) { $this->configuration['secondary'] = $levels['secondary']; } /** * {@inheritdoc} */ public function createPlaceholder(): bool { return TRUE; } } core/modules/block/src/BlockViewBuilder.php +7 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,13 @@ public function viewMultiple(array $entities = [], $view_mode = 'full', $langcod $build[$entity_id] += [ '#lazy_builder' => [static::class . '::lazyBuilder', [$entity_id, $view_mode, $langcode]], ]; // Only add create_placeholder if it's explicitly set to TRUE, so it can // be set to TRUE by automatic placeholdering conditions if it's absent. if ($plugin->createPlaceholder()) { $build[$entity_id] += [ '#create_placeholder' => TRUE, ]; } } } Loading Loading
core/lib/Drupal/Core/Block/BlockPluginInterface.php +13 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,19 @@ public function access(AccountInterface $account, $return_as_object = FALSE); */ public function build(); /** * Whether to render blocks in a placeholder. * * When blocks of this type are rendered, indicate whether they should be * rendered in a placeholder or not. In general, blocks that attach libraries * and/or render entities should be placeholdered to optimize various aspects * of rendering performance. * * @return bool * Whether to placeholder blocks of this plugin type. */ public function createPlaceholder(): bool; /** * Sets a particular value in the block settings. * Loading
core/lib/Drupal/Core/Block/BlockPluginTrait.php +7 −0 Original line number Diff line number Diff line Loading @@ -296,4 +296,11 @@ public function setInPreview(bool $in_preview): void { $this->inPreview = $in_preview; } /** * {@inheritdoc} */ public function createPlaceholder(): bool { return FALSE; } }
core/lib/Drupal/Core/Menu/Plugin/Block/LocalActionsBlock.php +7 −0 Original line number Diff line number Diff line Loading @@ -83,4 +83,11 @@ public function build() { return $local_actions; } /** * {@inheritdoc} */ public function createPlaceholder(): bool { return TRUE; } }
core/lib/Drupal/Core/Menu/Plugin/Block/LocalTasksBlock.php +7 −0 Original line number Diff line number Diff line Loading @@ -165,4 +165,11 @@ public function blockSubmit($form, FormStateInterface $form_state) { $this->configuration['secondary'] = $levels['secondary']; } /** * {@inheritdoc} */ public function createPlaceholder(): bool { return TRUE; } }
core/modules/block/src/BlockViewBuilder.php +7 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,13 @@ public function viewMultiple(array $entities = [], $view_mode = 'full', $langcod $build[$entity_id] += [ '#lazy_builder' => [static::class . '::lazyBuilder', [$entity_id, $view_mode, $langcode]], ]; // Only add create_placeholder if it's explicitly set to TRUE, so it can // be set to TRUE by automatic placeholdering conditions if it's absent. if ($plugin->createPlaceholder()) { $build[$entity_id] += [ '#create_placeholder' => TRUE, ]; } } } Loading