Back to Links class

Method link

public static string
(mixed $link)
Method to generate html code for a single link
Parameters
  • array $link link properties
Returns
  • string
Since
  • 3.2
Class: Links
Project: Joomla

Method link - Source code

/**
 * Method to generate html code for a single link
 *
 * @param   array  $link  link properties
 *
 * @return  string
 *
 * @since   3.2
 */
public static function link($link)
{
    if (isset($link['access'])) {
        if (is_bool($link['access'])) {
            if ($link['access'] == false) {
                return '';
            }
        } else {
            // Get the user object to verify permissions
            $user = Factory::getUser();
            // Take each pair of permission, context values.
            for ($i = 0, $n = count($link['access']); $i < $n; $i += 2) {
                if (!$user->authorise($link['access'][$i], $link['access'][$i + 1])) {
                    return '';
                }
            }
        }
    }
    // Instantiate a new FileLayout instance and render the layout
    $layout = new FileLayout('joomla.links.link');
    return $layout->render($link);
}