Skip to content

Commit

Permalink
[AsseticExtension] make adding the assetic TwigExtension lazy
Browse files Browse the repository at this point in the history
this prevents twig to get initialized in a non-request scope, since that can
lead to problems when the UrlGenerator extension is enabled for twig.
  • Loading branch information
igorw committed Jun 23, 2011
1 parent a437c3f commit e807a80
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/SilexExtension/AsseticExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,7 @@ public function register(Application $app)
$factory->setFilterManager($app['assetic.filter_manager']);
return $factory;
});


/**
* Initializes Assetic
*/
$app->before(function() use($app) {
$app['assetic'];
});


/**
* Writes down all lazy asset manager and asset managers assets
*/
Expand Down Expand Up @@ -137,17 +129,19 @@ public function register(Application $app)
));
}
}
return $lazy;
return $lazy;
});

$app->before(function () use ($app) {
// twig support
if (isset($app['twig'])) {
$app['twig']->addExtension(new TwigAsseticExtension($app['assetic.factory']));
}
});

// autoloading the assetic library
if (isset($app['assetic.class_path'])) {
$app['autoloader']->registerNamespace('Assetic', $app['assetic.class_path']);
}

// twig support
if(isset($app['twig'])) {
$app['twig']->addExtension(new TwigAsseticExtension($app['assetic.factory']));
}
}
}

0 comments on commit e807a80

Please sign in to comment.