-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: crynobone <crynobone@gmail.com>
- Loading branch information
Showing
5 changed files
with
73 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php namespace Orchestra\View\Console; | ||
|
||
use InvalidArgumentException; | ||
use Illuminate\View\Engines\CompilerEngine; | ||
use Illuminate\Console\Command as BaseCommand; | ||
|
||
class OptimizeCommand extends BaseCommand | ||
{ | ||
/** | ||
* The console command name. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'theme:optimize'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Pre-cache themes views in the application.'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return void | ||
*/ | ||
public function handle() | ||
{ | ||
$this->info('Compiling views'); | ||
|
||
$this->compileViews(); | ||
} | ||
|
||
/** | ||
* Compile all view files. | ||
* | ||
* @return void | ||
*/ | ||
protected function compileViews() | ||
{ | ||
foreach ($this->laravel['view']->getFinder()->getPaths() as $path) { | ||
foreach ($this->laravel['files']->allFiles($path) as $file) { | ||
try { | ||
$engine = $this->laravel['view']->getEngineFromPath($file); | ||
} catch (InvalidArgumentException $e) { | ||
continue; | ||
} | ||
|
||
if ($engine instanceof CompilerEngine) { | ||
$engine->getCompiler()->compile($file); | ||
} | ||
} | ||
} | ||
} | ||
} |