yii\widgets\Breadcrumbs::renderItem PHP Method

renderItem() protected method

Renders a single breadcrumb item.
protected renderItem ( array $link, string $template ) : string
$link array the link to be rendered. It must contain the "label" element. The "url" element is optional.
$template string the template to be used to rendered the link. The token "{link}" will be replaced by the link.
return string the rendering result
    protected function renderItem($link, $template)
    {
        $encodeLabel = ArrayHelper::remove($link, 'encode', $this->encodeLabels);
        if (array_key_exists('label', $link)) {
            $label = $encodeLabel ? Html::encode($link['label']) : $link['label'];
        } else {
            throw new InvalidConfigException('The "label" element is required for each link.');
        }
        if (isset($link['template'])) {
            $template = $link['template'];
        }
        if (isset($link['url'])) {
            $options = $link;
            unset($options['template'], $options['label'], $options['url']);
            $link = Html::a($label, $link['url'], $options);
        } else {
            $link = $label;
        }
        return strtr($template, ['{link}' => $link]);
    }