getLinkClass() public méthode

Get the anchor classes as text
public getLinkClass ( ) : string
Résultat string
Exemple #1
0
/**
 * Render a menu item (usually as a link)
 *
 * @param ElggMenuItem $item The menu item
 * @param array        $vars Options to pass to output/url if a link
 * @return string
 * @since 1.9.0
 */
function elgg_view_menu_item(ElggMenuItem $item, array $vars = array())
{
    if (!isset($vars['class'])) {
        $vars['class'] = 'elgg-menu-content';
    }
    $vars = array_merge($item->getValues(), $vars);
    if ($item->getLinkClass()) {
        $vars['class'] .= ' ' . $item->getLinkClass();
    }
    if ($item->getHref() === false) {
        $text = $item->getText();
        // if contains elements, don't wrap
        if (preg_match('~<[a-z]~', $text)) {
            return $text;
        } else {
            return elgg_format_element('span', array('class' => 'elgg-non-link'), $text);
        }
    }
    if (!isset($vars['rel']) && !isset($vars['is_trusted'])) {
        $vars['is_trusted'] = true;
    }
    if ($item->getConfirmText()) {
        $vars['confirm'] = $item->getConfirmText();
        return elgg_view('output/confirmlink', $vars);
    } else {
        unset($vars['confirm']);
    }
    return elgg_view('output/url', $vars);
}
 public function testAddLinkClassWithArray()
 {
     $item = new \ElggMenuItem('name', 'text', 'url');
     $item->setLinkClass('new-link');
     $item->addLinkClass(array('2nd-link'));
     $this->assertEquals('new-link 2nd-link', $item->getLinkClass());
 }