本文整理汇总了PHP中Slim::call方法的典型用法代码示例。如果您正苦于以下问题:PHP Slim::call方法的具体用法?PHP Slim::call怎么用?PHP Slim::call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slim
的用法示例。
在下文中一共展示了Slim::call方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: call
/**
* 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: call
/**
* 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: call
/**
* 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: call
/**
* 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: testErrorHandlerUsesCurrentResponseObject
/**
* 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: testGetCurrentRoute
/**
* 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: call
/**
* 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);
}