Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uw_cfg_common
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WCMS
uw_cfg_common
Commits
abf9620b
Commit
abf9620b
authored
4 years ago
by
Eric Bremner
Committed by
Kevin Paxman
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-4653: checking children of menu items to ensure that they are published
parent
fdc4f813
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!61
ISTWCMS-4653: checking for unpublished nodes when getting the menu
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Service/UWService.php
+28
-14
28 additions, 14 deletions
src/Service/UWService.php
src/Service/UWServiceInterface.php
+8
-0
8 additions, 0 deletions
src/Service/UWServiceInterface.php
with
36 additions
and
14 deletions
src/Service/UWService.php
+
28
−
14
View file @
abf9620b
...
...
@@ -293,20 +293,43 @@ class UWService implements UWServiceInterface {
*/
public
function
uwGetMenu
(
string
$menu_name
=
'main'
,
bool
$count_menu_items
=
FALSE
,
bool
$include_parent_in_count
=
FALSE
):
array
{
// The base path, need this for removing when on subfoldered sites,
// for example d8/fdsu5/, we need to remove the fdsu5 from the path
// alias.
global
$base_path
;
// Get the main menu from the simplify menu module.
$menu
=
$this
->
simplifyMenu
->
getMenuTree
(
$menu_name
);
// Set it to the menu_tree which is done by simplify menu.
$menu
=
$menu
[
'menu_tree'
];
// Ensure that we only get the published menu items.
$this
->
uwCheckPublishedMenuItems
(
$menu
);
// If we want to have the count of menu items, then count them.
if
(
$count_menu_items
)
{
// Add the count of the menu items.
$menu
=
$this
->
uwSetMenuItems
(
$menu
,
$include_parent_in_count
);
}
return
$menu
;
}
/**
* {@inheritDoc}
*/
public
function
uwCheckPublishedMenuItems
(
&
$menu
)
:
void
{
// The base path, need this for removing when on subfoldered sites,
// for example d8/fdsu5/, we need to remove the fdsu5 from the path
// alias.
global
$base_path
;
// Step through each menu and ensure that it is published.
foreach
(
$menu
as
$key
=>
$m
)
{
// If there is a submenu (i.e. children), process it first.
if
(
isset
(
$m
[
'submenu'
]))
{
$this
->
uwCheckPublishedMenuItems
(
$menu
[
$key
][
'submenu'
]);
}
// Remove the base path from the url so that we can get
// the actual content from the path alias.
$alias
=
str_replace
(
$base_path
,
''
,
$m
[
'url'
]);
...
...
@@ -326,15 +349,6 @@ class UWService implements UWServiceInterface {
}
}
}
// If we want to have the count of menu items, then count them.
if
(
$count_menu_items
)
{
// Add the count of the menu items.
$menu
=
$this
->
uwSetMenuItems
(
$menu
,
$include_parent_in_count
);
}
return
$menu
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
src/Service/UWServiceInterface.php
+
8
−
0
View file @
abf9620b
...
...
@@ -98,6 +98,14 @@ interface UWServiceInterface {
*/
public
function
uwGetMenu
(
string
$menu_name
=
'main'
,
bool
$count_menu_items
=
FALSE
,
bool
$include_parent_in_count
=
FALSE
):
array
;
/**
* Function to check that all menu links are published.
*
* @param $menu
* The array of menus.
*/
public
function
uwCheckPublishedMenuItems
(
&
$menu
)
:
void
;
/**
* A function to setup the menu for UW display.
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment