Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Platform
Commits
0b8e3ae7
Commit
0b8e3ae7
authored
Oct 05, 2014
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a navigation helper to sort the items
parent
14b9bb66
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
36 deletions
+34
-36
SidebarViewComposer.php
Composers/SidebarViewComposer.php
+0
-35
NavigationOrdener.php
Navigation/NavigationOrdener.php
+33
-0
sidebar-nav.blade.php
Resources/views/partials/sidebar-nav.blade.php
+1
-0
composers.php
composers.php
+0
-1
No files found.
Composers/SidebarViewComposer.php
deleted
100644 → 0
View file @
14b9bb66
<?php
namespace
Modules\Core\Composers
;
class
SidebarViewComposer
{
public
function
compose
(
$view
)
{
$view
->
items
->
sort
(
function
(
$item1
,
$item2
)
{
if
(
is_object
(
$item1
))
{
if
(
$item1
->
first
()[
'weight'
]
>
$item2
[
'weight'
])
{
return
1
;
}
if
(
$item1
->
first
()[
'weight'
]
<
$item2
[
'weight'
])
{
return
-
1
;
}
return
0
;
}
if
(
is_object
(
$item2
))
{
if
(
$item1
[
'weight'
]
>
$item2
->
first
()[
'weight'
])
{
return
1
;
}
if
(
$item1
[
'weight'
]
<
$item2
->
first
()[
'weight'
])
{
return
-
1
;
}
return
0
;
}
if
(
$item1
[
'weight'
]
>
$item2
[
'weight'
])
{
return
1
;
}
if
(
$item1
[
'weight'
]
<
$item2
[
'weight'
])
{
return
-
1
;
}
return
0
;
});
}
}
\ No newline at end of file
Navigation/NavigationOrdener.php
0 → 100644
View file @
0b8e3ae7
<?php
namespace
Modules\Core\Navigation
;
use
Illuminate\Support\Collection
;
class
NavigationOrdener
{
public
static
function
order
(
Collection
$items
)
{
return
$items
->
sort
(
function
(
$item1
,
$item2
)
{
$item1
=
self
::
getItem
(
$item1
);
$item2
=
self
::
getItem
(
$item2
);
if
(
$item1
[
'weight'
]
>
$item2
[
'weight'
])
{
return
1
;
}
if
(
$item1
[
'weight'
]
<
$item2
[
'weight'
])
{
return
-
1
;
}
return
0
;
}
);
}
/**
* @param $item
* @return mixed
*/
public
static
function
getItem
(
$item
)
{
return
isset
(
$item
[
'weight'
])
?
$item
:
$item
->
first
();
}
}
\ No newline at end of file
Resources/views/partials/sidebar-nav.blade.php
View file @
0b8e3ae7
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
<!-- sidebar menu: : style can be found in sidebar.less -->
<!-- sidebar menu: : style can be found in sidebar.less -->
<ul
class=
"sidebar-menu"
>
<ul
class=
"sidebar-menu"
>
<?php
$items
=
\Modules\Core\Navigation\NavigationOrdener
::
order
(
$items
);
?>
<?php
foreach
(
$items
as
$i
=>
$item
)
:
?>
<?php
foreach
(
$items
as
$i
=>
$item
)
:
?>
<?php
if
(
is_object
(
$item
))
:
?>
<?php
if
(
is_object
(
$item
))
:
?>
<li
class=
"treeview {{ $item[0]['request'] ? 'active' : ''}}"
>
<li
class=
"treeview {{ $item[0]['request'] ? 'active' : ''}}"
>
...
...
composers.php
View file @
0b8e3ae7
<?php
<?php
View
::
creator
(
'core::partials.sidebar-nav'
,
'Modules\Core\Composers\SidebarViewCreator'
);
View
::
creator
(
'core::partials.sidebar-nav'
,
'Modules\Core\Composers\SidebarViewCreator'
);
View
::
composer
(
'core::partials.sidebar-nav'
,
'Modules\Core\Composers\SidebarViewComposer'
);
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