Skip to content

Commit

Permalink
Fixing issue where unconfigured environment was used. (#32)
Browse files Browse the repository at this point in the history
* Ensure Twig_Environment is bound to the container

* Removing space to fix phpcs error
  • Loading branch information
rojtjo authored and barryvdh committed Apr 21, 2018
1 parent 38c09be commit 9817f1f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function register()
return new \Symfony\Component\Form\FormRenderer($renderer);
});

$this->app->alias( \Symfony\Component\Form\FormRenderer::class, FormRendererInterface::class);
$this->app->alias(\Symfony\Component\Form\FormRenderer::class, FormRendererInterface::class);

$this->app->bind('form.type.extensions', function ($app) {
return array(
Expand Down Expand Up @@ -207,13 +207,15 @@ protected function getTemplateDirectories()
*/
protected function getTwigEnvironment()
{
if ($this->app->bound(\Twig_Environment::class)) {
/** @var \Twig_Environment $twig */
return $this->app->make(\Twig_Environment::class);
if (! $this->app->bound(\Twig_Environment::class)) {
$this->app->singleton(\Twig_Environment::class, function () {
return new \Twig_Environment(new \Twig_Loader_Chain([]), [
'cache' => storage_path('framework/views/twig'),
]);
});
}

return new \Twig_Environment(new \Twig_Loader_Chain([]), [
'cache' => storage_path('framework/views/twig'),
]);
/** @var \Twig_Environment $twig */
return $this->app->make(\Twig_Environment::class);
}
}

0 comments on commit 9817f1f

Please sign in to comment.