laravel/framework — pull request #345 by illuminaux (2013-02-16 23:34:32+00:00)
Title: [Bug] Hard-coded view file extensions take precedence over self-added, more accurately matching extensions.

The `Environment::getExtension($path)` method has a strong bias towards the two hard-coded extensions. In fact, the way the above method resolves the "correct" extension makes it impossible for me to associate view file extensions ending in `php` with a third party engine like Twig, Smarty etc.

Quick example:

// Suppose we have a view file named `hello.twig.php` under our main
// views directory that's ment to be consumed by the Twig templating
// engine. Further suppose we properly added the engine by means
// of a EngineServiceProvider and set it up correctly.

$env->addExtension('twig.php', 'twig');

// Current status of Environment::$extensions
dump($env): {
protected $extensions =>
array(3) {
'blade.php' => string(5) "blade"
'php' => string(3) "php"
'tiwg.php' => string(4) "twig"
}
}

// The call to Environment::getEngineFromPath('home.twig.php') wrongly
// returns the `php` engine instead
$env->make('home', $data);

With the fix itself I've included a test in `ViewEnvironmentTest.php` that proofs the issue.