Bootstrap\View\Helper\BootstrapNavbarHelper::text PHP Method

text() public method

Add a text to the navbar.
public text ( $text, $options = [] )
    public function text($text, $options = [])
    {
        $options += ['tag' => 'p'];
        $tag = $options['tag'];
        unset($options['tag']);
        $options = $this->addClass($options, 'navbar-text');
        $text = preg_replace_callback('/<a([^>]*)?>([^<]*)?<\\/a>/i', function ($matches) {
            $attrs = preg_replace_callback('/class="(.*)?"/', function ($m) {
                $cl = $this->addClass(['class' => $m[1]], 'navbar-link');
                return 'class="' . $cl['class'] . '"';
            }, $matches[1], -1, $count);
            if ($count == 0) {
                $attrs .= ' class="navbar-link"';
            }
            return '<a' . $attrs . '>' . $matches[2] . '</a>';
        }, $text);
        return $this->Html->tag($tag, $text, $options);
    }