Skip to content

Commit

Permalink
Refactor OptimizeCommand.
Browse files Browse the repository at this point in the history
Signed-off-by: crynobone <crynobone@gmail.com>
  • Loading branch information
crynobone committed May 17, 2015
1 parent 2f24f0e commit 9966b9c
Showing 1 changed file with 35 additions and 10 deletions.
45 changes: 35 additions & 10 deletions src/Console/OptimizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,42 @@ public function handle()
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);
}
$this->compileViewsInPath($path);
}
}

/**
* Compile all views files in path.
*
* @param string $path
*
* @return void
*/
protected function compileViewsInPath($path)
{
foreach ($this->laravel['files']->allFiles($path) as $file) {
try {
$engine = $this->laravel['view']->getEngineFromPath($file);
} catch (InvalidArgumentException $e) {
continue;
}

$this->compileViewFile($engine, $file);
}
}

/**
* Compile single view file.
*
* @param mixed $engine
* @param string $file
*
* @return void
*/
protected function compileSingleViewFile($engine, $file)
{
if ($engine instanceof CompilerEngine) {
$engine->getCompiler()->compile($file);
}
}
}

0 comments on commit 9966b9c

Please sign in to comment.