You are here

function _social_activity_create_menu_links in Open Social 8.3

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_activity/social_activity.install \_social_activity_create_menu_links()
  2. 8 modules/social_features/social_activity/social_activity.install \_social_activity_create_menu_links()
  3. 8.2 modules/social_features/social_activity/social_activity.install \_social_activity_create_menu_links()
  4. 8.4 modules/social_features/social_activity/social_activity.install \_social_activity_create_menu_links()
  5. 8.5 modules/social_features/social_activity/social_activity.install \_social_activity_create_menu_links()
  6. 8.6 modules/social_features/social_activity/social_activity.install \_social_activity_create_menu_links()
  7. 8.7 modules/social_features/social_activity/social_activity.install \_social_activity_create_menu_links()
  8. 8.8 modules/social_features/social_activity/social_activity.install \_social_activity_create_menu_links()
  9. 10.3.x modules/social_features/social_activity/social_activity.install \_social_activity_create_menu_links()
  10. 10.0.x modules/social_features/social_activity/social_activity.install \_social_activity_create_menu_links()
  11. 10.1.x modules/social_features/social_activity/social_activity.install \_social_activity_create_menu_links()
  12. 10.2.x modules/social_features/social_activity/social_activity.install \_social_activity_create_menu_links()

Function to create some menu items.

1 call to _social_activity_create_menu_links()
social_activity_install in modules/social_features/social_activity/social_activity.install
Social activity install function.

File

modules/social_features/social_activity/social_activity.install, line 34
The Social activity install.

Code

function _social_activity_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('Community'),
      'link' => [
        'uri' => 'internal:/explore',
      ],
      'menu_name' => 'main',
      'expanded' => FALSE,
      'weight' => 10,
      'parent' => $parent,
    ])
      ->save();
  }
}