/**
  * 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;
     });
 }
예제 #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;
             }
         }
     }
 }
예제 #3
0
파일: Auth.php 프로젝트: pinodex/boardy
 /**
  * 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();
 }