Issue #3104980 by danflanagan8, acbramley: layout_builder_system_breadcrumb_alter doesn't check for a null route object
(cherry picked from commit ef493a71d5
)
merge-requests/1068/merge
parent
58bade981c
commit
e13e5590ed
|
@ -334,7 +334,7 @@ function layout_builder_plugin_filter_layout_alter(array &$definitions, array $e
|
|||
*/
|
||||
function layout_builder_system_breadcrumb_alter(Breadcrumb &$breadcrumb, RouteMatchInterface $route_match, array $context) {
|
||||
// Remove the extra 'Manage display' breadcrumb for Layout Builder defaults.
|
||||
if ($route_match->getRouteObject()->hasOption('_layout_builder') && $route_match->getParameter('section_storage_type') === 'defaults') {
|
||||
if ($route_match->getRouteObject() && $route_match->getRouteObject()->hasOption('_layout_builder') && $route_match->getParameter('section_storage_type') === 'defaults') {
|
||||
$links = array_filter($breadcrumb->getLinks(), function (Link $link) use ($route_match) {
|
||||
$entity_type_id = $route_match->getParameter('entity_type_id');
|
||||
if (!$link->getUrl()->isRouted()) {
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\layout_builder\Kernel;
|
||||
|
||||
use Drupal\Core\Breadcrumb\Breadcrumb;
|
||||
use Drupal\Core\Routing\NullRouteMatch;
|
||||
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
|
||||
|
||||
/**
|
||||
* Tests layout_builder_system_breadcrumb_alter().
|
||||
*
|
||||
* @group layout_builder
|
||||
*/
|
||||
class LayoutBuilderBreadcrumbAlterTest extends EntityKernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $modules = [
|
||||
'layout_builder',
|
||||
'layout_discovery',
|
||||
];
|
||||
|
||||
/**
|
||||
* Check that there are no errors when alter called with null route match.
|
||||
*/
|
||||
public function testBreadcrumbAlterNullRouteMatch() {
|
||||
$breadcrumb = new Breadcrumb();
|
||||
$route_match = new NullRouteMatch();
|
||||
layout_builder_system_breadcrumb_alter($breadcrumb, $route_match, []);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue