XF 2.2 Overriding breadcrumb links?


Active member
I had a thread a couple of weeks ago where I am overriding how link building for thread works using the router_public_setup code even listener:

Now I thought I could use the same mechanism for overriding breadcrumb links to special type of forums/nodes but I found that breadcrumb links do not work this way.

snippet from Entity/Node.php:
        public function getBreadcrumbs($includeSelf = true, $linkType = 'public')
                /** @var \XF\Mvc\Router $router */
                $router = $this->app()->container('router.' . $linkType);
                $nodeTypes = $this->app()->container('nodeTypes');
                                $route = $linkType == 'public' ? $nodeType['public_route'] : $nodeType['admin_route'];

                                $output[] = [
                                        'value' => $crumb['title'],
                                        'href' => $router->buildLink($route, $crumb),
                                        'node_id' => $crumb['node_id']

(So looking at this code, I realized I was probably doing this entire thing the wrong way and I should be adding a new Node Type but I couldn't find any examples of how to add custom node type and my experiment adding an entry in the xf_node_type table didn't work. If anyone has any examples of this, please share.)

So I get that I need to override this function in my extended class but it looks like I just need to straight up copy-paste it and add in my modification? Because what I really need to do is modify the $route when a custom node property matches my condition (I've already extended Service\Node\RebuildNestedSet to add the custom node property).

The other way I can think of is stubbing out app() in my Node class extension but that also feels like I'm going overboard.

Any pointers?