Handle the request.

@param \Symfony\Component\HttpFoundation\Request $request
@param int $type
@param bool $catch

@throws \Exception
@throws \LogicException

@return \Symfony\Component\HttpFoundation\Response
498424
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
    {
        // Passes the request to the container
        $this->getContainer()->add('Symfony\Component\HttpFoundation\Request', $request);

        try {
            $this->emit('request.received', $request);

            $dispatcher = $this->getRouter()->getDispatcher();
            $response = $dispatcher->dispatch(
                $request->getMethod(),
                $request->getPathInfo()
            );

            $this->emit('response.created', $request, $response);

            return $response;

        } catch (\Exception $e) {
            if (!$catch) {
                throw $e;
            }

            $response = call_user_func($this->exceptionDecorator, $e);
            if (!$response instanceof Response) {
                throw new \LogicException(
                    'Exception decorator did not return an instance of Symfony\Component\HttpFoundation\Response'
                );
            }

            $this->emit('response.created', $request, $response);

            return $response;
        }
    }
323704
private function finishRequest(Request $request, int $type)
    {
        $this->dispatcher->dispatch(new FinishRequestEvent($this, $request, $type), KernelEvents::FINISH_REQUEST);
        $this->requestStack->pop();
    }
1266001
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
	{
		$response = $this->app->handle($request, $type, $catch);

		foreach ($this->cookies->getQueuedCookies() as $cookie)
		{
			$response->headers->setCookie($cookie);
		}

		return $response;
	}
1238370
public function handleError($type, $message, $file, $line, $context)
    {
        if ($this->errorReporting() & $type) {
            $error = new \ErrorException($message, 0, $type, $file, $line);

            if ($this->convertFatalErrors && ($type & (E_RECOVERABLE_ERROR | E_USER_ERROR))) {
                throw $error;
            }

            if ($this->getLoggedErrorTypes() & $type) {
                $this->log($error);
            }
        }
        
        return $this->chainedErrorHandler
            ? call_user_func($this->chainedErrorHandler, $type, $message, $file, $line, $context)
            : false;
    }
416423
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
    {
        $filterResponse = new FilterResponse($request);
        $this->eventDispatcher->dispatch(KernelEvents::FILTER_REQUEST, $filterResponse);

        $response = $filterResponse->getResponse();
        if ($response instanceof Response) {
            return $response;
        }

        $controller = $request->attributes->get('_controller');
        if (!$controller) {
            throw new \InvalidArgumentException('Controller is not valid.');
        }

        $action = $request->attributes->get('_action');
        if (!$action) {
            throw new \InvalidArgumentException('Action method is not valid.');
        }

        $request->attributes->remove('_controller');
        $request->attributes->remove('_action');
        $parameters = $request->attributes->get('_parameters', []);
        if (!empty($parameters)) {
            $request->attributes->remove('_parameters');
        }

        $filterController = new FilterController($controller);
        $this->eventDispatcher->dispatch(KernelEvents::FILTER_CONTROLLER, $filterController);

        try {
            $response = call_user_func_array([$controller, $action], array_merge($parameters, [$request]));
        } catch (ResourceNotFoundException $e) {
            $response = new Response('Not found!', Response::HTTP_NOT_FOUND);
        }

        if ($response instanceof Response) {
            $filterResponse->setResponse($response);
            $this->eventDispatcher->dispatch(KernelEvents::FILTER_RESPONSE, $filterResponse);

            return $filterResponse->getResponse();
        }

        throw new \InvalidArgumentException(sprintf('The controller must return a "\Symfony\Component\HttpFoundation\Response" object'));
    }
851959
public function handle(Request $request, $type = self::MASTER_REQUEST)
    {
        try {
            $response = $this->handleRequest($request, $type);
        } catch (\Exception $e) {
            $response = $this->handleException($e, $request, $type);
        }

        return $response;
    }
883881
public function handle(Request $request)
    {
        if (!$this->booted) {
            $this->bootstrap();
        }

        $this->request = $request;
        $response = new Response();
        return($response);
    }
