Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make OptimizeCommand compile views #4565

Merged
merged 1 commit into from
Jun 6, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/Illuminate/Foundation/Console/OptimizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Illuminate\Console\Command;
use Illuminate\Foundation\Composer;
use Illuminate\View\Engines\CompilerEngine;
use ClassPreloader\Command\PreCompileCommand;
use Symfony\Component\Console\Input\InputOption;

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

$this->compileClasses();

$this->info('Compiling views');

$this->compileViews();
}
else
{
Expand Down Expand Up @@ -113,6 +118,32 @@ protected function registerClassPreloaderCommand()
$this->getApplication()->add(new PreCompileCommand);
}

/**
* Compile all view files.
*
* @return void
*/
protected function compileViews()
{
$paths = $this->laravel['view']->getFinder()
->getPaths();

foreach ($paths as $dir)
{
$files = $this->laravel['files']->allFiles($dir);

foreach ($files as $path)
{
$engine = $this->laravel['view']->getEngineFromPath($path);

if ($engine instanceof CompilerEngine)
{
$engine->getCompiler()->compile($path);
}
}
}
}

/**
* Get the console command options.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/View/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public function renderEach($view, $data, $iterator, $empty = 'raw|')
* @param string $path
* @return \Illuminate\View\Engines\EngineInterface
*/
protected function getEngineFromPath($path)
public function getEngineFromPath($path)
{
$engine = $this->extensions[$this->getExtension($path)];

Expand Down