if ($user->
isAuthenticated()) { $links['disallowed'
] =
[ '#markup' =>
$this->
t('You are not allowed to post new content in the forum.'
),
];
} // Anonymous user does not have access to create new topics.
else { $links['login'
] =
[ '#theme' => 'menu_local_action',
'#link' =>
[ 'title' =>
$this->
t('Log in to post new content in the forum.'
),
'url' => Url::
fromRoute('user.login',
[],
['query' =>
$this->
getDestinationArray()]),
],
// Without this workaround, the action links will be rendered as <li>
// with no wrapping <ul> element.
// @todo Find a better way for this in https://www.drupal.org/node/3181052.
'#prefix' => '<ul class="action-links">',
'#suffix' => '</ul>',
];
} } else { // Without this workaround, the action links will be rendered as <li> with