<?php


namespace App\Components\Sidebar\SidebarMenu\Controls;


class Link extends BaseControl implements IActiveNode
{
    protected $linkDestination;

    protected $linkParams;

    /**
     * @param $destination
     * @param array $params
     * @return Link
     */
    public function setLink($destination, $params = array())
    {
        $this->linkDestination = $destination;
        $this->linkParams = $params;
        return $this;
    }

    public function isActive()
    {
        return $this->presenter->isLinkCurrent($this->linkDestination, $this->linkParams);
    }

    public function render()
    {
        $this->template->isActive = $this->isActive();
        $this->template->link = $this->presenter->link($this->linkDestination, $this->linkParams);
        $this->renderTemplate('link');
    }
}