284401
private function handleObject($object, $type=null) {
        if (is_object($object)) {
          if (!($object instanceof BaMLAttribute || $object instanceof BaMLText || $object instanceof BaMLVerb)) {
            throw new \CatapultApiException("Not a valid object in BaML schema. Must be either BaMLAttribute, BaMLVerb or BaMLVerb");
          }
          if (!isset($this->currentVerb)) {
            $this->setCurrentVerb($object);
          }
          if (!isset($this->currentText)) {
            $this->setCurrentText($object);
          }
           
          $this->addData($object);
        } else {
            /** for this initialization we need type to be set **/
          $this->addData($object); 
        }
    }
846472
public function handle($request)
    {
        $this->loadAuthManager();
        
        try {
            $response = $this->sendRequestThroughRouter($request);
            $response = $response->getContent();
            
            $json = json_decode($response, true);
            if (json_last_error() == JSON_ERROR_NONE) {
                $response = $json;
            }
        } catch (Exception $e) {
            if ($e instanceof NotFoundHttpException) {
                $response = $e;
            } else {
                throw $e;
            }
        }
        
        $this->app['events']->fire('wskernel.handled', [$request, $response]);
        
        return $response;
    }
1104085
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $this->request = $request;
        $response = (new HttpFactory())->createResponse();
        $response = $response->withHeader('Content-Type', 'text/html');
        $pathInfo = RequestHelper::getPathInfo($request);

        try {
            $controller = $this->resolveController($pathInfo);
            $mixed = $this->executeAction($controller);
        } catch (\Throwable $t) {
            // handle errors with built-in error controller
            $controller = new ErrorController($this->view, $request, 'error/error');
            $controller->setError($t);
            $mixed = $this->executeAction($controller);
            $response = $response->withStatus($t->getCode());
        }

        if (is_array($mixed)) {
            $response = $response->withHeader('Content-Type', 'application/json');
            $response->getBody()->write(json_encode($mixed));
        } elseif (is_string($mixed)) {
            $response->getBody()->write($mixed);
        } else {
            throw new \Exception('Unsupported content type');
        }

        return $response;
    }
486496
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
	{
		$this->checkRequestForArraySessions($request);

		// If a session driver has been configured, we will need to start the session here
		// so that the data is ready for an application. Note that the FlyPHP sessions
		// do not make use of PHP "native" sessions in any way since they are crappy.
		if ($this->sessionConfigured())
		{
			$session = $this->startSession($request);

			$request->setSession($session);
		}

		$response = $this->app->handle($request, $type, $catch);

		// Again, if the session has been configured we will need to close out the session
		// so that the attributes may be persisted to some storage medium. We will also
		// add the session identifier cookie to the application response headers now.
		if ($this->sessionConfigured())
		{
			$this->closeSession($session);

			$this->addCookieToResponse($response, $session);
		}

		return $response;
	}
856773
public function handleException(ServerRequestInterface $request, ResponseInterface $response, Exception $exception)
    {
        if ($level = $this->shouldLog('error')) {
            $this->logError($exception, $level);
        }

        return $this->handler->handleException($request, $response, $exception);
    }
348731
public function handle($request, Closure $next, $type)
    {
        if (!$this->typeResolver->hasType($this->tenant->getTenantCreator(), $type)) {
            return redirect()->route('tenant.tenant_type_not_supported', ['type' => $type]);
        }

        return $next($request);
    }
224721
public function addFromRequest(Type $type, Request $request)
    {
        $key = parent::addFromRequest($type, $request);

        return $this->saveFromRequest($key, $request);
    }
287565
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
    {
        $templateEngine = $this->container['internal.template'];
        if ($templateEngine instanceof \Twig_Environment) {
            $templateEngine->addExtension(new TwigFilterExtension());
        }

        return $this->app->handle($request, $type, $catch);
    }
598496
public function setRequest(string $type, $request)
    {
        $this->request = new Request($type, $request);
        $this->initialized['request'] = true;

        return $this;
    }
1286806
public function handle(Request $request) : Response
	{
		if ($result = $this->handleContext($request, $this->rootContext)) {
			return $result;
		}
		
		if ($defaultHandler = $this->rootContext->getDefault()) {
			return $this->resultToResponse(
				call_user_func($defaultHandler, $request, null)
			);
		}
		
		throw new Exception('No matching route found. Set a default handler on root context to cover this case.');
	}