Dispatch the request for this operation and process the response. Allows you to
modify the request before it is sent.

@return \GithubService\Model\SearchRepos
@param \Amp\Artax\Request $request The request to be processed
548256
public function dispatch(\Amp\Artax\Request $request) {
        $response = $this->api->execute($request, $this);
        $this->response = $response;
        $instance = $this->api->instantiateResult($response, $this);

        return $instance;
    }
1331649
public function dispatch(\sb\JSON\RPC2\Request $request)
    {

        if (!(is_array($request->params) || is_object($request->params))) {
            $response = new \sb\JSON\RPC2\Response();
            $response->error = new \sb\JSON\RPC2\Error('-32602');
            $response->message = 'Invalid params';
            $response->error->data = 'Invalid method parameters: ' . json_encode($request->params);
            return $response;
        }

        $host = $this->host;
        $port = $this->port;
        $timeout = $this->timeout;
        $request_timeout = $this->request_timeout;
        $uri = $this->uri;

        $json = json_encode($request);

        $this->logRequest($json);

        if ($this->debug == true) {
            echo "--> " . $json;
        }

        $headers = [];
        
        if ($this->php_serialize_response) {
            $headers[] = "php-serialize-response:".($this->php_serialize_response ? 1 : 0);
        }

        //if there are cookies add them
        if (!empty($this->cookies)) {
            $cookies = '';
            foreach ($this->cookies as $key => $val) {
                $cookies .= $key . '=' . urlencode($val) . ';';
            }

            $headers[] = "Cookie: " . $cookies;
        }

        $response_str = '';

        $ch = curl_init();
        if($headers){
            curl_setopt($ch,CURLOPT_HTTPHEADER, $headers); 
        }
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $this->verify_ssl ? 2 : false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->verify_ssl ? 2 : false);
        curl_setopt($ch, CURLOPT_USERAGENT, $this->agent ? $this->agent : \sb\Gateway::$http_host.' '.'\sb\JSON\RPC2\Client ');
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 
        curl_setopt($ch, CURLOPT_TIMEOUT, $request_timeout); 
        curl_setopt($ch, CURLOPT_PORT, $port);
        
        $url = 'http'.($this->port == 443 ? 's' : '').'://'.$this->host.$uri;
        if($this->method == 'post'){
            if (isset($this->encryption_key)) {
                $json = $this->encryptor->encrypt($json);
            }
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
        } else {
            
            $params = base64_encode(json_encode($request->params));
            $params = urlencode($params);

            $url .= (strstr($this->uri, '?') ? '&' : '?')
                . 'method=' . $request->method . '&params='
                . $params . '&id=' . $request->id;
    
        }
        
        curl_setopt ($ch, CURLOPT_URL, $url);  
       
        $response_str = curl_exec($ch);
        $error = curl_errno($ch);
        if($error){
            $response = new \sb\JSON\RPC2\Response();
            $response->error = new \sb\JSON\RPC2\Error('-32099');
            $response->error->message = 'Server error';
            $response->error->data = 'Could not reach: ' . $this->host . ": #$error - ". curl_error($ch);
            return $response;
        }
        
        return $this->processResponse($response_str);
    }
71225
private function _dispatchRequest($request)
	{
		// track the number of requests across instances
		self::$requestCount++;
		$timestart = microtime(true);

		$response = self::transport()->send($request);

		// pass the response through the filter chain
		foreach($this->_filters as $filter)
		{
			$response = $filter->response($response);
		}

		$httpCode = $response->getStatus()->getCode();
		$location = $response->getHeaders()->value('Location');
		$body = $response->getBody();

		// track the time taken across instances
		self::$requestTime += microtime(true) - $timestart;

		// process a redirect if needed
		if($httpCode < 400 && $location)
		{
			return $this->_redirect($location);
		}
		else
		{
			$this->_redirects = 0;
		}

		// translate error code to a typed exception
		if($httpCode == 500)
		{
			throw new Error\InternalServerError($body);
		}
		elseif($httpCode == 400)
		{
			throw new Error\BadRequest($body);
		}
		elseif($httpCode == 401)
		{
			throw new Error\Unauthorized($body);
		}
		elseif($httpCode == 404)
		{
			throw new Error\NotFound($body);
		}
		else if($httpCode >= 300)
		{
			throw new Error($body,$httpCode);
		}

		return $response;
	}
