Пример #1
0
 /**
  * Call
  * @param   array $env
  * @return  array[status, header, body]
  */
 public function call(&$env)
 {
     $env['slim.flash'] = $this;
     list($status, $header, $body) = $this->app->call($env);
     $this->save();
     return array($status, $header, $body);
 }
Пример #2
0
 /**
  * Call
  * @param   array $env
  * @return  array[status, header, body]
  */
 public function call(&$env)
 {
     if (isset($env['CONTENT_TYPE'])) {
         $env['slim.input_original'] = $env['slim.input'];
         $env['slim.input'] = $this->parse($env['slim.input'], $env['CONTENT_TYPE']);
     }
     return $this->app->call($env);
 }
Пример #3
0
 /**
  * Call
  * @param array $env
  * @return array[status, header, body]
  */
 public function call(&$env)
 {
     try {
         return $this->app->call($env);
     } catch (Exception $e) {
         $env['slim.log']->error($e);
         $response = new Slim_Http_Response($this->renderBody($env, $e), 500);
         return $response->finalize();
     }
 }
Пример #4
0
 /**
  * Call
  *
  * Implements Slim middleware interface. This method is invoked and passed
  * an array of environemnt variables. This middleware inspects the environment
  * variables for the HTTP method override parameter; if found, this middleware
  * modifies the environment settings so downstream middleware and/or the Slim
  * application will treat the request with the desired HTTP method.
  *
  * @param   array $env
  * @return  array[status, header, body]
  */
 public function call(&$env)
 {
     if (isset($env['REQUEST_METHOD']) && $env['REQUEST_METHOD'] === 'POST') {
         $req = new Slim_Http_Request($env);
         $method = $req->post($this->settings['key']);
         if ($method) {
             $env['slim.method_override.original_method'] = $env['REQUEST_METHOD'];
             $env['REQUEST_METHOD'] = strtoupper($method);
         }
     }
     return $this->app->call($env);
 }
Пример #5
0
 /**
  * Test custom error handler uses existing Response object
  */
 public function testErrorHandlerUsesCurrentResponseObject()
 {
     $s = new Slim(array('debug' => false));
     $s->error(function (Exception $e) use($s) {
         $r = $s->response();
         $r->status(503);
         $r->write('Foo');
         $r['X-Powered-By'] = 'Slim';
         echo 'Bar';
     });
     $s->get('/bar', function () {
         throw new Exception('Foo');
     });
     $s->call();
     list($status, $header, $body) = $s->response()->finalize();
     $this->assertEquals(503, $status);
     $this->assertEquals('FooBar', $body);
     $this->assertEquals('Slim', $header['X-Powered-By']);
 }
Пример #6
0
 /**
  * Test get current route
  */
 public function testGetCurrentRoute()
 {
     Slim_Environment::mock(array('REQUEST_METHOD' => 'GET', 'SCRIPT_NAME' => '', 'PATH_INFO' => '/foo'));
     $app = new Slim();
     $route1 = $app->get('/bar', function () {
         echo "Bar";
     });
     $route2 = $app->get('/foo', function () {
         echo "Foo";
     });
     $app->call();
     $this->assertSame($route2, $app->router()->getCurrentRoute());
 }
Пример #7
0
 /**
  * Call
  * @param   array $env
  * @return  array[status, header, body]
  */
 public function call(&$env)
 {
     $this->loadSession($env);
     list($status, $header, $body) = $this->app->call($env);
     return $this->saveSession($env, $status, $header, $body);
 }