Prado\Web\UI\WebControls\TRepeater::createItem PHP Method

createItem() protected method

Creates a repeater item instance based on the item type and index.
protected createItem ( $itemIndex, $itemType ) : TControl
return TControl created repeater item
    protected function createItem($itemIndex, $itemType)
    {
        $template = null;
        $classPath = null;
        switch ($itemType) {
            case TListItemType::Item:
                $classPath = $this->getItemRenderer();
                $template = $this->_itemTemplate;
                break;
            case TListItemType::AlternatingItem:
                if (($classPath = $this->getAlternatingItemRenderer()) === '' && ($template = $this->_alternatingItemTemplate) === null) {
                    $classPath = $this->getItemRenderer();
                    $template = $this->_itemTemplate;
                }
                break;
            case TListItemType::Header:
                $classPath = $this->getHeaderRenderer();
                $template = $this->_headerTemplate;
                break;
            case TListItemType::Footer:
                $classPath = $this->getFooterRenderer();
                $template = $this->_footerTemplate;
                break;
            case TListItemType::Separator:
                $classPath = $this->getSeparatorRenderer();
                $template = $this->_separatorTemplate;
                break;
            default:
                throw new TInvalidDataValueException('repeater_itemtype_unknown', $itemType);
        }
        if ($classPath !== '') {
            $item = Prado::createComponent($classPath);
            if ($item instanceof IItemDataRenderer) {
                $item->setItemIndex($itemIndex);
                $item->setItemType($itemType);
            }
        } else {
            if ($template !== null) {
                $item = new TRepeaterItem();
                $item->setItemIndex($itemIndex);
                $item->setItemType($itemType);
                $template->instantiateIn($item);
            } else {
                $item = null;
            }
        }
        return $item;
    }