Added twig weekday filter.

This commit is contained in:
2020-01-14 19:27:26 +03:00
parent d7561cb7e2
commit 122b86a20c
2 changed files with 24 additions and 1 deletions
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace App\Twig;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
class AppExtension extends AbstractExtension
{
private const WEEKDAYS_RU = ['Воскресенье', 'Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота'];
public function getFilters()
{
return [
new TwigFilter('weekday', [$this, 'formatWeekday']),
];
}
public function formatWeekday($weekdayNumber)
{
return self::WEEKDAYS_RU[$weekdayNumber];
}
}
+1 -1
View File
@@ -31,7 +31,7 @@
</div>
{% if is_granted('ROLE_USER') %}
<h1> Чихи за сегодня - {{ 'now'|date('d.m.Y') }}</h1>
<h1>{{ 'now'|date('w')|weekday }} {{ 'now'|date('d.m.Y') }}</h1>
<table class="pure-table">
<thead>