3
3
namespace Illuminate \View \Compilers ;
4
4
5
5
use Illuminate \Filesystem \Filesystem ;
6
+ use Illuminate \Support \Str ;
6
7
use InvalidArgumentException ;
7
8
8
9
abstract class Compiler
9
10
{
10
11
/**
11
- * The Filesystem instance.
12
+ * The filesystem instance.
12
13
*
13
14
* @var \Illuminate\Filesystem\Filesystem
14
15
*/
15
16
protected $ files ;
16
17
17
18
/**
18
- * Get the cache path for the compiled views.
19
+ * The cache path for the compiled views.
19
20
*
20
21
* @var string
21
22
*/
22
23
protected $ cachePath ;
23
24
25
+ /**
26
+ * The base path that should be removed from paths before hashing.
27
+ *
28
+ * @var string
29
+ */
30
+ protected $ basePath ;
31
+
24
32
/**
25
33
* Create a new compiler instance.
26
34
*
27
35
* @param \Illuminate\Filesystem\Filesystem $files
28
36
* @param string $cachePath
37
+ * @param string $basePath
29
38
* @return void
30
39
*
31
40
* @throws \InvalidArgumentException
32
41
*/
33
- public function __construct (Filesystem $ files , $ cachePath )
42
+ public function __construct (Filesystem $ files , $ cachePath, $ basePath = '' )
34
43
{
35
44
if (! $ cachePath ) {
36
45
throw new InvalidArgumentException ('Please provide a valid cache path. ' );
37
46
}
38
47
39
48
$ this ->files = $ files ;
40
49
$ this ->cachePath = $ cachePath ;
50
+ $ this ->basePath = $ basePath ;
41
51
}
42
52
43
53
/**
@@ -48,7 +58,7 @@ public function __construct(Filesystem $files, $cachePath)
48
58
*/
49
59
public function getCompiledPath ($ path )
50
60
{
51
- return $ this ->cachePath .'/ ' .sha1 ($ path ).'.php ' ;
61
+ return $ this ->cachePath .'/ ' .sha1 (Str:: after ( $ path, $ this -> basePath ) ).'.php ' ;
52
62
}
53
63
54
64
/**
0 commit comments