src/bbn/appui/menus.php
public function add_shortcut(string $id): ?string
  {
    if (
      ($bit = $this->pref->get_bit($id, false)) &&
      ($id_option = $this->from_path('shortcuts')) &&
      ($c = $this->pref->get_class_cfg())
    ){
      if ( $id_menu = $this->pref->get_by_option($id_option) ){
        $id_menu = $id_menu[$c['arch']['user_options']['id']];
      }
      else {
        $id_menu = $this->pref->add($id_option, [$c['arch']['user_options']['text'] => _('Shortcuts')]);
      }
      if (
        !empty($id_menu) &&
        ($arch = $c['arch']['user_options_bits'])
      ){
        if (
          ($bits = $this->pref->get_bits($id_menu, false, false)) &&
          ( \bbn\x::find($bits, [$arch['id_option'] => $bit[$arch['id_option']]]) !== false)
        ){
          return null;
        }
        return $this->pref->add_bit($id_menu, [
          $arch['id_option'] => $bit[$arch['id_option']],
          $arch['text'] => $bit[$arch['text']],
          $arch['cfg'] => $bit[$arch['cfg']],
          $arch['num'] => $this->pref->next_bit_num($id_menu) ?: 1
        ]);
      }
    }
    return null;
  }
public function add_shortcut(string $id): ?string
  {
    if (
      ($bit = $this->pref->get_bit($id, false)) &&
      ($id_option = $this->from_path('shortcuts')) &&
      ($c = $this->pref->get_class_cfg())
    ){
      if ( $id_menu = $this->pref->get_by_option($id_option) ){
        $id_menu = $id_menu[$c['arch']['user_options']['id']];
      }
      else {
        $id_menu = $this->pref->add($id_option, [$c['arch']['user_options']['text'] => _('Shortcuts')]);
      }
      if (
        !empty($id_menu) &&
        ($arch = $c['arch']['user_options_bits'])
      ){
        if (
          ($bits = $this->pref->get_bits($id_menu, false, false)) &&
          ( \bbn\x::find($bits, [$arch['id_option'] => $bit[$arch['id_option']]]) !== false)
        ){
          return null;
        }
        return $this->pref->add_bit($id_menu, [
          $arch['id_option'] => $bit[$arch['id_option']],
          $arch['text'] => $bit[$arch['text']],
          $arch['cfg'] => $bit[$arch['cfg']],
          $arch['num'] => $this->pref->next_bit_num($id_menu) ?: 1
        ]);
      }
    }
    return null;
  }
public function add_shortcut ( string $ id ) : ? string { if ( ( $ bit = $ this -> pref -> get_bit ( $ id , false ) ) && ( $ id_option = $ this -> from_path ( 'shortcuts' ) ) && ( $ c = $ this -> pref -> get_class_cfg ( ) ) ) { if ( $ id_menu = $ this -> pref -> get_by_option ( $ id_option ) ) { $ id_menu = $ id_menu [ $ c [ 'arch' ] [ 'user_options' ] [ 'id' ] ] ; } else { $ id_menu = $ this -> pref -> add ( $ id_option , [ $ c [ 'arch' ] [ 'user_options' ] [ 'text' ] => _ ( 'Shortcuts' ) ] ) ; } if ( ! empty ( $ id_menu ) && ( $ arch = $ c [ 'arch' ] [ 'user_options_bits' ] ) ) { if ( ( $ bits = $ this -> pref -> get_bits ( $ id_menu , false , false ) ) && ( \ bbn \ x :: find ( $ bits , [ $ arch [ 'id_option' ] => $ bit [ $ arch [ 'id_option' ] ] ] ) !== false ) ) { return null ; } return $ this -> pref -> add_bit ( $ id_menu , [ $ arch [ 'id_option' ] => $ bit [ $ arch [ 'id_option' ] ] , $ arch [ 'text' ] => $ bit [ $ arch [ 'text' ] ] , $ arch [ 'cfg' ] => $ bit [ $ arch [ 'cfg' ] ] , $ arch [ 'num' ] => $ this -> pref -> next_bit_num ( $ id_menu ) ? : 1 ] ) ; } } return null ; }
Adds an user'shortcut from a menu

@param string $id The menu item's ID to link
@return string|null
Adds an user shortcut from a menu