/**
  * Handle request in HTTP stack
  * 
  * @param   object  $request  HTTP Request
  * @return  mixed
  */
 public function handle(Request $request)
 {
     if (!$this->app->runningInConsole()) {
         $this->app['dispatcher']->trigger('system.onBeforeRoute');
         foreach ($this->app['router']->parse($request->getUri()) as $key => $val) {
             $request->setVar($key, $val, 'get');
         }
         $this->app['dispatcher']->trigger('system.onAfterRoute');
         if ($this->app->has('profiler')) {
             $this->app['profiler'] ? $this->app['profiler']->mark('afterRoute') : null;
         }
     }
     return $this->next($request);
 }
 /**
  * Handle request in stack
  * 
  * @param   object  $request  Request
  * @return  mixed
  */
 public function handle(Request $request)
 {
     $response = $this->next($request);
     // Get the referer to parse for the applicable app
     $referer = $request->header('referer');
     $app = Request::create($referer)->segment(1, 'site');
     $app = in_array($app, ['site', 'administrator']) ? $app : 'site';
     // Get secret and session name manually
     $secret = $this->app['config']->get('secret');
     $cookie_name = md5(md5($secret . $app));
     $session_id = $request->getVar($cookie_name, false, 'COOKIE');
     // Build moderator
     $identifier = $request->segment(2);
     $moderator = new Moderator($identifier, $session_id, $secret);
     if (!$moderator->validateToken()) {
         header('HTTP/1.1 401 You don\'t have permission to do this');
         exit;
     }
     $this->app['moderator'] = $moderator;
     return $response;
 }
Пример #3
0
 /**
  * Create a new application instance.
  *
  * @param   object  $request   Request object
  * @param   object  $response  Response object
  * @return  void
  */
 public function __construct(Request $request = null, Response $response = null)
 {
     parent::__construct();
     $this['request'] = $request ?: Request::createFromGlobals();
     $this['response'] = $response ?: new Response();
     $this->registerBaseServiceProviders();
 }
Пример #4
0
 /**
  * Create a new application instance.
  *
  * @param   object  $request   Request object
  * @param   object  $response  Response object
  * @return  void
  */
 public function __construct(Request $request = null, Response $response = null)
 {
     parent::__construct();
     $this['request'] = $request ?: Request::createFromGlobals();
     $this['response'] = $response ?: new Response();
 }