Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 14 |
SystemBreadcrumbBlock | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 14 |
__construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 4 |
|||
create | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 8 |
|||
build | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
<?php | |
/** | |
* @file | |
* Contains \Drupal\system\Plugin\Block\SystemBreadcrumbBlock. | |
*/ | |
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; | |
/** | |
* Provides a block to display the breadcrumbs. | |
* | |
* @Block( | |
* id = "system_breadcrumb_block", | |
* admin_label = @Translation("Breadcrumbs") | |
* ) | |
*/ | |
class SystemBreadcrumbBlock extends BlockBase implements ContainerFactoryPluginInterface { | |
/** | |
* The breadcrumb manager. | |
* | |
* @var \Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface | |
*/ | |
protected $breadcrumbManager; | |
/** | |
* The current route match. | |
* | |
* @var \Drupal\Core\Routing\RouteMatchInterface | |
*/ | |
protected $routeMatch; | |
/** | |
* Constructs a new SystemBreadcrumbBlock object. | |
* | |
* @param array $configuration | |
* A configuration array containing information about the plugin instance. | |
* @param string $plugin_id | |
* The plugin_id for the plugin instance. | |
* @param mixed $plugin_definition | |
* The plugin implementation definition. | |
* @param \Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface $breadcrumb_manager | |
* The breadcrumb manager. | |
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match | |
* The current route match. | |
*/ | |
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; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
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') | |
); | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function build() { | |
return $this->breadcrumbManager->build($this->routeMatch)->toRenderable(); | |
} | |
} |