Skip to content

Commit

Permalink
Use new FormRenderer
Browse files Browse the repository at this point in the history
  • Loading branch information
Rena Holmgren committed Jan 8, 2018
1 parent 62ac3bf commit af11511
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@
use Illuminate\Support\Facades\Blade;
use Barryvdh\Form\Extension\SessionExtension;
use Illuminate\View\View;
use Symfony\Bridge\Twig\Form\TwigRendererEngineInterface;
use Symfony\Bridge\Twig\Form\TwigRendererInterface;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormRendererInterface;
use Symfony\Component\Form\Forms;
use Symfony\Bridge\Twig\Form\TwigRenderer;
use Barryvdh\Form\Extension\EloquentExtension;
use Symfony\Bridge\Twig\Form\TwigRendererEngine;
use Symfony\Bridge\Twig\Form\TwigRendererEngineInterface;
use Barryvdh\Form\Extension\FormValidatorExtension;
use Symfony\Component\Form\ResolvedFormTypeFactory;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
Expand Down Expand Up @@ -53,14 +51,9 @@ public function boot()

$loader->addLoader(new \Twig_Loader_Filesystem($this->getTemplateDirectories()));

/** @var TwigRenderer $renderer */
$renderer = $this->app->make(TwigRenderer::class);
$renderer->setEnvironment($twig);


$twig->addRuntimeLoader(new \Twig_FactoryRuntimeLoader(array(
TwigRenderer::class => function () {
return $this->app->make(TwigRenderer::class);
\Symfony\Component\Form\FormRenderer::class => function () {
return $this->app->make(\Symfony\Component\Form\FormRenderer::class);
}
)));

Expand Down Expand Up @@ -94,14 +87,15 @@ public function register()

$this->app->singleton(TwigRendererEngine::class, function ($app) {
$theme = (array) $app['config']->get('form.theme', 'bootstrap_3_layout.html.twig');
return new TwigRendererEngine($theme);
return new TwigRendererEngine($theme, $app->make(\Twig_Environment::class));
});

$this->app->singleton(TwigRenderer::class, function ($app) {
$this->app->singleton(\Symfony\Component\Form\FormRenderer::class, function ($app) {
$renderer = $app->make(TwigRendererEngine::class);
return new TwigRenderer($renderer);
return new \Symfony\Component\Form\FormRenderer($renderer);
});
$this->app->alias(TwigRenderer::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 @@ -187,8 +181,8 @@ public function provides()
FormFactoryInterface::class,
TwigRendererEngine::class,
TwigRendererEngineInterface::class,
TwigRenderer::class,
TwigRendererInterface::class,
\Symfony\Component\Form\FormRenderer::class,
\Symfony\Component\Form\FormRendererInterface::class,
FormRendererInterface::class,
FormFactoryInterface::class,
'form.factory',
Expand Down

0 comments on commit af11511

Please sign in to comment.