Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
A
admin_toolbar
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
admin_toolbar
Commits
a80432f7
Commit
a80432f7
authored
Jan 15, 2016
by
mimran
Committed by
matio89
Jan 15, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2598136
by mimran, felribeiro: Menu items duplicated
parent
14349023
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
10 deletions
+48
-10
admin_toolbar.module
admin_toolbar.module
+39
-1
admin_toolbar_tools/src/Tests/AdminToolbarToolsAlterTest.php
admin_toolbar_tools/src/Tests/AdminToolbarToolsAlterTest.php
+9
-9
No files found.
admin_toolbar.module
View file @
a80432f7
...
...
@@ -27,10 +27,48 @@ function admin_toolbar_prerender_toolbar_administration_tray(array $element) {
$manipulators
=
array
(
array
(
'callable'
=>
'menu.default_tree_manipulators:checkAccess'
),
array
(
'callable'
=>
'menu.default_tree_manipulators:generateIndexAndSort'
),
array
(
'callable'
=>
'toolbar_menu_navigation_links'
),
array
(
'callable'
=>
'toolbar_
tools_
menu_navigation_links'
),
);
$tree
=
$menu_tree
->
transform
(
$tree
,
$manipulators
);
$element
[
'administration_menu'
]
=
$menu_tree
->
build
(
$tree
);
return
$element
;
}
/**
* Adds toolbar-specific attributes to the menu link tree.
*
* @param \Drupal\Core\Menu\MenuLinkTreeElement[] $tree
* The menu link tree to manipulate.
*
* @return \Drupal\Core\Menu\MenuLinkTreeElement[]
* The manipulated menu link tree.
*/
function
toolbar_tools_menu_navigation_links
(
array
$tree
)
{
foreach
(
$tree
as
$element
)
{
if
(
$element
->
subtree
)
{
toolbar_tools_menu_navigation_links
(
$element
->
subtree
);
}
// Make sure we have a path specific ID in place, so we can attach icons
// and behaviors to the menu links.
$link
=
$element
->
link
;
$url
=
$link
->
getUrlObject
();
if
(
!
$url
->
isRouted
())
{
// This is an unusual case, so just get a distinct, safe string.
$id
=
substr
(
Crypt
::
hashBase64
(
$url
->
getUri
()),
0
,
16
);
}
else
{
$id
=
str_replace
(
array
(
'.'
,
'<'
,
'>'
),
array
(
'-'
,
''
,
''
),
$url
->
getRouteName
());
}
// Get the non-localized title to make the icon class.
$definition
=
$link
->
getPluginDefinition
();
$element
->
options
[
'attributes'
][
'class'
][]
=
'toolbar-icon'
;
$element
->
options
[
'attributes'
][
'class'
][]
=
'toolbar-icon-'
.
strtolower
(
str_replace
(
array
(
'.'
,
' '
,
'_'
),
array
(
'-'
,
'-'
,
'-'
),
$definition
[
'id'
]));
$element
->
options
[
'attributes'
][
'title'
]
=
$link
->
getDescription
();
}
return
$tree
;
}
\ No newline at end of file
admin_toolbar_tools/src/Tests/AdminToolbarToolsAlterTest.php
View file @
a80432f7
...
...
@@ -5,16 +5,16 @@
* Contains \Drupal\admin_toolbar\Tests\AdminToolbarAlterTest.
*/
namespace
Drupal\admin_toolbar
_tools
\Tests
;
namespace
Drupal\admin_toolbar\Tests
;
use
Drupal\simpletest\WebTestBase
;
/**
* Test the existence of Admin Toolbar
tools new links
.
* Test the existence of Admin Toolbar
module
.
*
* @group admin_toolbar
_tools
* @group admin_toolbar
*/
class
AdminToolbar
Tools
AlterTest
extends
WebTestBase
{
class
AdminToolbarAlterTest
extends
WebTestBase
{
/**
* A user with permission to access the administrative toolbar.
...
...
@@ -28,7 +28,7 @@ class AdminToolbarToolsAlterTest extends WebTestBase {
*
* @var array
*/
public
static
$modules
=
array
(
'toolbar'
,
'admin_toolbar'
,
'admin_toolbar_tools'
);
public
static
$modules
=
array
(
'toolbar'
,
'admin_toolbar'
);
protected
function
setUp
()
{
parent
::
setUp
();
...
...
@@ -41,11 +41,11 @@ class AdminToolbarToolsAlterTest extends WebTestBase {
/**
* Tests for a the hover of sub menus.
*/
function
testAdminToolbar
Tools
()
{
function
testAdminToolbar
()
{
// Test for admin_toolbar_tools if special menu items are added.
$this
->
assertRaw
(
'id="toolbar-link-admin_toolbar_tools-flush"'
);
// Assert that expanded links are present in HTML.
// Test with the site configuration link that must be there whatever modules exists.
$this
->
assertRaw
(
'data-drupal-link-system-path="admin/config/system"'
);
}
}
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