<?php
namespace TwigExtension;

use Skeleton\Router;
use Psr\Container\ContainerInterface;

class LiRoueDenteExtension extends \Twig\Extension\AbstractExtension
{
 
    public function __construct()
    {
    }

    public function getFunctions()
    {
        return [
            new \Twig\TwigFunction('liAl', [
                $this,
                'liAl'
            ], [
                'is_safe' => [
                    'html'
                ]
            ])
        ];
    }

    public function liAl($pathLi, $params = null, $classAl = null, $libelleAl = null)
    {
        $html = "
        <script>
            function redirect(url)
            {
                redirectJSWithPost( url ,'', 'GET');
            }
        </script>";

        $html .= '<li onclick ="redirect(\''.$pathLi.'\')">';

        $html .= '<a class="'.$classAl.'">'.$libelleAl.'</a></li>';
        
        return $html;
    }
}
