Beispiel #1
0
if (isset($config['bg-image']['image'])) {
    $app['image'] = '/images/' . $config['bg-image']['image'];
}
# store regularly used variables(services?) in the app container
$dbmanager = new DbManager();
# app['dbh'] is a connection instance and is passed to the constructor
# of the database repository.
$app['dbh'] = $dbmanager->getPdoInstance();
$db = new DbRepository($app['dbh']);
# The $pages variable will be accessible in twig templates as app.pages.
# and will (usually) be an array of page objects
# so you can loop through with a twig for loop.
# e.g {% for page in app.pages %}{{ page.pageName or page.pageTemplate }}
# this will save having to query the database every time you want to access
# the page objects.
$app['pages'] = $db->getAllPages();
$app['images'] = $db->viewImages();
# twig loaders for templates: a database loader for dynamically created templates,
# and a filesystem loader for templates stored on the filesystem.
$app['loader1'] = new Twig_Loader_Filesystem(array($myTemplatesPath1, $myTemplatesPath2));
$app['loader2'] = new DatabaseTwigLoader($app['dbh']);
$app['debug'] = true;
# ______________________________________________________________
#              ADD PROVIDERS HERE
# ______________________________________________________________
#
$app->register(new Silex\Provider\ValidatorServiceProvider());
$app->register(new Silex\Provider\UrlGeneratorServiceProvider());
$app->register(new Silex\Provider\SessionServiceProvider());
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.loader' => $app->share(function () use($app) {
    return new Twig_Loader_Chain(array($app['loader1'], $app['loader2']));