Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uw_sites_all
Manage
Activity
Members
Labels
Code
Merge requests
3
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_sites_all
Commits
b64de6b9
Commit
b64de6b9
authored
3 years ago
by
Chris Shantz
Browse files
Options
Downloads
Plain Diff
Merge branch '1.0.x' into prod/1.0.x
parents
8f612952
2e5fed4f
No related branches found
Branches containing commit
Tags
1.0.7
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
uw_sites_all.install
+100
-0
100 additions, 0 deletions
uw_sites_all.install
with
100 additions
and
0 deletions
uw_sites_all.install
+
100
−
0
View file @
b64de6b9
...
...
@@ -5,6 +5,8 @@
* Install, update and uninstall for UW Sites all.
*/
use
Drupal\Core\Url
;
use
Drupal\menu_link_content
\Entity\MenuLinkContent
;
use
Drupal\user\Entity\Role
;
/**
...
...
@@ -35,6 +37,79 @@ function uw_sites_all_install() {
// Remove default "contact" form.
\Drupal
::
entityTypeManager
()
->
getStorage
(
'webform'
)
->
load
(
'contact'
)
->
delete
();
// Get the menu items.
$menu_items
=
_uw_sites_all_get_menu_items
();
// Step through each menu item and create a menu link.
foreach
(
$menu_items
as
$menu_item
)
{
// Create the URL from the route name.
$url
=
URL
::
fromRoute
(
$menu_item
[
'route_name'
])
->
toString
();
// Create the actual menu link.
MenuLinkContent
::
create
([
'title'
=>
$menu_item
[
'title'
],
'link'
=>
[
'uri'
=>
'internal:'
.
$url
],
'menu_name'
=>
$menu_item
[
'menu_name'
],
'weight'
=>
$menu_item
[
'weight'
],
'enabled'
=>
$menu_item
[
'enabled'
],
])
->
save
();
}
}
/**
* Helper function to return the UW default menu links.
*
* @return array[]
* Array of UW specific menu links.
*/
function
_uw_sites_all_get_menu_items
():
array
{
return
[
'Contacts'
=>
[
'title'
=>
'Contacts'
,
'menu_name'
=>
'main'
,
'route_name'
=>
'view.uw_view_contacts.contact_page'
,
'weight'
=>
40
,
'enabled'
=>
TRUE
,
],
'Profiles'
=>
[
'title'
=>
'Profiles'
,
'menu_name'
=>
'main'
,
'route_name'
=>
'view.uw_view_profiles.profile_page'
,
'weight'
=>
45
,
'enabled'
=>
TRUE
,
],
'Blog'
=>
[
'title'
=>
'Blog'
,
'menu_name'
=>
'main'
,
'route_name'
=>
'view.uw_view_blogs.blog_page'
,
'weight'
=>
50
,
'enabled'
=>
TRUE
,
],
'Events'
=>
[
'title'
=>
'Events'
,
'menu_name'
=>
'main'
,
'route_name'
=>
'view.uw_view_events.event_page'
,
'weight'
=>
55
,
'enabled'
=>
TRUE
,
],
'News'
=>
[
'title'
=>
'News'
,
'menu_name'
=>
'main'
,
'route_name'
=>
'view.uw_view_news_items.news_page'
,
'weight'
=>
60
,
'enabled'
=>
TRUE
,
],
'Catalogs'
=>
[
'title'
=>
'Catalogs'
,
'menu_name'
=>
'main'
,
'route_name'
=>
'view.uw_view_catalogs.catalogs_page'
,
'weight'
=>
65
,
'enabled'
=>
FALSE
,
],
];
}
/**
...
...
@@ -189,3 +264,28 @@ function uw_sites_all_update_8107() {
\Drupal
::
service
(
'module_installer'
)
->
uninstall
(
$modules
);
}
/**
* Recreate main menu items.
*/
function
uw_sites_all_update_8108
(
&
$sandbox
)
{
// Get the menu items.
$menu_items
=
_uw_sites_all_get_menu_items
();
// Step through each menu item and create a menu link.
foreach
(
$menu_items
as
$menu_item
)
{
// Create the URL from the route name.
$url
=
URL
::
fromRoute
(
$menu_item
[
'route_name'
])
->
toString
();
// Create the actual menu link.
MenuLinkContent
::
create
([
'title'
=>
$menu_item
[
'title'
],
'link'
=>
[
'uri'
=>
'internal:'
.
$url
],
'menu_name'
=>
$menu_item
[
'menu_name'
],
'weight'
=>
$menu_item
[
'weight'
],
'enabled'
=>
$menu_item
[
'enabled'
],
])
->
save
();
}
}
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