I've tried to define a new breadcrumb override, but I'm still getting the site default.
I've created a custom module, foo_breadcrumb:
- modules/custom/foo_breadcrumb
- foo_breadcrumb.info.yml
- foo_breadcrumb.services.yml
- src/
- BreadcrumbBuild.php
Here's the foo_breadcrumb.services.yml
:
services:
foo_breadcrumb.breadcrumb:
class: Drupal\foo_breadcrumb\BreadcrumbBuild
tags:
- { name: breadcrumb_builder, priority: 100 }
Inside src/BreadcrumbBuild.php
, I have:
<?php
namespace Drupal\foo_breadcrumb;
use Drupal\Core\Breadcrumb\BreadcrumbBuilderBase;
class BreadcrumbBuild implements BreadcrumbManager {
/**
* {@inheritdoc}
*/
public function applies(array $attributes) {
return true;
}
/**
* {@inheritdoc}
*/
public function build(array $attributes) {
$breadcrumb[] = $this->l($this->t('Test'), NULL);
$breadcrumb[] = $this->l($this->t('Test2'), 'test');
return $breadcrumb;
}
}
?>
I started working off the only writeup I could find on Drupal 8 breadcrumbs, but the thing is it appears to be using an older version of the PSR-4 autoloading that is no longer in place (for the record I'm on 8.0.0-dev-beta3), and so I went by how all the other modules work in the codebase.
Now I'm fairly certain this correct to get the module to load; however I'm not sure if
class BreadcrumbBuild extends BreadcrumbBuilderBase
is correct. The problem is that the old tutorial I linked to mentions extending from BreadcrumbBuilderBase
, but the more current docs don't seem to mention it and I wonder if it's out of date - and how I should do this.
Likewise, I don't really understand what the services.yml
file is doing in this regard, there's no documentation anywhere for this.