Commit 1104509d authored by webchick's avatar webchick

Issue #2237241 by pwolanin: BreadcrumbManager does not have a proper interface .

parent b431efaf
......@@ -31,7 +31,7 @@ public function applies(array $attributes);
* Attributes representing the current page.
*
* @return array
* A render array for the breadcrumbs. Returning an empty array will
* An array of HTML links for the breadcrumb. Returning an empty array will
* suppress all breadcrumbs.
*/
public function build(array $attributes);
......
......@@ -13,11 +13,14 @@
/**
* Provides a breadcrumb manager.
*
* Can be assigned any number of other BreadcrumbBuilderInterface objects
* by calling the addBuilder() method, then uses the highest priority one
* to build breadcrumbs when build() is called.
* Can be assigned any number of BreadcrumbBuilderInterface objects by calling
* the addBuilder() method. When build() is called it iterates over the objects
* in priority order and uses the first one that returns TRUE from
* BreadcrumbBuilderInterface::applies() to build the breadcrumbs.
*
* @see \Drupal\Core\DependencyInjection\Compiler\RegisterBreadcrumbBuilderPass
*/
class BreadcrumbManager implements BreadcrumbBuilderInterface {
class BreadcrumbManager implements ChainBreadcrumbBuilderInterface {
/**
* The module handler to invoke the alter hook.
......@@ -53,12 +56,7 @@ public function __construct(ModuleHandlerInterface $module_handler) {
}
/**
* Adds another breadcrumb builder.
*
* @param \Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface $builder
* The breadcrumb builder to add.
* @param int $priority
* Priority of the breadcrumb builder.
* {@inheritdoc}
*/
public function addBuilder(BreadcrumbBuilderInterface $builder, $priority) {
$this->builders[$priority][] = $builder;
......
<?php
/**
* @file
* Contains \Drupal\Core\Breadcrumb\ChainBreadcrumbBuilderInterface.
*/
namespace Drupal\Core\Breadcrumb;
/**
* Defines an interface a chained service that builds the breadcrumb.
*/
interface ChainBreadcrumbBuilderInterface extends BreadcrumbBuilderInterface {
/**
* Adds another breadcrumb builder.
*
* @param \Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface $builder
* The breadcrumb builder to add.
* @param int $priority
* Priority of the breadcrumb builder.
*/
public function addBuilder(BreadcrumbBuilderInterface $builder, $priority);
}
......@@ -24,9 +24,11 @@ public function process(ContainerBuilder $container) {
return;
}
$manager = $container->getDefinition('breadcrumb');
foreach ($container->findTaggedServiceIds('breadcrumb_builder') as $id => $attributes) {
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
$manager->addMethodCall('addBuilder', array(new Reference($id), $priority));
if (is_subclass_of($manager->getClass(), 'Drupal\Core\Breadcrumb\ChainBreadcrumbBuilderInterface')) {
foreach ($container->findTaggedServiceIds('breadcrumb_builder') as $id => $attributes) {
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
$manager->addMethodCall('addBuilder', array(new Reference($id), $priority));
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment