Skip to content

Commit 9817f1f

Browse files
rojtjobarryvdh
authored andcommitted
Fixing issue where unconfigured environment was used. (#32)
* Ensure Twig_Environment is bound to the container * Removing space to fix phpcs error
1 parent 38c09be commit 9817f1f

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/ServiceProvider.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function register()
9090
return new \Symfony\Component\Form\FormRenderer($renderer);
9191
});
9292

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

9595
$this->app->bind('form.type.extensions', function ($app) {
9696
return array(
@@ -207,13 +207,15 @@ protected function getTemplateDirectories()
207207
*/
208208
protected function getTwigEnvironment()
209209
{
210-
if ($this->app->bound(\Twig_Environment::class)) {
211-
/** @var \Twig_Environment $twig */
212-
return $this->app->make(\Twig_Environment::class);
210+
if (! $this->app->bound(\Twig_Environment::class)) {
211+
$this->app->singleton(\Twig_Environment::class, function () {
212+
return new \Twig_Environment(new \Twig_Loader_Chain([]), [
213+
'cache' => storage_path('framework/views/twig'),
214+
]);
215+
});
213216
}
214217

215-
return new \Twig_Environment(new \Twig_Loader_Chain([]), [
216-
'cache' => storage_path('framework/views/twig'),
217-
]);
218+
/** @var \Twig_Environment $twig */
219+
return $this->app->make(\Twig_Environment::class);
218220
}
219221
}

0 commit comments

Comments
 (0)