Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e91f016

Browse files
committed
Merge pull request #4565 from alprs/feature/optimize-compile-views
Make OptimizeCommand compile views
2 parents 4ce3061 + 27d4230 commit e91f016

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/Illuminate/Foundation/Console/OptimizeCommand.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Illuminate\Console\Command;
44
use Illuminate\Foundation\Composer;
5+
use Illuminate\View\Engines\CompilerEngine;
56
use ClassPreloader\Command\PreCompileCommand;
67
use Symfony\Component\Console\Input\InputOption;
78

@@ -64,6 +65,10 @@ public function fire()
6465
$this->info('Compiling common classes');
6566

6667
$this->compileClasses();
68+
69+
$this->info('Compiling views');
70+
71+
$this->compileViews();
6772
}
6873
else
6974
{
@@ -113,6 +118,32 @@ protected function registerClassPreloaderCommand()
113118
$this->getApplication()->add(new PreCompileCommand);
114119
}
115120

121+
/**
122+
* Compile all view files.
123+
*
124+
* @return void
125+
*/
126+
protected function compileViews()
127+
{
128+
$paths = $this->laravel['view']->getFinder()
129+
->getPaths();
130+
131+
foreach ($paths as $dir)
132+
{
133+
$files = $this->laravel['files']->allFiles($dir);
134+
135+
foreach ($files as $path)
136+
{
137+
$engine = $this->laravel['view']->getEngineFromPath($path);
138+
139+
if ($engine instanceof CompilerEngine)
140+
{
141+
$engine->getCompiler()->compile($path);
142+
}
143+
}
144+
}
145+
}
146+
116147
/**
117148
* Get the console command options.
118149
*

src/Illuminate/View/Factory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public function renderEach($view, $data, $iterator, $empty = 'raw|')
247247
* @param string $path
248248
* @return \Illuminate\View\Engines\EngineInterface
249249
*/
250-
protected function getEngineFromPath($path)
250+
public function getEngineFromPath($path)
251251
{
252252
$engine = $this->extensions[$this->getExtension($path)];
253253

0 commit comments

Comments
 (0)