示例#1
0
 public function getAction(Request $req, Application $app)
 {
     return $app->render('top.html');
 }
示例#2
0
文件: app.php 项目: rabbl/pwx
<?php

$startTime = microtime(true);
// Bootstrap
require_once __DIR__ . '/../vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use App\Silex\Application;
// Config
$config = array('debug' => true, 'locale' => 'en', 'baseUrl' => '', 'theme' => 'yeti', 'requireHttps' => false, 'timer.start' => $startTime, 'monolog.name' => 'pwx', 'monolog.level' => \Monolog\Logger::DEBUG, 'monolog.logfile' => __DIR__ . '/../log/app.log', 'twig.path' => __DIR__ . '/../src/App/views', 'twig.options' => array('cache' => __DIR__ . '/../cache/twig'), 'orm.em.options' => array('mappings' => array(array('type' => 'annotation', 'namespace' => 'App\\Entity', 'path' => __DIR__ . '/../src/App/Entity'))));
if (file_exists(__DIR__ . '/config.php')) {
    include __DIR__ . '/config.php';
}
// Initialize Silex
$app = new App\Silex\Application($config);
// Register ControllerServiceProvider service
$app->register(new Silex\Provider\ServiceControllerServiceProvider());
// Register DoctrineServiceProvider service
$app->register(new Silex\Provider\DoctrineServiceProvider(), $config);
// Register DoctrineOrmServiceProvider service
$app->register(new Dflydev\Silex\Provider\DoctrineOrm\DoctrineOrmServiceProvider(), $config);
// Register theme service & set user theme
$app['i18n_service'] = $app->share(function () {
    return new App\Service\I18nService();
});
// Register translation service
$app->register(new Silex\Provider\TranslationServiceProvider(), array('locale_fallbacks' => array('en'), 'locale' => $app['i18n_service']->getLocale($config['locale'])));
// Register the yaml translations
$app['translator'] = $app->share($app->extend('translator', function (Silex\Translator $translator, $app) {
    $translator->addLoader('yaml', new Symfony\Component\Translation\Loader\YamlFileLoader());
    foreach ($app['i18n_service']->getValidLocales() as $locale) {