本文整理汇总了PHP中Symfony\Component\HttpKernel\HttpKernelInterface::terminate方法的典型用法代码示例。如果您正苦于以下问题:PHP HttpKernelInterface::terminate方法的具体用法?PHP HttpKernelInterface::terminate怎么用?PHP HttpKernelInterface::terminate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpKernel\HttpKernelInterface
的用法示例。
在下文中一共展示了HttpKernelInterface::terminate方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: terminate
/**
* {@inheritdoc}
*/
public function terminate(Request $request, Response $response)
{
parent::terminate($request, $response);
if ($this->app instanceof TerminableInterface) {
$this->app->terminate($request, $response);
}
}
示例2: onRequest
/**
* Handle a request using a HttpKernelInterface implementing application.
*
* @param \React\Http\Request $request
* @param \React\Http\Response $response
*/
public function onRequest(ReactRequest $request, ReactResponse $response)
{
if (null === $this->application) {
return;
}
$content = '';
$headers = $request->getHeaders();
$contentLength = isset($headers['Content-Length']) ? (int) $headers['Content-Length'] : 0;
$request->on('data', function ($data) use($request, $response, &$content, $contentLength) {
// read data (may be empty for GET request)
$content .= $data;
// handle request after receive
if (strlen($content) >= $contentLength) {
$syRequest = self::mapRequest($request, $content);
try {
$syResponse = $this->application->handle($syRequest);
} catch (\Exception $exception) {
$response->writeHead(500);
// internal server error
$response->end();
return;
}
self::mapResponse($response, $syResponse);
if ($this->application instanceof TerminableInterface) {
$this->application->terminate($syRequest, $syResponse);
}
}
});
}
示例3: terminate
/**
* @param Request $request
* @param Response $response
*/
public function terminate(Request $request, Response $response)
{
$this->newRelic->endOfTransaction();
if ($this->app instanceof TerminableInterface) {
$this->app->terminate($request, $response);
}
}
示例4: onRequest
/**
* Handle a request
*
* @param ReactRequest $request
* @param ReactResponse $response
*/
public function onRequest(ReactRequest $request, ReactResponse $response)
{
$content = '';
$headers = $request->getHeaders();
$contentLength = isset($headers['Content-Length']) ? (int) $headers['Content-Length'] : 0;
$request->on('data', function ($data) use($request, $response, &$content, $contentLength) {
// Read data (may be empty for GET request)
$content .= $data;
// Handle request after receive
if (strlen($content) >= $contentLength) {
$symfonyRequest = static::mapRequest($request, $content);
try {
// Execute
$symfonyResponse = $this->application->handle($symfonyRequest);
} catch (\Throwable $t) {
// Executed only in PHP 7, will not match in PHP 5.x
$this->fatalError($response, $t);
return;
} catch (\Exception $e) {
// Executed only in PHP 5.x, will not be reached in PHP 7
$this->fatalError($response, $e);
return;
}
static::mapResponse($response, $symfonyResponse);
if ($this->application instanceof SymfonyHttpKernel\TerminableInterface) {
$this->application->terminate($symfonyRequest, $symfonyResponse);
}
}
});
}
示例5: terminate
/**
* @param Request $request
* @param Response $response
*/
public function terminate(Request $request, Response $response)
{
$logger = $this->loggerFactory->create('app.request');
$routeName = $request->attributes->get('_route');
$logger->notice(sprintf('Route %s matched', $routeName), array('route' => $routeName, 'response_code' => $response->getStatusCode(), 'response_size' => strlen($response->getContent())));
$this->loggerFactory->flushBuffer();
if ($this->app instanceof TerminableInterface) {
$this->app->terminate($request, $response);
}
}
示例6: terminate
public function terminate(Request $request, Response $response)
{
foreach ($this->map as $path => $app) {
if ($app instanceof TerminableInterface) {
$app->terminate($request, $response);
}
}
if ($this->app instanceof TerminableInterface) {
$this->app->terminate($request, $response);
}
}
示例7: run
function run(HttpKernelInterface $app, Request $request = null)
{
$request = $request ?: Request::createFromGlobals();
$response = $app->handle($request);
$response->send();
if ($app instanceof TerminableInterface) {
$app->terminate($request, $response);
}
}
示例8: doRun
/**
* @param Request $request
* @param $type
*/
private function doRun(Request $request, $type)
{
if (false === $this->isResolved) {
$this->resolvedApp = $this->builder->resolve($this);
$this->isResolved = true;
}
$request = $request ?: Request::createFromGlobals();
$response = $this->resolvedApp->handle($request, $type);
$response->send();
if ($this->resolvedApp instanceof TerminableInterface) {
$this->resolvedApp->terminate($request, $response);
}
}
示例9: terminate
/**
* Terminates the request/response cycle
*
* @param Request $request The request
* @param Response $response The response
*
* @return void
*/
public function terminate(Request $request, Response $response)
{
if ($this->kernel instanceof TerminableInterface) {
$this->kernel->terminate($request, $response);
}
}
示例10: terminate
/**
* Terminates a request/response cycle.
*
* @param SyfmonyRequest $request A Request instance
* @param Response $response A Response instance
*
* @api
*/
public function terminate(SyfmonyRequest $request, Response $response)
{
$this->httpKernel->terminate(Request::createFromBase($request), $response);
}
示例11: terminate
/**
* Terminates a request/response cycle.
*
* @param Request $request
* @param Response $response
*/
public function terminate(Request $request, Response $response)
{
$this->kernel->terminate($request, $response);
}
示例12: terminate
/**
* Terminates a request/response cycle.
*
* @param DomRequest $request A Request instance
* @param Response $response A Response instance
*
* @api
*/
public function terminate(DomRequest $request, Response $response)
{
$this->httpKernel->terminate($request, $response);
}