theming – How to hide/show menu based on conditions in Drupal 8?


I have created a menu -/admin/structure/menu/manage/new-menu

In which there are 3 links.

I want to hide/show the 3rd link from this menu with name ‘download pdf’ based on condition.

I am using code –

 function MYTHEME_preprocess_menu(&$variables) {
---
     }