SystemBreadcrumbBlock.php in Drupal 9
File
core/modules/system/src/Plugin/Block/SystemBreadcrumbBlock.php
View source
<?php
namespace Drupal\system\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class SystemBreadcrumbBlock extends BlockBase implements ContainerFactoryPluginInterface {
protected $breadcrumbManager;
protected $routeMatch;
public function __construct(array $configuration, $plugin_id, $plugin_definition, BreadcrumbBuilderInterface $breadcrumb_manager, RouteMatchInterface $route_match) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->breadcrumbManager = $breadcrumb_manager;
$this->routeMatch = $route_match;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('breadcrumb'), $container
->get('current_route_match'));
}
public function build() {
return $this->breadcrumbManager
->build($this->routeMatch)
->toRenderable();
}
}