function _social_group_create_menu_links in Open Social 8.2
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/social_group.install \_social_group_create_menu_links()
- 8 modules/social_features/social_group/social_group.install \_social_group_create_menu_links()
- 8.3 modules/social_features/social_group/social_group.install \_social_group_create_menu_links()
- 8.4 modules/social_features/social_group/social_group.install \_social_group_create_menu_links()
- 8.5 modules/social_features/social_group/social_group.install \_social_group_create_menu_links()
- 8.6 modules/social_features/social_group/social_group.install \_social_group_create_menu_links()
- 8.7 modules/social_features/social_group/social_group.install \_social_group_create_menu_links()
- 8.8 modules/social_features/social_group/social_group.install \_social_group_create_menu_links()
- 10.3.x modules/social_features/social_group/social_group.install \_social_group_create_menu_links()
- 10.0.x modules/social_features/social_group/social_group.install \_social_group_create_menu_links()
- 10.1.x modules/social_features/social_group/social_group.install \_social_group_create_menu_links()
- 10.2.x modules/social_features/social_group/social_group.install \_social_group_create_menu_links()
Function to create some menu items.
1 call to _social_group_create_menu_links()
- social_group_install in modules/
social_features/ social_group/ social_group.install - Implements hook_install().
File
- modules/
social_features/ social_group/ social_group.install, line 129 - Install, update and uninstall functions for the social_group module.
Code
function _social_group_create_menu_links() {
$menu_links = MenuLinkContent::loadMultiple();
$parent = NULL;
/** @var \Drupal\menu_link_content\Entity\MenuLinkContent $menu_link */
foreach ($menu_links as $menu_link) {
if ($menu_link
->label() === 'Explore' && $menu_link
->isExpanded()) {
$parent = 'menu_link_content:' . $menu_link
->uuid();
}
}
if (!is_null($parent)) {
MenuLinkContent::create([
'title' => t('All groups'),
'link' => [
'uri' => 'internal:/all-groups',
],
'menu_name' => 'main',
'expanded' => FALSE,
'weight' => 20,
'parent' => $parent,
])
->save();
}
}