RouterExtension
extends TICTwigExtension
in package
Filtres et fonctions twig de formattage et conversions.
https://symfony.com/doc/current/templating/twig_extension.html
Table of Contents
Properties
- $router : mixed
- $strings : mixed
- $translator : mixed
- $urlHelper : mixed
Methods
- __construct() : mixed
- getFilters() : array<string|int, mixed>
- isCurrentUrlFilter() : bool
- getBool() : mixed
- Retourne l'équivalent booléen (ou null) d'une variable quelconque.
- getIcon() : string
- Génération d'un tag HTML pour afficher un icone FontAwesome ou Bootstrap (avec quelques alias utiles).
- getText() : string
- Retourne une chaine texte à partir d'une variable (avec traduction et échappements HTML possibles).
- htmlAttr() : string
- Conversion d'un hachage en une chaine d'attributs insérable dans un tag HTML.
- trans() : string
- Recherche la traduction d'un texte (si le service $translator est disponible).
Properties
$router
protected
mixed
$router
$strings
protected
static mixed
$strings
= ['true' => 'ext.boolean.true', 'false' => 'ext.boolean.false', 'null' => null]
$translator
protected
mixed
$translator
$urlHelper
protected
mixed
$urlHelper
Methods
__construct()
public
__construct(UrlGeneratorInterface $router) : mixed
Parameters
- $router : UrlGeneratorInterface
getFilters()
public
getFilters() : array<string|int, mixed>
Return values
array<string|int, mixed>isCurrentUrlFilter()
public
isCurrentUrlFilter([string $value = null ]) : bool
Parameters
- $value : string = null
Return values
boolgetBool()
Retourne l'équivalent booléen (ou null) d'une variable quelconque.
protected
getBool(mixed $value[, mixed $default = null ]) : mixed
Parameters
- $value : mixed
-
Variable à convertir en booléen
- $default : mixed = null
-
Valeur à retourner si la conversion échoue
getIcon()
Génération d'un tag HTML pour afficher un icone FontAwesome ou Bootstrap (avec quelques alias utiles).
protected
getIcon(string $name[, string $state = '' ]) : string
Parameters
- $name : string
-
Classe Bootstrap ou FontAwesome (ex 'fas-user', 'fab-user', 'envelope', 'ban-circle'...)
- $state : string = ''
-
Ajout d'une classe de type 'text-
' (ex: primary, info, success, warning, danger)
Return values
stringgetText()
Retourne une chaine texte à partir d'une variable (avec traduction et échappements HTML possibles).
protected
getText(mixed $value[, bool $trans = false ][, bool $escape = false ]) : string
Parameters
- $value : mixed
-
Variable à convertir en texte
- $trans : bool = false
-
Recherche d'une traduction (si c'est une chaine valide)
- $escape : bool = false
-
Appliquer les échappements HTML
Return values
string —Chaine de texte correspondante
htmlAttr()
Conversion d'un hachage en une chaine d'attributs insérable dans un tag HTML.
protected
htmlAttr([array<string|int, mixed> $attr = array() ]) : string
Parameters
- $attr : array<string|int, mixed> = array()
-
Liste d'attributs HTML en clé/valeur
Return values
string —Code HTML contenant les attributs d'un tag
trans()
Recherche la traduction d'un texte (si le service $translator est disponible).
protected
trans(string $token) : string
Parameters
- $token : string
-
Chaine de texte à traduire
Return values
string —Chaine de texte traduite