Commit 1104509d authored by webchick's avatar webchick
Browse files

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

parent b431efaf
...@@ -31,7 +31,7 @@ public function applies(array $attributes); ...@@ -31,7 +31,7 @@ public function applies(array $attributes);
* Attributes representing the current page. * Attributes representing the current page.
* *
* @return array * @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. * suppress all breadcrumbs.
*/ */
public function build(array $attributes); public function build(array $attributes);
......
...@@ -13,11 +13,14 @@ ...@@ -13,11 +13,14 @@
/** /**
* Provides a breadcrumb manager. * Provides a breadcrumb manager.
* *
* Can be assigned any number of other BreadcrumbBuilderInterface objects * Can be assigned any number of BreadcrumbBuilderInterface objects by calling
* by calling the addBuilder() method, then uses the highest priority one * the addBuilder() method. When build() is called it iterates over the objects
* to build breadcrumbs when build() is called. * 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. * The module handler to invoke the alter hook.
...@@ -53,12 +56,7 @@ public function __construct(ModuleHandlerInterface $module_handler) { ...@@ -53,12 +56,7 @@ public function __construct(ModuleHandlerInterface $module_handler) {
} }
/** /**
* Adds another breadcrumb builder. * {@inheritdoc}
*
* @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) { public function addBuilder(BreadcrumbBuilderInterface $builder, $priority) {
$this->builders[$priority][] = $builder; $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) { ...@@ -24,9 +24,11 @@ public function process(ContainerBuilder $container) {
return; return;
} }
$manager = $container->getDefinition('breadcrumb'); $manager = $container->getDefinition('breadcrumb');
foreach ($container->findTaggedServiceIds('breadcrumb_builder') as $id => $attributes) { if (is_subclass_of($manager->getClass(), 'Drupal\Core\Breadcrumb\ChainBreadcrumbBuilderInterface')) {
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; foreach ($container->findTaggedServiceIds('breadcrumb_builder') as $id => $attributes) {
$manager->addMethodCall('addBuilder', array(new Reference($id), $priority)); $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
$manager->addMethodCall('addBuilder', array(new Reference($id), $priority));
}
} }
} }
......
Supports Markdown
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