<?php
namespace TwigExtension;

use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

class LiRoueDenteExtension extends AbstractExtension
{
    
    /**
     * Summary of getFunctions
     * @return TwigFunction[]
     */
    public function getFunctions()
    {
        return [
            new TwigFunction('liAl', $this->liAl(...), [
                'is_safe' => [
                    'html'
                ]
            ])
        ];
    }

    /**
     * Summary of liAl
     * @param mixed $pathLi
     * @param mixed $params
     * @param mixed $classAl
     * @param mixed $libelleAl
     * @return string
     */
    public function liAl($pathLi, $params = null, $classAl = null, $libelleAl = null)
    {
        $html = "
        <script>
            function redirect(url)
            {
                redirectJSWithPost( url ,'', 'GET');
            }
        </script>";

        $html .= '<li onclick ="redirect(\''.$pathLi.'\')">';
        
        return $html . ('<a class="' . $classAl . '">' . $libelleAl . '</a></li>');
    }
}
