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
1839baef
Commit
1839baef
authored
4 years ago
by
Eric Bremner
Committed by
Igor Biki
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-4199: coding standards
parent
5e6b633b
No related branches found
No related tags found
1 merge request
!17
Feature/istwcms 4199 ebremner menu items count
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Service/UWService.php
+11
-6
11 additions, 6 deletions
src/Service/UWService.php
src/Service/UWServiceInterface.php
+9
-7
9 additions, 7 deletions
src/Service/UWServiceInterface.php
with
20 additions
and
13 deletions
src/Service/UWService.php
+
11
−
6
View file @
1839baef
...
@@ -32,7 +32,7 @@ class UWService implements UWServiceInterface {
...
@@ -32,7 +32,7 @@ class UWService implements UWServiceInterface {
private
$database
;
private
$database
;
/**
/**
* Simplify_menu menu.
* Simplify_menu menu
items
.
*
*
* @var \Drupal\simplify_menu\MenuItems
* @var \Drupal\simplify_menu\MenuItems
*/
*/
...
@@ -45,6 +45,8 @@ class UWService implements UWServiceInterface {
...
@@ -45,6 +45,8 @@ class UWService implements UWServiceInterface {
* Entity Type Manager from core.
* Entity Type Manager from core.
* @param \Drupal\Core\Database\Connection $database
* @param \Drupal\Core\Database\Connection $database
* The database entity.
* The database entity.
* @param \Drupal\simplify_menu\MenuItems $simplifyMenu
* The simplify_menu menu items.
*/
*/
public
function
__construct
(
EntityTypeManagerInterface
$entityTypeManager
,
Connection
$database
,
MenuItems
$simplifyMenu
)
{
public
function
__construct
(
EntityTypeManagerInterface
$entityTypeManager
,
Connection
$database
,
MenuItems
$simplifyMenu
)
{
$this
->
entityTypeManager
=
$entityTypeManager
;
$this
->
entityTypeManager
=
$entityTypeManager
;
...
@@ -271,7 +273,7 @@ class UWService implements UWServiceInterface {
...
@@ -271,7 +273,7 @@ class UWService implements UWServiceInterface {
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*/
*/
public
function
uwGetMenu
(
string
$menu_name
=
'main'
,
$include_parent_in_count
=
FALSE
):
array
{
public
function
uwGetMenu
(
string
$menu_name
=
'main'
,
bool
$count_menu_items
=
FALSE
,
bool
$include_parent_in_count
=
FALSE
):
array
{
// Get the main menu from the simplify menu module.
// Get the main menu from the simplify menu module.
$menu
=
$this
->
simplifyMenu
->
getMenuTree
(
$menu_name
);
$menu
=
$this
->
simplifyMenu
->
getMenuTree
(
$menu_name
);
...
@@ -279,10 +281,12 @@ class UWService implements UWServiceInterface {
...
@@ -279,10 +281,12 @@ class UWService implements UWServiceInterface {
// Set it to the menu_tree which is done by simplify menu.
// Set it to the menu_tree which is done by simplify menu.
$menu
=
$menu
[
'menu_tree'
];
$menu
=
$menu
[
'menu_tree'
];
$menu_items_count
=
0
;
// If we want to have the count of menu items, then count them.
if
(
$count_menu_items
)
{
// Add the count of the menu items.
// Add the count of the menu items.
$menu
=
$this
->
uwSetMenuItems
(
$menu
,
$include_parent_in_count
);
$menu
=
$this
->
uwSetMenuItems
(
$menu
,
$include_parent_in_count
);
}
return
$menu
;
return
$menu
;
}
}
...
@@ -290,7 +294,7 @@ class UWService implements UWServiceInterface {
...
@@ -290,7 +294,7 @@ class UWService implements UWServiceInterface {
/**
/**
* {@inheritDoc}
* {@inheritDoc}
*/
*/
public
function
uwSetMenuItems
(
$menus
,
$include_parent_in_count
=
FALSE
):
array
{
public
function
uwSetMenuItems
(
array
$menus
,
bool
$include_parent_in_count
=
FALSE
):
array
{
// Step through the menu and do a few things:
// Step through the menu and do a few things:
// (a) Remove the Home link (this will be a house icon)
// (a) Remove the Home link (this will be a house icon)
...
@@ -370,4 +374,5 @@ class UWService implements UWServiceInterface {
...
@@ -370,4 +374,5 @@ class UWService implements UWServiceInterface {
}
}
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
src/Service/UWServiceInterface.php
+
9
−
7
View file @
1839baef
...
@@ -88,13 +88,15 @@ interface UWServiceInterface {
...
@@ -88,13 +88,15 @@ interface UWServiceInterface {
*
*
* @param string $menu_name
* @param string $menu_name
* A string to the machine name of the menu to get.
* A string to the machine name of the menu to get.
* @param $include_parent_in_count
* @param bool $count_menu_items
* A boolean on whether to count the number of menu items.
* @param bool $include_parent_in_count
* A boolean on whether to include the parent in the menu items count.
* A boolean on whether to include the parent in the menu items count.
*
*
* @return array
* @return array
* An array of the menu.
* An array of the menu.
*/
*/
public
function
uwGetMenu
(
string
$menu_name
=
'main'
,
$include_parent_in_count
=
false
):
array
;
public
function
uwGetMenu
(
string
$menu_name
=
'main'
,
bool
$count_menu_items
=
FALSE
,
bool
$include_parent_in_count
=
FALSE
):
array
;
/**
/**
* A function to setup the menu for UW display.
* A function to setup the menu for UW display.
...
@@ -125,22 +127,22 @@ interface UWServiceInterface {
...
@@ -125,22 +127,22 @@ interface UWServiceInterface {
* So it should with the recursive function it will return 11.
* So it should with the recursive function it will return 11.
* If we include the parent the count will be 12.
* If we include the parent the count will be 12.
*
*
* @param
&
$menus
* @param
array
$menus
* A reference to the array list of menu items.
* A reference to the array list of menu items.
* @param $include_parent_in_count
* @param
bool
$include_parent_in_count
* A boolean on whether to include the parent in the menu items count.
* A boolean on whether to include the parent in the menu items count.
*
*
* @return array
* @return array
* An array of the updated menu items.
* An array of the updated menu items.
*/
*/
public
function
uwSetMenuItems
(
$menus
,
$include_parent_in_count
=
false
):
array
;
public
function
uwSetMenuItems
(
array
$menus
,
bool
$include_parent_in_count
=
FALSE
):
array
;
/**
/**
* A function to recursively count the number of menu items in the submenu.
* A function to recursively count the number of menu items in the submenu.
*
*
* @param $menu
* @param
array
$menu
* An array that contains the submenu.
* An array that contains the submenu.
* @param $menu_items_count
* @param
int &
$menu_items_count
* A reference to the integer that is storing the number of menu items.
* A reference to the integer that is storing the number of menu items.
*/
*/
public
function
uwCountMenuItems
(
array
$menu
,
int
&
$menu_items_count
):
void
;
public
function
uwCountMenuItems
(
array
$menu
,
int
&
$menu_items_count
):
void
;
...
...
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