nymo / silex-twig-breadcrumb-extension

Twig breadcrumb extension with service provider for Silex
MIT License
7 stars 6 forks source link

renderBreadCrumbs already initialized #2

Closed MHaendel closed 10 years ago

MHaendel commented 10 years ago

When I change a Template and reload it the first time, I get this:

Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("Unable to register extension "renderBreadCrumbs" as extensions have already been initialized.") in "layout.html" at line 225.

After a reload it's okay and works. Sometimes this happens randomly

MHaendel commented 10 years ago

This is the fix:

$app['twig'] = $app->share($app->extend('twig', function($twig, $app) {
    $twig->addExtension(new \nymo\Twig\Extension\BreadCrumbExtension($app));
    return $twig;
}));
nymo commented 10 years ago

Thanks for that haven't had this issue in my projects but it makes sense to use this extension as a shared service. Will update the docs tomorrow.