You are here

function opigno_messaging_update_8004 in Opigno messaging 8

Update private messages main menu link.

File

./opigno_messaging.install, line 61
Install, update and uninstall functions for the Opigno Messaging module.

Code

function opigno_messaging_update_8004() {
  $menu_name = 'main';
  $storage = \Drupal::entityTypeManager()
    ->getStorage('menu_link_content');
  $menu_links = $storage
    ->loadByProperties([
    'menu_name' => $menu_name,
  ]);
  foreach ($menu_links as $menu_link) {
    if ($menu_link
      ->getTitle() == 'Messages') {
      $menu_link
        ->set('link', [
        'uri' => 'internal:/private-messages',
      ]);
      $menu_link
        ->save();
      break;
    }
  }
}