mirror of
https://github.com/stan220/chixana.git
synced 2026-09-08 16:28:41 +00:00
Added twig weekday filter.
This commit is contained in:
@@ -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];
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user