core/lib/Drupal/Core/Block/TitleBlockPluginInterface.php | 2 ++ .../Core/Render/Plugin/DisplayVariant/SimplePageVariant.php | 5 +++-- .../block/src/Plugin/DisplayVariant/BlockPageVariant.php | 5 +++-- .../src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php | 6 ++++-- .../block_content/src/Tests/BlockContentTranslationUITest.php | 1 + core/modules/comment/src/Tests/CommentTranslationUITest.php | 1 + .../src/Tests/ContentTestTranslationUITest.php | 1 + .../src/Tests/MenuLinkContentTranslationUITest.php | 2 +- core/modules/node/src/Tests/NodeTranslationUITest.php | 6 +----- core/modules/system/src/Plugin/Block/SystemPageTitleBlock.php | 10 ++-------- core/modules/system/system.module | 5 +---- 11 files changed, 20 insertions(+), 24 deletions(-) diff --git a/core/lib/Drupal/Core/Block/TitleBlockPluginInterface.php b/core/lib/Drupal/Core/Block/TitleBlockPluginInterface.php index f4deff0..229300f 100644 --- a/core/lib/Drupal/Core/Block/TitleBlockPluginInterface.php +++ b/core/lib/Drupal/Core/Block/TitleBlockPluginInterface.php @@ -13,6 +13,8 @@ * A title block shows the title returned by the controller. * * @ingroup block_api + * + * @see \Drupal\Core\Render\Element\PageTitle */ interface TitleBlockPluginInterface extends BlockPluginInterface { diff --git a/core/lib/Drupal/Core/Render/Plugin/DisplayVariant/SimplePageVariant.php b/core/lib/Drupal/Core/Render/Plugin/DisplayVariant/SimplePageVariant.php index 6e0e98e..183f9e3 100644 --- a/core/lib/Drupal/Core/Render/Plugin/DisplayVariant/SimplePageVariant.php +++ b/core/lib/Drupal/Core/Render/Plugin/DisplayVariant/SimplePageVariant.php @@ -54,14 +54,15 @@ public function setTitle($title) { * {@inheritdoc} */ public function build() { - $title = is_array($this->title) ? $this->title : ['#markup' => $this->title]; $build = [ 'content' => [ 'page_title' => [ + '#type' => 'page_title', + '#title' => $this->title, '#prefix' => '

', '#suffix' => '

', '#weight' => -900, - ] + $title, + ], 'main_content' => $this->mainContent, 'messages' => [ '#type' => 'status_messages', diff --git a/core/modules/block/src/Plugin/DisplayVariant/BlockPageVariant.php b/core/modules/block/src/Plugin/DisplayVariant/BlockPageVariant.php index c74c858..6d734a1 100644 --- a/core/modules/block/src/Plugin/DisplayVariant/BlockPageVariant.php +++ b/core/modules/block/src/Plugin/DisplayVariant/BlockPageVariant.php @@ -189,12 +189,13 @@ public function build() { // Analogously for the page title. if (!$title_block_displayed) { - $title = is_array($this->title) ? $this->title : ['#markup' => $this->title]; $build['content']['page_title'] = [ + '#type' => 'page_title', + '#title' => $this->title, '#prefix' => '

', '#suffix' => '

', '#weight' => -900, - ] + $title; + ]; } // The access results' cacheability is currently added to the top level of the diff --git a/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php b/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php index 0abab9a..5adf2f1 100644 --- a/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php +++ b/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php @@ -192,10 +192,11 @@ public function providerBuild() { '#type' => 'status_messages', ], 'page_title' => [ + '#type' => 'page_title', + '#title' => 'Hi cats!', '#prefix' => '

', '#suffix' => '

', '#weight' => -900, - '#markup' => 'Hi cats!', ], ], ], @@ -271,10 +272,11 @@ public function testBuildWithoutMainContent() { '#type' => 'status_messages', ], 'page_title' => [ + '#type' => 'page_title', + '#title' => 'Hi llamas!', '#prefix' => '

', '#suffix' => '

', '#weight' => -900, - '#markup' => 'Hi llamas!', ], ], ]; diff --git a/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php b/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php index 964f0f9..317baf2 100644 --- a/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php +++ b/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php @@ -35,6 +35,7 @@ class BlockContentTranslationUITest extends ContentTranslationUITestBase { */ protected $defaultCacheContexts = [ 'languages:language_interface', + 'route', 'theme', 'url.path', 'url.query_args', diff --git a/core/modules/comment/src/Tests/CommentTranslationUITest.php b/core/modules/comment/src/Tests/CommentTranslationUITest.php index 6397c69..c0791df 100644 --- a/core/modules/comment/src/Tests/CommentTranslationUITest.php +++ b/core/modules/comment/src/Tests/CommentTranslationUITest.php @@ -37,6 +37,7 @@ class CommentTranslationUITest extends ContentTranslationUITestBase { */ protected $defaultCacheContexts = [ 'languages:language_interface', + 'route', 'theme', 'timezone', 'url.query_args:_wrapper_format', diff --git a/core/modules/content_translation/src/Tests/ContentTestTranslationUITest.php b/core/modules/content_translation/src/Tests/ContentTestTranslationUITest.php index 08b1d4a..aef2512 100644 --- a/core/modules/content_translation/src/Tests/ContentTestTranslationUITest.php +++ b/core/modules/content_translation/src/Tests/ContentTestTranslationUITest.php @@ -31,6 +31,7 @@ class ContentTestTranslationUITest extends ContentTranslationUITestBase { */ protected $defaultCacheContexts = [ 'languages:language_interface', + 'route', 'theme', 'url.path', 'url.query_args', diff --git a/core/modules/menu_link_content/src/Tests/MenuLinkContentTranslationUITest.php b/core/modules/menu_link_content/src/Tests/MenuLinkContentTranslationUITest.php index 1404384..f75586e 100644 --- a/core/modules/menu_link_content/src/Tests/MenuLinkContentTranslationUITest.php +++ b/core/modules/menu_link_content/src/Tests/MenuLinkContentTranslationUITest.php @@ -20,7 +20,7 @@ class MenuLinkContentTranslationUITest extends ContentTranslationUITestBase { /** * {inheritdoc} */ - protected $defaultCacheContexts = ['languages:language_interface', 'theme', 'url.path', 'url.query_args', 'user.permissions', 'user.roles:authenticated']; + protected $defaultCacheContexts = ['languages:language_interface', 'route', 'theme', 'url.path', 'url.query_args', 'user.permissions', 'user.roles:authenticated']; /** * Modules to enable. diff --git a/core/modules/node/src/Tests/NodeTranslationUITest.php b/core/modules/node/src/Tests/NodeTranslationUITest.php index bcb9de9..509a0d1 100644 --- a/core/modules/node/src/Tests/NodeTranslationUITest.php +++ b/core/modules/node/src/Tests/NodeTranslationUITest.php @@ -27,11 +27,7 @@ class NodeTranslationUITest extends ContentTranslationUITestBase { protected $defaultCacheContexts = [ 'languages:language_interface', 'theme', - 'route.name', - 'route.menu_active_trails:account', - 'route.menu_active_trails:footer', - 'route.menu_active_trails:main', - 'route.menu_active_trails:tools', + 'route', 'timezone', 'url', 'user' diff --git a/core/modules/system/src/Plugin/Block/SystemPageTitleBlock.php b/core/modules/system/src/Plugin/Block/SystemPageTitleBlock.php index 128151c..973fdea 100644 --- a/core/modules/system/src/Plugin/Block/SystemPageTitleBlock.php +++ b/core/modules/system/src/Plugin/Block/SystemPageTitleBlock.php @@ -48,15 +48,9 @@ public function defaultConfiguration() { */ public function build() { return [ - 'title' => is_array($this->title) ? $this->title : ['#markup' => $this->title], + '#type' => 'page_title', + '#title' => $this->title, ]; } - /** - * {@inheritdoc} - */ - public function getCacheContexts() { - return ['route']; - } - } diff --git a/core/modules/system/system.module b/core/modules/system/system.module index a3b0174..d5dae88 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -815,10 +815,7 @@ function system_preprocess_block(&$variables) { break; case 'system_page_title_block': - $variables['title'] = ''; - if ($variables['content']['title']['#markup']) { - $variables['title'] = $variables['content']['title']['#markup']; - } + $variables['title'] = $variables['content']; break; } }