mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 21:13:57 +00:00
add show-hide module for javascript
This commit is contained in:
@@ -33,30 +33,53 @@ class ChillTwigHelper extends AbstractExtension
|
||||
* - 'default' ;
|
||||
* - 'blockquote' ;
|
||||
*
|
||||
* `DateTimeInterface are also rendered. The date and time format may be set
|
||||
* using those key in `$options´ parameter:
|
||||
*
|
||||
* - `date_format` (default to `'medium'`)
|
||||
* - `time_format` (default to `'none'`)
|
||||
*
|
||||
* @param Environment $twig
|
||||
* @param string $value
|
||||
* @param string $value Default to 'No value'. Fallback to default if null
|
||||
* @param string $message
|
||||
* @param string $template
|
||||
* @param array $options
|
||||
* @return string
|
||||
*/
|
||||
public function printOrMessage(
|
||||
Environment $twig,
|
||||
$value,
|
||||
$message = 'No value',
|
||||
$template = 'default'
|
||||
$template = 'default',
|
||||
array $options = []
|
||||
) {
|
||||
switch ($template) {
|
||||
case 'default':
|
||||
case 'blockquote':
|
||||
$t = '@ChillMain/Extensions/PrintOrMessage/'.$template.'.html.twig';
|
||||
break;
|
||||
default:
|
||||
$t = $template;
|
||||
if ($value instanceof \DateTimeInterface) {
|
||||
$options = \array_merge([
|
||||
'date_format' => 'medium',
|
||||
'time_format' => 'none'
|
||||
], $options);
|
||||
switch ($template) {
|
||||
case 'default':
|
||||
case 'blockquote':
|
||||
$t = '@ChillMain/Extensions/PrintOrMessage/'.$template.'_date.html.twig';
|
||||
break;
|
||||
default:
|
||||
$t = $template;
|
||||
}
|
||||
} else {
|
||||
switch ($template) {
|
||||
case 'default':
|
||||
case 'blockquote':
|
||||
$t = '@ChillMain/Extensions/PrintOrMessage/'.$template.'.html.twig';
|
||||
break;
|
||||
default:
|
||||
$t = $template;
|
||||
}
|
||||
}
|
||||
|
||||
return $twig->render($t, [
|
||||
return $twig->render($t, \array_merge([
|
||||
'value' => $value,
|
||||
'message' => $message
|
||||
]);
|
||||
'message' => $message ?? 'No value'
|
||||
], $options));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user