• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

heimrichhannot / contao-utils-bundle / 6809777185

09 Nov 2023 09:22AM UTC coverage: 22.835%. Remained the same
6809777185

push

github

koertho
deprecate twig filters and tests

2 of 32 new or added lines in 8 files covered. (6.25%)

4 existing lines in 4 files now uncovered.

1255 of 5496 relevant lines covered (22.83%)

1.55 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Twig/DateExtension.php
1
<?php
2

3
/*
4
 * Copyright (c) 2021 Heimrich & Hannot GmbH
5
 *
6
 * @license LGPL-3.0-or-later
7
 */
8

9
namespace HeimrichHannot\UtilsBundle\Twig;
10

11
use Contao\Config;
12
use Contao\System;
13
use Twig\Extension\AbstractExtension;
14
use Twig\TwigFilter;
15

16
class DateExtension extends AbstractExtension
17
{
18
    /**
19
     * Get list of twig filters.
20
     *
21
     * @return array|\Twig_SimpleFilter[]
22
     */
23
    public function getFilters()
24
    {
25
        return [
×
NEW
26
            new TwigFilter('localized_date', [$this, 'getLocalizedDate'], ['deprecated' => true]),
×
27
        ];
×
28
    }
29

30
    public function getLocalizedDate($timestamp, string $format = null): string
31
    {
32
        if (null === $format) {
×
33
            $format = Config::get('dateFormat');
×
34
        }
35

36
        $dateUtil = System::getContainer()->get('huh.utils.date');
×
37

38
        $date = date($format, $timestamp);
×
39

40
        // translate months
41
        $date = $dateUtil->translateMonths($date);
×
42

43
        return $date;
×
44
    }
45
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc