33namespace Illuminate \View \Compilers ;
44
55use Illuminate \Filesystem \Filesystem ;
6+ use Illuminate \Support \Str ;
67use InvalidArgumentException ;
78
89abstract class Compiler
910{
1011 /**
11- * The Filesystem instance.
12+ * The filesystem instance.
1213 *
1314 * @var \Illuminate\Filesystem\Filesystem
1415 */
1516 protected $ files ;
1617
1718 /**
18- * Get the cache path for the compiled views.
19+ * The cache path for the compiled views.
1920 *
2021 * @var string
2122 */
2223 protected $ cachePath ;
2324
25+ /**
26+ * The base path that should be removed from paths before hashing.
27+ *
28+ * @var string
29+ */
30+ protected $ basePath ;
31+
2432 /**
2533 * Create a new compiler instance.
2634 *
2735 * @param \Illuminate\Filesystem\Filesystem $files
2836 * @param string $cachePath
37+ * @param string $basePath
2938 * @return void
3039 *
3140 * @throws \InvalidArgumentException
3241 */
33- public function __construct (Filesystem $ files , $ cachePath )
42+ public function __construct (Filesystem $ files , $ cachePath, $ basePath = '' )
3443 {
3544 if (! $ cachePath ) {
3645 throw new InvalidArgumentException ('Please provide a valid cache path. ' );
3746 }
3847
3948 $ this ->files = $ files ;
4049 $ this ->cachePath = $ cachePath ;
50+ $ this ->basePath = $ basePath ;
4151 }
4252
4353 /**
@@ -48,7 +58,7 @@ public function __construct(Filesystem $files, $cachePath)
4858 */
4959 public function getCompiledPath ($ path )
5060 {
51- return $ this ->cachePath .'/ ' .sha1 ($ path ).'.php ' ;
61+ return $ this ->cachePath .'/ ' .sha1 (Str:: after ( $ path, $ this -> basePath ) ).'.php ' ;
5262 }
5363
5464 /**
0 commit comments