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:
parent
6685658a89
commit
a7f11179c9
@ -123,6 +123,8 @@ services:
|
||||
# Twig
|
||||
|
||||
AppBundle\Twig\AppExtension:
|
||||
arguments:
|
||||
$webDir: "%kernel.root_dir%/../web"
|
||||
tags:
|
||||
- { name: twig.extension }
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user