<?php
/**
 * @package     DOCman
 * @copyright   Copyright (C) 2019 Timble CVBA (http://www.timble.net)
 * @license     GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        http://www.joomlatools.com
 */

namespace Foliolabs\Docman;

use Foliolabs\Library;

class TemplateHelperPermalink extends Library\TemplateHelperGrid
{
    public function generate($config = [])
    {
        $config = new Library\ObjectConfig($config);

        $entity = $config->entity;

        $router = $this->getObject('com://site/docman.dispatcher.router.site', ['request' => $this->getObject('request')]);

        return $router->generate(null, ['component' => 'docman', 'endpoint' => '~documents', 'view' => 'download', 'id' => $entity->id]);
    }
}