public function renderItem($item, $index)
    {
        if (is_string($item)) {
            $content = $item;
            $caption = null;
            $options = [];
        } elseif (isset($item['content'])) {
            $content = $item['content'];
            $caption = ArrayHelper::getValue($item, 'caption');
            if ($caption !== null) {
                $captionOptions = ArrayHelper::remove($item, 'captionOptions', []);
                Html::addCssClass($captionOptions, ['widget' => 'carousel-caption']);

                $caption = Html::tag('div', $caption, $captionOptions);
            }
            $options = ArrayHelper::getValue($item, 'options', []);
        } else {
            throw new InvalidConfigException('The "content" option is required.');
        }

        Html::addCssClass($options, ['widget' => 'carousel-item']);
        if ($index === 0) {
            Html::addCssClass($options, 'active');
        }

        return Html::tag('div', $content . "\n" . $caption, $options);
    }
public function renderItem($item, $index)
    {
        if (is_string($item)) {
            $content = $item;
            $caption = null;
            $options = [];
        } elseif (isset($item['content'])) {
            $content = $item['content'];
            $caption = ArrayHelper::getValue($item, 'caption');
            if ($caption !== null) {
                $captionOptions = ArrayHelper::remove($item, 'captionOptions', []);
                Html::addCssClass($captionOptions, ['widget' => 'carousel-caption']);

                $caption = Html::tag('div', $caption, $captionOptions);
            }
            $options = ArrayHelper::getValue($item, 'options', []);
        } else {
            throw new InvalidConfigException('The "content" option is required.');
        }

        Html::addCssClass($options, ['widget' => 'carousel-item']);
        if ($index === 0) {
            Html::addCssClass($options, 'active');
        }

        return Html::tag('div', $content . "\n" . $caption, $options);
    }
public function renderItem ( $ item , $ index ) { if ( is_string ( $ item ) ) { $ content = $ item ; $ caption = null ; $ options = [ ] ; } elseif ( isset ( $ item [ 'content' ] ) ) { $ content = $ item [ 'content' ] ; $ caption = ArrayHelper :: getValue ( $ item , 'caption' ) ; if ( $ caption !== null ) { $ captionOptions = ArrayHelper :: remove ( $ item , 'captionOptions' , [ ] ) ; Html :: addCssClass ( $ captionOptions , [ 'widget' => 'carousel-caption' ] ) ; $ caption = Html :: tag ( 'div' , $ caption , $ captionOptions ) ; } $ options = ArrayHelper :: getValue ( $ item , 'options' , [ ] ) ; } else { throw new InvalidConfigException ( 'The "content" option is required.' ) ; } Html :: addCssClass ( $ options , [ 'widget' => 'carousel-item' ] ) ; if ( $ index === 0 ) { Html :: addCssClass ( $ options , 'active' ) ; } return Html :: tag ( 'div' , $ content . "\n" . $ caption , $ options ) ; }
Renders a single carousel item
@param string|array $item a single item from [[items]]
@param int $index the item index as the first item should be set to `active`
@return string the rendering result
@throws InvalidConfigException if the item is invalid
Renders a single carousel item