3 namespace Drupal\system\Plugin\Block;
5 use Drupal\Core\Block\BlockBase;
6 use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
7 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
8 use Drupal\Core\Routing\RouteMatchInterface;
9 use Symfony\Component\DependencyInjection\ContainerInterface;
12 * Provides a block to display the breadcrumbs.
15 * id = "system_breadcrumb_block",
16 * admin_label = @Translation("Breadcrumbs")
19 class SystemBreadcrumbBlock extends BlockBase implements ContainerFactoryPluginInterface {
22 * The breadcrumb manager.
24 * @var \Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface
26 protected $breadcrumbManager;
29 * The current route match.
31 * @var \Drupal\Core\Routing\RouteMatchInterface
33 protected $routeMatch;
36 * Constructs a new SystemBreadcrumbBlock object.
38 * @param array $configuration
39 * A configuration array containing information about the plugin instance.
40 * @param string $plugin_id
41 * The plugin_id for the plugin instance.
42 * @param mixed $plugin_definition
43 * The plugin implementation definition.
44 * @param \Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface $breadcrumb_manager
45 * The breadcrumb manager.
46 * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
47 * The current route match.
49 public function __construct(array $configuration, $plugin_id, $plugin_definition, BreadcrumbBuilderInterface $breadcrumb_manager, RouteMatchInterface $route_match) {
50 parent::__construct($configuration, $plugin_id, $plugin_definition);
51 $this->breadcrumbManager = $breadcrumb_manager;
52 $this->routeMatch = $route_match;
58 public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
63 $container->get('breadcrumb'),
64 $container->get('current_route_match')
71 public function build() {
72 return $this->breadcrumbManager->build($this->routeMatch)->toRenderable();