<?php


namespace App\Components\Sidebar\SidebarMenu\Controls;


use Nette\Application\UI\Control;

abstract class BaseControl extends Control
{
    protected $text;

    protected $icon;

    /**
     * @param mixed $text
     * @return Header
     */
    public function setText($text)
    {
        $this->text = $text;
        return $this;
    }

    /**
     * @param mixed $icon
     * @return Header
     */
    public function addIcon($icon)
    {
        $this->icon = $icon;
        return $this;
    }

    public function addFaIcon($icon)
    {
        return $this->addIcon("fa fa-{$icon}");
    }

    public function addGlyphicon($icon)
    {
        return $this->addIcon("glyphicon glyphicon-{$icon}");
    }

    protected function renderTemplate($template)
    {
        $this->template->setFile(__DIR__ . "/../templates/{$template}.latte");
        $this->template->text = $this->text;
        $this->template->icon = $this->icon;
        $this->template->render();
    }
}