@param Request  $request
@param Response $response
@param array    $args

@return Response
977850
public function createAction(Request $request, Response $response, array $args)
    {
        $form = $this->createCreateForm();

        if ($request->attributes->get('repopulate', false)) {
            $form->populate($request->request->all());
        }

        $response->setContent($this->twig->render($this->views['create'], [
            'form' => $form,
        ]));

        return $response;
    }
441420
public function runBefore(Request $request, Response $response)
    {
        foreach ($this->middlewares as $middleware) {
            if (class_exists($middleware)) {
                $instance = new $middleware($request, $response);
                if ($instance instanceof MiddlewareAbstract) {
                    /* @var $instance MiddlewareAbstract */
                    $instance->onBefore();
                    $this->running[] = $instance;
                }
            }
        }
    }
612377
public function read(Request $request, Response $response, array $args)
    {
        $entity = $this->em->getRepository($this->entityClass)->find($args['id']);

        if ($entity) {
            $response->setContent($this->twig->render($this->views['read'], [
                'entity' => $entity,
            ]));

            return $response;
        }

        throw new NotFoundException;
    }
405525
public function checkRedirect(
        RequestInterface $request,
        array $options,
        ResponseInterface $response
    ) {
        if (substr($response->getStatusCode(), 0, 1) != '3'
            || !$response->hasHeader('Location')
        ) {
            return $response;
        }

        $this->guardMax($request, $options);
        $nextRequest = $this->modifyRequest($request, $options, $response);

        if (isset($options['allow_redirects']['on_redirect'])) {
            call_user_func(
                $options['allow_redirects']['on_redirect'],
                $request,
                $response,
                $nextRequest->getUri()
            );
        }

        /** @var PromiseInterface|ResponseInterface $promise */
        $promise = $this($nextRequest, $options);

        // Add headers to be able to track history of redirects.
        if (!empty($options['allow_redirects']['track_redirects'])) {
            return $this->withTracking(
                $promise,
                (string) $nextRequest->getUri(),
                $response->getStatusCode()
            );
        }

        return $promise;
    }
859019
public function delete(Request $request, Response $response, array $args)
    {
        $entity = $this->em->getRepository($this->entityClass)->find($args['id']);

        if ($entity) {
            $this->em->remove($entity);
            $this->em->flush();
        }

        return new RedirectResponse($this->route);
    }
949866
private function handleUnauthenticatedResponse(RequestInterface $request, ResponseInterface $response, array $options)
    {
        if (!$this->isUnauthenticatedResponse($response)) {
            return null;
        }

        $handler = $this->handler;
        $newRequest = $this->reauthenticate($request);

        return $handler($newRequest, $options);
    }
469071
public function run(Request $request, Response $response) : Response {

		$strict = $this->getParam('STRICT_ROUTING');
		$case = $this->getParam('CASE_SENSITIVE');
		$method = $request->getMethod();
		$url = $request->getUri()->getPath();

		//Matching
		foreach($this->routes as $route) {
			if($route->match($url, $strict, $case) && $method == $route->getMethod()) {
				return $route->call($request, $response);
			} elseif($route->match($url, $strict, $case) && $method == 'HEAD') {
				$body = $response->getBody();
				$body->close();
				$response = $response->withBody($body);
				return $response;
			}
		}

		//Error
		$methods = array();
		foreach($this->routes as $route) {
			array_push($methods, $route->getMethod());
			if($route->match($url, $strict, $case) && $method != $route->getMethod() && in_array($method, self::$_METHODS))
				return call_user_func($this->httpErrors['405'], $request, $response);

			elseif($route->match($url, $strict, $case) && $method != $route->getMethod() && !in_array($method, self::$_METHODS))
				return call_user_func($this->httpErrors['400'], $request, $response);
		}

		if(!in_array($method, $methods) && !in_array($method, self::$_METHODS))
			return call_user_func($this->httpErrors['400'], $request, $response);
		else
			return call_user_func($this->httpErrors['404'], $request, $response);
		
	}
829671
public function callGetResources(Request $request, Response $response, array $args)
    {
        $resourceNamePlural = $args['resourceNamePlural'];
        $inflector          = $this->get(ServiceProvider::INFLECTOR);
        $methodName         = 'get'.$inflector->camelize($resourceNamePlural);

        return $this->callMethod($resourceNamePlural, $methodName, [$request, $response]);
    }
