本文整理汇总了PHP中Symfony\Component\HttpKernel\Kernel::handle方法的典型用法代码示例。如果您正苦于以下问题:PHP Kernel::handle方法的具体用法?PHP Kernel::handle怎么用?PHP Kernel::handle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpKernel\Kernel
的用法示例。
在下文中一共展示了Kernel::handle方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveTokenAction
/**
* @return \Symfony\Component\HttpFoundation\Response $response
*/
public function saveTokenAction()
{
if (!$this->request->query->has('oauth_token') || !$this->request->query->has('oauth_verifier')) {
return $this->goToSettingsAction();
}
$path['_controller'] = 'weaving_the_web_user.controller.twitter:getAccessTokenAction';
$subRequest = $this->request->duplicate(['oauth_token' => $this->request->get('oauth_token'), 'oauth_verifier' => $this->request->get('oauth_verifier')], null, $path);
/**
* @var \Symfony\Component\HttpFoundation\Response $response
*/
$response = $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
$content = $response->getContent();
$tokenParameters = json_decode($content, true);
if (json_last_error() !== JSON_ERROR_NONE) {
return $this->goToSettingsAction();
}
$this->persistToken($tokenParameters);
$subRequest = $this->request->duplicate(null, null, ['_controller' => 'weaving_the_web_user.controller.settings:showAction']);
return $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
}
示例2: handleRequest
/**
* {@inheritdoc}
*/
public function handleRequest(RequestInterface $request)
{
$symfonyRequest = $request->getHttpFoundationRequest();
$symfonyResponse = $this->kernel->handle($symfonyRequest);
$this->kernel->terminate($symfonyRequest, $symfonyResponse);
return $symfonyResponse;
}
示例3: replay
public function replay(Request $baseRequest, Notification $notification)
{
$webHook = $notification->getWebHook();
$endpoint = $webHook->getEndpoint();
$content = json_decode($notification->getContent(), true);
$query = array_merge(['username' => $webHook->getUser()->getUsername(), 'endpoint' => $endpoint], $content['query']);
$url = $this->router->generate('notifications', $query);
$request = Request::create($url, $content['method'], [], [], [], $baseRequest->server->all(), $content['body']);
$request->headers->replace($content['headers']);
$response = $this->kernel->handle($request, HttpKernelInterface::SUB_REQUEST);
return $response;
}
示例4: handle
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
$isUserHashRequest = $this->isUserHashRequest($request);
if ($isUserHashRequest && !$this->canGenerateUserHash($request)) {
return new Response('', 405);
} else {
if ($isUserHashRequest && !$this->generatingUserHash) {
return new Response('', 200, array('X-User-Hash' => $this->generateUserHash($request)));
}
}
return parent::handle($request, $type, $catch);
}
示例5: renderWithParameters
/**
* Renders the given route with the given parameter.
*
* @param Route $route Route.
* @param string $name Name of the route; the default value is `null`.
* @param array $parameter Array of parameters; the default value is an empty array.
*
* @return void
*/
protected function renderWithParameters(Route $route, $name = null, array $parameter = array())
{
$request = $this->buildRequest($route, $name, $parameter);
$response = $this->kernel->handle($request);
$content = $response->getContent();
$this->kernel->terminate($request, $response);
$this->kernel->shutdown();
if (null !== $name) {
$filename = $this->router->generate($name, $parameter);
} else {
$filename = $route->getPath();
}
$this->writer->write($filename, $content);
}
示例6: handle
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
if (false === $this->booted && $this->enableTenanting) {
// Find and set the current tenant
try {
$tenant = $this->getCurrentTenantKey($request);
$this->getTenantRegistry()->setCurrent($tenant);
// Change the environment to the tenant's environment
$this->environment = 'tenant_' . $tenant;
} catch (\OutOfBoundsException $e) {
throw new NotFoundHttpException('Could not find tenant');
} catch (\RuntimeException $e) {
}
$this->boot();
}
return parent::handle($request, $type, $catch);
}
示例7: handle
/**
* {@inheritdoc}
*/
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
if (strpos($request->getRequestUri(), 'installer') !== false || !$this->isInstalled()) {
define('MAUTIC_INSTALLER', 1);
}
if (false === $this->booted) {
$this->boot();
}
//the context is not populated at this point so have to do it manually
$router = $this->getContainer()->get('router');
$requestContext = new \Symfony\Component\Routing\RequestContext();
$requestContext->fromRequest($request);
$router->setContext($requestContext);
if (strpos($request->getRequestUri(), 'installer') === false && !$this->isInstalled()) {
//the context is not populated at this point so have to do it manually
$router = $this->getContainer()->get('router');
$requestContext = new \Symfony\Component\Routing\RequestContext();
$requestContext->fromRequest($request);
$router->setContext($requestContext);
$base = $requestContext->getBaseUrl();
//check to see if the .htaccess file exists or if not running under apache
if (strpos(strtolower($_SERVER["SERVER_SOFTWARE"]), 'apache') === false || !file_exists(__DIR__ . '../.htaccess') && strpos($base, 'index') === false) {
$base .= '/index.php';
}
//return new RedirectResponse();
return new RedirectResponse($base . '/installer');
}
// Check for an an active db connection and die with error if unable to connect
if (!defined('MAUTIC_INSTALLER')) {
$db = $this->getContainer()->get('database_connection');
try {
$db->connect();
} catch (\Exception $e) {
error_log($e);
throw new \Mautic\CoreBundle\Exception\DatabaseConnectionException($this->getContainer()->get('translator')->trans('mautic.core.db.connection.error', array('%code%' => $e->getCode())));
}
}
return parent::handle($request, $type, $catch);
}
示例8: handleRaw
private function handleRaw(Request $request, $type = self::MASTER_REQUEST, $catch = true)
{
$this->container->enterScope('request');
$this->container->set('request', $request, 'request');
$this->container->get('request_stack')->push($request);
if ($type === self::MASTER_REQUEST) {
$this->request = $request;
}
Service::setRequest($request);
$event = new GetResponseEvent($this, $request, $type);
$this->container->get('event_dispatcher')->dispatch(KernelEvents::REQUEST, $event);
if ($request->attributes->get('_defaultHandler')) {
return parent::handle($request, $type, $catch);
}
// An event may have given a response
if ($event->hasResponse()) {
return $this->filterResponse($event->getResponse(), $request, $type);
}
$session = $this->container->get('session');
$session->start();
Service::setFormFactory($this->container->get('form.factory'));
$con = Controller::getController($request->attributes);
$response = $con->callAction();
return $this->filterResponse($response, $request, $type);
}
示例9: theKernelTerminates
/**
* @When the kernel terminates
*/
public function theKernelTerminates()
{
$request = Request::create('/', 'GET');
$response = $this->kernel->handle($request);
$this->kernel->terminate($request, $response);
}
示例10: updateJsLib
/**
* @return string
*/
public function updateJsLib()
{
$response = $this->kernel->handle(Request::create('/js/fp_js_validator.js'));
$libFile = $this->kernel->getRootDir() . '/../../Resources/public/js/fp_js_validator.js';
file_put_contents($libFile, $response->getContent());
}
示例11: handle
/**
* @param \Symfony\Component\HttpFoundation\Request $request
* @param int $type
* @param bool $catch
*
* @return Symfony\Component\HttpFoundation\Response
*/
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
$catch = false;
return parent::handle($request, $type, $catch);
}