812287
public function dispatch(Request $request)
    {
        $url = $request->getQueryString();
        $url = $this->RemoveQueryString($url, new Request());
        if ($this->match($url)) {
            (isset($this->params['middleware'])) ? $this->params['middleware'] = new $this->params['middleware']() : null;
            if (!isset($this->params['callable'])) {
                $controller = $this->params['controller'];
                $controller = $this->convertToStudlyCaps($controller);
                $controller = $this->getNamespace().$controller;
                if (class_exists($controller)) {
                    (isset($this->params['middleware']) && is_object($this->params['middleware'])) ? ( new $this->params['middleware']())->before(new Request(), new Response(), $this->params) : null;
                    $controller_object = new $controller($this->params, $this->getInput(new Input()));
                    $action = $this->params['action'];
                    $action = $this->convertToCamelCase($action);
                    if (preg_match('/action$/i', $action) == 0) {
                        $controller_object->$action();
                        (isset($this->params['middleware']) && is_object($this->params['middleware'])) ? (new $this->params['middleware']())->after(new Request(), new Response(), $this->params) : null;
                    } else {
                        throw new \Exception("Method $action in controller $controller cannot be called directly - remove the Action suffix to call this method");
                    }
                } else {
                    throw new \Exception("Controller class $controller not found");
                }
            } else {
                (is_object(isset($this->params['middleware']))) ? $this->params['middleware']->before(new Request(), new Response(), $this->params) : null;
                call_user_func($this->params['callable'], $this->params);
                (is_object(isset($this->params['middleware']))) ? $this->params['middleware']->after(new Request(), new Response(), $this->params) : null;
            }
        } else {
            \Zest\Component\Router::loadComponents();
        }
    }
346550
public function moveAction(Request $request)
    {
        $admin = $this->getAdmin();

        $admin->checkAccess('edit');

        if ($admin->isChild()) {
            $id = $request->query->get('childId');
        } else {
            $id = $request->query->get('id');
        }

        $targetId = $request->query->get('target');
        $dropPosition = $request->query->get('position');

        $em = $this->getDoctrine()->getManager();

        /** @var NestedTreeRepository $repo */
        $repo = $em->getRepository($admin->getClass());

        $currentNode = $repo->find($id);
        $targetNode = $repo->find($targetId);

        switch ($dropPosition) {
            case 'before':
                $currentNode->setParent($targetNode->getParent());

                if ($targetNode->getPosition()) {
                    $currentNode->setPosition($targetNode->getPosition() - 1);
                } else {
                    $currentNode->setPosition(0);
                }
                break;
            case 'after':
                $currentNode->setParent($targetNode->getParent());
                $currentNode->setPosition($targetNode->getPosition() + 1);
                break;
            case 'append':
                $currentNode->setParent($targetNode);
                $currentNode->setPosition(-1);
                break;
        }

        $admin->update($currentNode);
        $admin->update($targetNode);

        return $this->renderJson(['result' => true]);
    }
178305
protected function doRequest($request)
    {
        if (!$this->firstRequest) {
            $this->initialize($request);
        }
        $this->firstRequest = false;

        $this->applyBindings();
        $this->applyContextualBindings();
        $this->applyInstances();
        $this->applyApplicationHandlers();

        $request = Request::createFromBase($request);
        $response = $this->kernel->handle($request);
        $this->app->make('Illuminate\Contracts\Http\Kernel')->terminate($request, $response);

        return $response;
    }
576404
public function dispatch(Request $request)
	{
		if ($this->isDownForMaintenance())
		{
			$response = $this['events']->until('flyphp.app.down');

			if ( ! is_null($response)) return $this->prepareResponse($response, $request);
		}

		if ($this->runningUnitTests() && ! $this['session']->isStarted())
		{
			$this['session']->start();
		}

		return $this['router']->dispatch($this->prepareRequest($request));
	}
