franmomu / silex-pagerfanta-provider

Pagerfanta Silex Provider
14 stars 11 forks source link

Handle if extension is already loaded when rendering multiple views #7

Closed beleneglorion closed 9 years ago

beleneglorion commented 10 years ago

When rendering multiple twig file in the same "controller" a LogicException is throw , you need to test if the extension il already loaded before add it

burki commented 9 years ago

I had the same issue, using $app>share as in http://silex.sensiolabs.org/doc/providers/twig.html#customization solves it without calling $twig->hasExtension:

    if (isset($app['twig'])) {
        $app['twig'] = $app->share($app->extend('twig', function($twig, $app) {
            $twig->addExtension(new PagerfantaExtension($app));

            return $twig;
        }));
    }
franmomu commented 9 years ago

Sorry I totally forgot about this, can you send a PR with that solution? Thanks!

burki commented 9 years ago

https://github.com/plotek/silex-pagerfanta-provider/compare/franmomu:master...master gives you the proper diff, see https://github.com/franmomu/silex-pagerfanta-provider/pull/8 for the pull-request

franmomu commented 9 years ago

It was fixed in https://github.com/franmomu/silex-pagerfanta-provider/pull/7