// Only render accessible links.
if (!
$element->access->
isAllowed()) { continue;
} /** @var \Drupal\Core\Menu\MenuLinkInterface $link */
$link =
$element->link;
if ($link) { $id = 'menu_plugin_id:' .
$link->
getPluginId();
$form[$id]['#item'
] =
$element;
$form[$id]['#attributes'
] =
$link->
isEnabled() ?
['class' =>
['menu-enabled'
]] :
['class' =>
['menu-disabled'
]];
$form[$id]['title'
] = Link::
fromTextAndUrl($link->
getTitle(),
$link->
getUrlObject())->
toRenderable();
if (!
$link->
isEnabled()) { $form[$id]['title'
]['#suffix'
] = ' (' .
$this->
t('disabled'
) . ')';
} // @todo Remove this in https://www.drupal.org/node/2568785.
elseif ($id === 'menu_plugin_id:user.logout'
) { $form[$id]['title'
]['#suffix'
] = ' (' .
$this->
t('<q>Log in</q> for anonymous users'
) . ')';
} // @todo Remove this in https://www.drupal.org/node/2568785.
elseif (($url =
$link->
getUrlObject()) &&
$url->
isRouted() &&
$url->
getRouteName() == 'user.page'
) { $form[$id]['title'
]['#suffix'
] = ' (' .
$this->
t('logged in users only'
) . ')';
}