1315162
public function indexAction( Request $request )
	{
		if( Auth::check() === false
			|| $request->user()->can( 'admin', [AdminController::class, ['admin', 'editor']] ) === false
		) {
			return redirect()->guest( 'login' );
		}

		$siteId = $request->user()->siteid;
		$context = app( 'aimeos.context' )->get( false );
		$siteManager = \Aimeos\MShop::create( $context, 'locale/site' );
		$siteCode = ( $siteId ? $siteManager->getItem( $siteId )->getCode() : 'default' );
		$locale = $request->user()->langid ?: config( 'app.locale', 'en' );

		$param = array(
			'resource' => 'dashboard',
			'site' => Route::input( 'site', Input::get( 'site', $siteCode ) ),
			'lang' => Route::input( 'lang', Input::get( 'lang', $locale ) )
		);

		return redirect()->route( 'aimeos_shop_jqadm_search', $param );
	}
1182157
public function search(SearchRequest $request)
    {
        $this->eventDispatcher->dispatch(ONGRFilterManagerEvents::PRE_SEARCH, new PreSearchEvent($request));

        $search = $this->container->buildSearch($request);

        /** @var FilterInterface $filter */
        foreach ($this->container->all() as $name => $filter) {
            $relatedSearch = new Search();

            if ($filter->isRelated()) {
                // We simply exclude not related filters and current filter itself.
                $relatedFilters = $this->container->getFiltersByRelation(
                    new AndRelation([$filter->getSearchRelation(), new ExcludeRelation([$name])])
                );
                $relatedSearch = $this->container->buildSearch($request, $relatedFilters);
            }

            $this->eventDispatcher->dispatch(
                ONGRFilterManagerEvents::PRE_PROCESS_SEARCH,
                new PreProcessSearchEvent($request->get($name), $relatedSearch)
            );

            $filter->preProcessSearch(
                $search,
                $relatedSearch,
                $request->get($name)
            );
        }

        $result = $this->repository->findDocuments($search);
        $this->eventDispatcher->dispatch(ONGRFilterManagerEvents::SEARCH_RESPONSE, new SearchResponseEvent($result));

        return new SearchResponse(
            $this->getFiltersViewData($result, $request),
            $result,
            $this->composeUrlParameters($request),
            $this->serializer
        );
    }
1181851
public function indexAction(Request $request)
    {
        /** @var HttpErrorRepository $errorRepository */
        $errorRepository = $this->getDoctrine()->getManager()->getRepository('VictoireSeoBundle:HttpError');

        // Fetch errors

        $routes = $errorRepository->getRouteErrors();
        $routesResults = $routes->getQuery()->getResult();

        $files = $errorRepository->getFileErrors();
        $filesResults = $files->getQuery()->getResult();

        // Build forms

        $forms = [];
        $errors = array_merge($routesResults, $filesResults);

        /** @var Error404 $error */
        foreach ($errors as $error) {
            $redirection = new ErrorRedirection();
            $redirection->setError($error);
            $forms[$error->getId()] = $this->getError404RedirectionForm($redirection)->createView();
        }

        // Return datas

        return new Response($this->renderView('@VictoireSeo/Error404/index.html.twig', [
            'routes' => $routesResults,
            'files'  => $filesResults,
            'forms'  => $forms,
        ]));
    }
586799
public function searchAction(Request $request)
    {
        $acl = $this->get('bacon_acl.service.authorization');

        if (!$acl->authorize('module-actions', 'INDEX')) {
            throw $this->createAccessDeniedException();
        }

        $this->get('session')->remove('moduleactions_search_session');

        if ($request->getMethod() === Request::METHOD_POST) {
            $entityName     =   $this->getParameter('bacon_acl.entities.module_actions');
            $formTypeName   =   $this->getParameter('bacon_acl.forms.module_actions_form_type_class');

            $form = $this->createForm($formTypeName, new $entityName(), [
                'search' => true,
            ]);

            $form->handleRequest($request);

            $this->get('session')->set('moduleactions_search_session', serialize($form->getData()));
        }

        return $this->redirect($this->generateUrl('module_actions'));
    }
430583
public function handle($request)
    {
        $entity = $this->repository()->findById($request->getId());
        $this->authorize($request, $entity);

        $item = $this->getProperty($entity, $this->field());
        $this->related()->getEntityManager()->remove($item);
        $this->setProperty($entity, $this->field(), null);

        $this->repository()->getEntityManager()->flush();

        return $this->response()->noContent();
    }
1341979
protected function handle($request)
    {
        $this->authorize($request, $this->repository()->getClassName());

        $qb = $this->repository()->sourceQueryBuilder($request);
        $this->applyPagination($request, $qb);
        $this->applyFilter($request, $qb);

        return $this->response()->resource($request, $this->prepareCollection($request, $qb));
    }
