8000 Add config option to ignore view cache timestamps · laravel/framework@87d75ca · GitHub
[go: up one dir, main page]

Skip to content

Commit 87d75ca

Browse files
committed
Add config option to ignore view cache timestamps
1 parent 44e6a29 commit 87d75ca

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/Illuminate/View/Compilers/Compiler.php

+14-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,14 @@ abstract class Compiler
4242
*
4343
* @var string
4444
*/
45-
protected $compiledExtension = 'php';
45+
protected $compiledExtension;
46+
47+
/**
48+
* Determines if view cache timestamps should be ignored.
49+
*
50+
* @var bool
51+
*/
52+
protected $ignoreCacheTimestamps;
4653

4754
/**
4855
* Create a new compiler instance.
@@ -61,6 +68,7 @@ public function __construct(
6168
$basePath = '',
6269
$shouldCache = true,
6370
$compiledExtension = 'php',
71+
$ignoreCacheTimestamps = false,
6472
) {
6573
if (! $cachePath) {
6674
throw new InvalidArgumentException('Please provide a valid cache path.');
@@ -71,6 +79,7 @@ public function __construct(
7179
$this->basePath = $basePath;
7280
$this->shouldCache = $shouldCache;
7381
$this->compiledExtension = $compiledExtension;
82+
$this->ignoreCacheTimestamps = $ignoreCacheTimestamps;
7483
}
7584

7685
/**
@@ -94,6 +103,10 @@ public function getCompiledPath($path)
94103
*/
95104
public function isExpired($path)
96105
{
106+
if ($this->ignoreCacheTimestamps) {
107+
return false;
108+
}
109+
97110
if (! $this->shouldCache) {
98111
return true;
99112
}

src/Illuminate/View/ViewServiceProvider.php

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public function registerBladeCompiler()
100100
$app['config']->get('view.relative_hash', false) ? $app->basePath() : '',
101101
$app['config']->get('view.cache', true),
102102
$app['config']->get('view.compiled_extension', 'php'),
103+
$app['config']->get('view.ignore_cache_timestamps', false),
103104
), function ($blade) {
104105
$blade->component('dynamic-component', DynamicComponent::class);
105106
});

tests/View/ViewBladeCompilerTest.php

+6
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ public function testIsExpiredReturnsTrueWhenUseCacheIsFalse()
5555
$this->assertTrue($compiler->isExpired('foo'));
5656
}
5757

58+
public function testIsExpiredReturnsFalseWhenIgnoreCacheTimestampsIsTrue()
59+
{
60+
$compiler = new BladeCompiler($this->getFiles(), __DIR__, $ignoreCacheTimestamps = true);
61+
$this->assertFalse($compiler->isExpired('foo'));
62+
}
63+
5864
public function testCompilePathIsProperlyCreated()
5965
{
6066
$compiler = new BladeCompiler($this->getFiles(), __DIR__);

0 commit comments

Comments
 (0)
0