1
0
mirror of https://github.com/ToxicCrack/PrintABrick.git synced 2025-05-18 05:10:07 -07:00

Fix file timestamp

This commit is contained in:
Unknown 2017-06-08 22:58:47 +02:00
parent 6685658a89
commit a7f11179c9
2 changed files with 8 additions and 6 deletions

View File

@ -123,6 +123,8 @@ services:
# Twig
AppBundle\Twig\AppExtension:
arguments:
$webDir: "%kernel.root_dir%/../web"
tags:
- { name: twig.extension }

View File

@ -9,14 +9,18 @@ class AppExtension extends \Twig_Extension
/** @var FormatTransformer */
private $formatTransformer;
/** @var string */
private $webDir;
/**
* AppExtension constructor.
*
* @param FormatTransformer $formatTransformer
*/
public function __construct(FormatTransformer $formatTransformer)
public function __construct(FormatTransformer $formatTransformer, $webDir)
{
$this->formatTransformer = $formatTransformer;
$this->webDir = $webDir;
}
public function getFilters()
@ -75,11 +79,7 @@ class AppExtension extends \Twig_Extension
public function fileTimestamp($filePath)
{
$changeDate = filemtime($_SERVER['DOCUMENT_ROOT'].'/'.$filePath);
if (!$changeDate) {
//Fallback if mtime could not be found:
$changeDate = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
}
$changeDate = filemtime($this->webDir.DIRECTORY_SEPARATOR.$filePath);
return $filePath.'?'.$changeDate;
}