291419
private function processRequest($request)
    {
        if (!is_array($request)) {
            return self::requestError();
        }

        // The presence of the 'id' key indicates that a response is expected
        $isQuery = array_key_exists('id', $request);

        $id = &$request['id'];

        if (($id !== null) && !is_int($id) && !is_float($id) && !is_string($id)) {
            return self::requestError();
        }

        $version = &$request['jsonrpc'];

        if ($version !== self::VERSION) {
            return self::requestError($id);
        }

        $method = &$request['method'];

        if (!is_string($method)) {
            return self::requestError($id);
        }

        // The 'params' key is optional, but must be non-null when provided
        if (array_key_exists('params', $request)) {
            $arguments = $request['params'];

            if (!is_array($arguments)) {
                return self::requestError($id);
            }
        } else {
            $arguments = array();
        }

        if ($isQuery) {
            return $this->processQuery($id, $method, $arguments);
        }

        $this->processNotification($method, $arguments);
        return null;
    }
917542
public function dispatch(Request $request)
    {
        $this->currentRoute = null;

        $this->container->instance(Request::class, $request);

        $this->routesDispatched++;

        try {
            $response = $this->adapter->dispatch($request, $request->version());
        } catch (Exception $exception) {
            if ($request instanceof InternalRequest) {
                throw $exception;
            }

            $this->exception->report($exception);

            $response = $this->exception->handle($exception);
        }

        return $this->prepareResponse($response, $request, $request->format());
    }
51642
public function handleRequest(SymfonyRequest $request)
    {
        $stack = $this->stack;
        if ($stack instanceof MiddlewareStack) {
            $stack = $stack->withDispatcher($this->app->make(DispatcherDelegate::class, [$this->dispatcher]));
        }

        return $stack->process($request);
    }
329553
public function dispatch(Request $request)
    {
        $this->logger->debug('Dispatching request');
        try {
            /**
             * @var \Shade\Router\RouterInterface $router
             */
            $router = $this->serviceContainer->getService(ServiceContainer::SERVICE_ROUTER);
            $route = $router->route($request);
            if (!isset($this->primaryRequest)) {
                $this->primaryRequest = $request;
                $logMessage = 'Route found for primary request';
            } else {
                $logMessage = 'Route found for secondary request';
            }
            if (!isset($this->primaryRoute)) {
                $this->primaryRoute = $route;
            }
        } catch (Exception $e) {
            $this->logger->debug('Route not found');
            $response = new Response();
            $response->setCode(404);

            return $response;
        }

        $this->validateRoute($route);
        $this->logger->debug(
            $logMessage,
            [
                'controller' => $route->controller(),
                'action' => $route->action(),
                'args' => $route->args(),
            ]
        );
        $controllerClass = $route->controller();
        $actionName = $route->action();
        $actionArguments = $this->getMethodArguments($controllerClass, $actionName);

        if (method_exists($controllerClass, '__construct')) {
            $constructorArguments = $this->getMethodArguments($controllerClass, '__construct');
        }

        if (empty($constructorArguments)) {
            $controller = new $controllerClass();
        } else {
            $controllerReflection = new \ReflectionClass($controllerClass);
            $controller = $controllerReflection->newInstanceArgs($constructorArguments);
        }

        if (!($controller instanceof Controller)) {
            throw new Exception(
                "'{$controllerClass}' must inherit '\\Shade\\Controller'."
            );
        }

        /**
         * @var \Shade\Controller $controller
         */
        $controller->setControllerDispatcher($this);
        $controller->setView($this->serviceContainer->getService(ServiceContainer::SERVICE_VIEW));
        $controller->setCurrentRequest($request);
        $controller->setCurrentRoute($route);
        $controller->setPrimaryRequest($request);
        $controller->setPrimaryRoute($route);

        /**
         * @var Response $response
         */
        $response = call_user_func_array([$controller, $actionName], $actionArguments);
        if (!$response instanceof Response) {
            throw new Exception(
                "Executed controller hasn't returned instance of \\Shade\\Response. "
                .ucfirst(gettype($response)).' has been returned.'
            );
        }

        if (!$response->getCode()) {
            $response->setCode(200);
        }

        return $response;
    }