You are here

public function MenuLinkContentService::updateMenuItemsBundle in Menu Item Extras 8.2

Update menu items.

Parameters

string $menu_id: Menu id is a bundle for menu items that required to be updated.

bool $extras_enabled: Flag of enabled functionality.

Return value

bool Success or failed result of update.

Overrides MenuLinkContentServiceInterface::updateMenuItemsBundle

File

src/Service/MenuLinkContentService.php, line 105

Class

MenuLinkContentService
Class MenuLinkContentHelper.

Namespace

Drupal\menu_item_extras\Service

Code

public function updateMenuItemsBundle($menu_id, $extras_enabled = TRUE) {

  /** @var \Drupal\menu_link_content\MenuLinkContentInterface[] $menu_links */
  $menu_links = $this->entityTypeManager
    ->getStorage('menu_link_content')
    ->loadByProperties([
    'menu_name' => $menu_id,
  ]);
  if (!empty($menu_links)) {
    foreach ($menu_links as $menu_link) {
      $this
        ->updateMenuItemBundle($menu_link, $extras_enabled);
      if ($menu_link
        ->requiresRediscovery()) {
        $menu_link
          ->setRequiresRediscovery(FALSE);
      }
      $menu_link
        ->save();
    }
  }
}