Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The build() method of a breadcrumb builder gets given a $route_match parameter, presumably to use to create the breadcrumb.
However, PathBasedBreadcrumbBuilder completely ignores that and instead gets the actual current path from the context:
$path = trim($this->context->getPathInfo(), '/');
This means that PathBasedBreadcrumbBuilder can't be used in any other contexts, for example to create the breadcrumb for another route to use as the basis for another breadcrumb builder.
Comment | File | Size | Author |
---|---|---|---|
#9 | interdiff-6-9.txt | 1.11 KB | idebr |
#9 | 2884217-9.patch | 4.11 KB | idebr |
Comments
Comment #3
seanBFound this stackexchange link that could be used as a workaround. Would be nice to get this fixed though.
https://drupal.stackexchange.com/questions/191548/how-do-i-build-breadcr...
I'll see if I can work on a patch.
Comment #4
seanBPlease review!
Comment #6
seanBFixed the tests and added extra test coverage for the custom route match.
Comment #8
borisson_I don't think the
->will
is needed, because nothing can get returned if this is supposed to never be called.Otherwise I think this testcoverage is sufficient and I'm really sorry about bumping this back after months of inactivity with such a small nitpick.
Comment #9
idebr CreditAttribution: idebr at iO commented#8 Removed the
->will
method, as it does not get called.Also replaced the call to the deprecated
->getMock()
method, see #2795317: Allow PHPUnit 6+ support for object mockingComment #18
Simon Georges CreditAttribution: Simon Georges at Makina Corpus commented