1008842
private function getArgs(array $args, $cmd, $response, $driverId)
    {
        $response = array($response);
        $allowedArgs = $this->commands[$cmd];
        unset($allowedArgs['interface']);
        foreach ($allowedArgs as $key => $value) {
            if (isset($args[$key])) {
                $response[$key] = $args[$key];
                if (isset($this->filenameInRequest[$key])) {
                    $response[$key] = self::getNameByTarget($args[$key], $driverId);
                } elseif ($key == 'targets') {
                    $response[$key] = array_map(
                        function ($val) use ($driverId) {
                            return self::getNameByTarget($val, $driverId);
                        },
                        $args[$key]
                    );
                }
            } elseif (isset($this->defaultValues[$key])) {
                $response[$key] = $this->defaultValues[$key];
            } elseif ($value) {
                $this->error(sprintf('parameter "%s" in cmd "%s" required', $key, $cmd));
            }
        }

        return $response;
    }
314343
public function execute(Request $request, Response $response, ...$params)
    {
        if (is_string($this->_params[0])) {
            $response->write(...$this->_params);
        } elseif (is_callable($this->_params[0])) {
            $this->_params[0]($request, $response);
        } else {
            throw new \DomainException('INVALID_ROUTER_FUNC');
        }
    }
1374033
public function run(Request $request, Response $response)
    {
        $this->initController($request, $response);
        $event = $this->eventDispatcher->raiseEvent(
            $this->createLoadedEvent()
        );

        if ($event->isHandled() && $event->getResponse() instanceof Response) {
            return $event->getResponse();
        }

        $this->eventDispatcher->raiseEvent(
            $this->createFinishedEvent(
                $this->runController($request, $response)
            )
        );

        return $response;
    }
168076
public function post($resource, array $args = [], array $options = [])
    {
        $response = $this->client->post($resource, $args, $options);
        if (!$response->success()) {
            $this->throwError("MailjetService:post() failed", $response);
        }
        return $response;
    }
819341
public function modifyResponse(Request $request, Response $response)
    {
        $app = $this->app;

        if (is_admin_panel() || $app->runningInConsole() || $this->isDebugbarRequest() || $request->ajax()) {
            return $response;
        }

        $this->injectAdminBar($response);

        return $response;
    }
878231
public static function make(Request $request, Response $response)
    {
        if (is_null(static::$instance)) {
            static::$instance = new static($request, $response);
        }

        return static::$instance;
    }
492383
protected function request(array $args, $key, $action)
    {
        $client = $this->getHttpClient();

        $response = $client->post('/v2/index.php', [
            'form_params' => $this->buildFormParams($args, $key, $action),
        ]);

        $contents = $response->getBody()->getContents();

        return $this->normalize($contents);
    }
533259
public function parseArguments(array $args)
    {
        $this->action = null;
        $this->arguments = array();
        $parsed = array();
        $argument = reset($args);
        while ($argument) {
            if (strpos($argument, '=') > 0) {
                $arg = explode('=', $argument);
                $argKey = ltrim($arg[0], '-');
                $argValue = trim($arg[1], '"');
                $parsed[$argKey] = $argValue;
            } else {
                $parsed[ltrim($argument, '-')] = true;
            }
            $argument = next($args);
        }
        if (!isset($parsed['action']) || empty($parsed['action'])) {
            if (isset($parsed['version']) ||  isset($parsed['V'])) {
                $this->action = 'Version';
                $this->arguments = $parsed;
                return $this->arguments;
            }
            if (isset($parsed['help']) || isset($parsed['h'])) {
                $this->action = 'Help';
                $this->arguments = $parsed;
                return $this->arguments;
            }
            throw new RequestException($this, "No valid action argument specified.");
        }
        $this->action = $parsed['action'];
        unset($parsed['action']);
        $this->arguments = $parsed;
        return $this->arguments;
    }
468866
function process_response($request, $response)
    {
        if (! $request->user->isAnonymous()) {
            $request->session->setData($this->session_key, $request->user->id);
        }
        return $response;
    }