/**
  * Boot the Twig Global Functions
  *
  * @param Silex\Application $app
  */
 public function boot(Application $app)
 {
     $app->extend('twig', function (\Twig_Environment $twig, Application $app) {
         $twig->addGlobal('app', null);
         $twig->addGlobal('forum_name', Config::get('forum_name', 'Boardy Forums'));
         $twig->addGlobal('current_user', Auth::user());
         $twig->addGlobal('request_uri', $app['request']->getRequestUri());
         $twig->addGlobal('request_route', $app['request']->get('_route'));
         if (isset($app['flashbag'])) {
             $twig->addGlobal('flashbag', $app['flashbag']);
         }
         return $twig;
     });
 }
Beispiel #2
0
 /**
  * Load activated extensions
  */
 public static function load()
 {
     self::$base = ROOT . 'resources/extensions';
     $extensions = Config::get('activated_extensions', []);
     foreach ($extensions as $extension) {
         if ($entryFile = self::getEntryFile($extension)) {
             include_once $entryFile;
             if (class_exists($extension)) {
                 $entryClass = new $extension();
                 $entryClass->load();
                 self::$loadedExtensions[] = $extension;
             }
         }
     }
 }
Beispiel #3
0
 /**
  * Get the groups the current user belong to
  * 
  * @return array
  */
 public static function groups()
 {
     $groupIds = [Config::get('guest_group_id', 0)];
     if ($user = self::user()) {
         $groupIds = $user->groups->pluck('id')->all();
     }
     return Group::whereIn('id', $groupIds)->with('boards')->get();
 }
Beispiel #4
0
$app->register(new Silex\Provider\TranslationServiceProvider(), array('translator.messages' => array()));
require ROOT . 'config/app.php';
Debug\ErrorHandler::register();
Debug\ExceptionHandler::register($app['debug']);
$app['theme.path'] = ROOT . 'resources/themes/' . $app['theme.name'];
$app->register(new Providers\IlluminateDatabaseServiceProvider());
$app->register(new Providers\AssetsServiceProvider());
if ($app['debug']) {
    $app->register(new Provider\HttpFragmentServiceProvider());
    $app->register(new Provider\ServiceControllerServiceProvider());
    $app->register(new Provider\WebProfilerServiceProvider());
}
/*
 * Initialize connection to database.
 */
$app['database'];
$app['session.storage.handler'] = $app->share(function () use($app) {
    return new Services\Session\IlluminateDatabaseSessionHandler($app['database'], $app['session.storage.handler.options']);
});
$app['flashbag'] = $app->share(function () use($app) {
    return $app['session']->getFlashBag();
});
$app->register(new Providers\MarkdownServiceProvider());
$app->register(new Providers\TwigGlobalFunctionsProvider());
$app['twig.loader.filesystem']->addPath(APP . 'Views', 'main');
$app['twig.loader.filesystem']->addPath($app['theme.path'] . '/views', 'theme');
Service::setApp($app);
Config::load();
require 'routes.php';
ExtensionLoader::load();
return $app;