Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
1104509d
Commit
1104509d
authored
Apr 11, 2014
by
webchick
Browse files
Issue
#2237241
by pwolanin: BreadcrumbManager does not have a proper interface .
parent
b431efaf
Changes
4
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/Breadcrumb/BreadcrumbBuilderInterface.php
View file @
1104509d
...
...
@@ -31,7 +31,7 @@ public function applies(array $attributes);
* Attributes representing the current page.
*
* @return array
* A
render array
for the breadcrumb
s
. Returning an empty array will
* A
n array of HTML links
for the breadcrumb. Returning an empty array will
* suppress all breadcrumbs.
*/
public
function
build
(
array
$attributes
);
...
...
core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php
View file @
1104509d
...
...
@@ -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
Chain
BreadcrumbBuilderInterface
{
/**
* 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
;
...
...
core/lib/Drupal/Core/Breadcrumb/ChainBreadcrumbBuilderInterface.php
0 → 100644
View file @
1104509d
<?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
);
}
core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterBreadcrumbBuilderPass.php
View file @
1104509d
...
...
@@ -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
));
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment