Skip to content

Commit

Permalink
allow extension
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Apr 22, 2022
1 parent f1d20b8 commit 68e41fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/Illuminate/View/Compilers/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,31 @@ abstract class Compiler
*/
protected $shouldCache;

/**
* The compiled view file extension.
*
* @var string
*/
protected $compiledExtension = 'php';

/**
* Create a new compiler instance.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @param string $cachePath
* @param string $basePath
* @param bool $shouldCache
* @param string $compiledExtension
* @return void
*
* @throws \InvalidArgumentException
*/
public function __construct(Filesystem $files, $cachePath, $basePath = '', $shouldCache = true)
public function __construct(
Filesystem $files,
$cachePath,
$basePath = '',
$shouldCache = true,
$compiledExtension = 'php')
{
if (! $cachePath) {
throw new InvalidArgumentException('Please provide a valid cache path.');
Expand All @@ -57,6 +70,7 @@ public function __construct(Filesystem $files, $cachePath, $basePath = '', $shou
$this->cachePath = $cachePath;
$this->basePath = $basePath;
$this->shouldCache = $shouldCache;
$this->compiledExtension = $compiledExtension;
}

/**
Expand All @@ -67,7 +81,7 @@ public function __construct(Filesystem $files, $cachePath, $basePath = '', $shou
*/
public function getCompiledPath($path)
{
return $this->cachePath.'/'.sha1('v2'.Str::after($path, $this->basePath)).'.php';
return $this->cachePath.'/'.sha1('v2'.Str::after($path, $this->basePath)).'.'.$this->compiledExtension;
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/Illuminate/View/ViewServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public function registerBladeCompiler()
$app['config']['view.compiled'],
$app['config']->get('view.relative_hash', false) ? $app->basePath() : '',
$app['config']->get('view.cache', true),
$app['config']->get('view.compiled_extension', 'php'),
), function ($blade) {
$blade->component('dynamic-component', DynamicComponent::class);
});
Expand Down

0 comments on commit 68e41fd

Please sign in to comment.