@throws NotFoundHttpException

@return Response
481486
public function retrieveFormFieldElementAction(Request $request)
    {
        $action = new RetrieveFormFieldElementAction($this->twig, $this->pool, $this->helper);

        return $action($request);
    }
365031
public static function getRequestRoute()
    {
        $route = \Yii::$app->getRequest()->resolve();
        if (isset($route[0]) && !empty($route[0]))
            return $route[0];
        else
            throw new NotFoundHttpException(\Yii::t('yii', 'Page not found.'));
    }
1371725
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $user_id = (int) $request->getParsedBody()['user_id'];

        $user = $this->user_service->find($user_id);

        if ($user === null) {
            throw new NotFoundHttpException('User ID ' . $user_id . ' not found');
        }

        if (Auth::isAdmin($user)) {
            throw new AccessDeniedHttpException('Cannot delete an administrator');
        }

        Log::addAuthenticationLog('Deleted user: ' . $user->userName());
        $this->user_service->delete($user);

        return response('', StatusCodeInterface::STATUS_NO_CONTENT);
    }
204393
public function handle(Request $request)
    {
        $path = trim($request->getRequestUri(), '/');
        $entity = $this->getResolver()->resolve($path);

        if (is_null($entity)) {
            throw new NotFoundHttpException;
        }

        return $this->renderEntity($request, $entity);
    }
1152092
public function apiAction(Request $request)
    {
        if ($request->isXmlHttpRequest() or $request->headers->get('Content-Type') =='application/json') {
            $pathInfo = $request->getPathInfo();
            if(!$this->getApiRequestAllow()->isAllow($pathInfo)){
                throw new NotFoundHttpException('No route allow for " '.$request->getMethod().' '.$pathInfo.'"');
            }
            $query_string = null;
            if ($request->server->get('QUERY_STRING')){
                $query_string = '?' .$request->server->get('QUERY_STRING');
            }

            $url_api = $pathInfo . $query_string;

            /*
             * Only is configurable the first folder
             * internalapi/users/username-available
             * is changed to api/users/username-available
             */
            $array = explode("/", $url_api);
            unset($array[1]);
            $text = implode("/", $array);

            $url_api = "/api".$text;

            $apiUri = trim($url_api,'/');
            try{
                return $this->container->get('antwebes_chateaclient_bundle.http.api_client')->sendRequest('GET',$apiUri);
            }catch (ClientErrorResponseException $e){
                $headersGuzzle = $e->getResponse()->getHeaders()->toArray();
                $headersSymfony = array();
                foreach($headersGuzzle as $key=>$value){
//this header is not suporter in symfony
                    if($key != 'Transfer-Encoding' && $value !== 'chunked'){
                        $headersSymfony[$key] = $value[0];
                    }
                }
                return new Response($e->getResponse()->getBody(true),
                    $e->getResponse()->getStatusCode(),
                    $headersSymfony
                );
            }
        }else{
            throw new NotFoundHttpException();
        }
    }
653743
public function handler(): Response
    {
        $bulletin = Bulletin::find($this->getParameter('id'));
        if (!$bulletin) {
            throw new HttpNotFoundException();
        }
        if (!$bulletin->isDraft()) {
            throw new HttpForbiddenException();
        }
        $data = $this->validate([
            'title' => [
                new NotBlank()
            ],
            'content' => [
                new NotBlank()
            ],
            'receivers' => []
        ]);
        $bulletin->update($data);
        $this->log('info', 'Update bulletin [' . $bulletin->getId() . ']');
        return response();
    }
774064
public function handler(): Response
    {
        $data = $this->validate([
            'username' => [
                new NotBlank()
            ],
            'email' => [
                new NotBlank(),
                new Email()
            ],
            'name' => [
                new NotBlank()
            ],
            'gender' => [
                new NotBlank()
            ],
            'role' => [
                new NotBlank()
            ]
        ]);
        $data['role'] = Role::findBy(['slug' => $data['role']]);
        if (!$data['role']) {
            throw new HttpForbiddenException();
        }
        $member = new Member($data);
        $member->save();
        if ($this->request->get('activate', false) === true) {
            app()->dispatch(new WelcomeMessageNeedsToBeSent($member));
        }
        $this->log('info', 'Create a member [' . $member->getUsername() . ']');
        return response();
    }
1148396
public function response(ServerRequestInterface $request, ResponseInterface $response)
    {
        // Throw Not Found
        //$this->response->exception(404);

        // Demo contents
        $contents = 'It works!';

        // PSR-7 JSON response
        return $this->response->dispatch($response, 200, $contents); // 202
    }
263402
public function errorAction()
    {
        try {
            $order = $this->getPaymentHandler()->handleError($this->getCurrentRequest(), $this->getBasket());
        } catch (EntityNotFoundException $ex) {
            throw new NotFoundHttpException($ex->getMessage());
        } catch (InvalidTransactionException $ex) {
            throw new UnauthorizedHttpException($ex->getMessage());
        }

        return $this->render('SonataPaymentBundle:Payment:error.html.twig', [
            'order' => $order,
        ]);
    }
260611
protected function _run()
    {
//        $class = $this->modelClass;
//        $class::initNavigationPagesById($this->actionParams->get['id']);
        $pageId = \yii::$app->request->getQueryParam('id');
        if ($pageId) {
            $pages = FrontendPage::getNavigationPages($pageId);
            if (empty($pages)) {
                throw new NotFoundHttpException();
            }
        }

        return $this->getResponse([
            'content' => [],
        ]);
    }
58254
public function getResponse(): ResponseInterface
    {
        if (is_null($this->response)) {
            if (method_exists($this, 'resolve')) {
                $this->setResponse($this->resolve(Response::class)->load());
            } else {
                $response = new Response();
                $this->setResponse($response->load());
            }
        }

        return $this->response;
    }
1089008
public function updateAction(Request $request, Response $response, array $args)
    {
        $form = $this->createUpdateForm();
        $form->setAttribute('action', sprintf('%s/%s', $this->route, $args['id']));

        $entity = $this->em->getRepository($this->entityClass)->find($args['id']);

        if (!$entity) {
            throw new NotFoundException;
        }

        $data = $this->loadData($entity);

        $form->populate($data);

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

        return $response;
    }
985765
public function evaluatePage() {
    if ($this->webPage == null) {
      throw new HttpNotFound();
    }

    $requestMethod = Server::getRequestMethod();
    $reflectionObject = new \ReflectionObject($this->webPage);

    if (!$reflectionObject->hasMethod($requestMethod)) {
      throw new HttpMethodNotAllowed();
    }

    $this->evaluatePermissions();

    // initialize the page
    $initializeParameters = $this->getParametersForMethod($reflectionObject->getMethod(self::INITIALIZE_FUNCTION));
    call_user_func_array([$this->webPage, self::INITIALIZE_FUNCTION], $initializeParameters);

    $renderParameters = $this->getParametersForMethod($reflectionObject->getMethod(self::FALLBACK_FUNCTION));
    try {
      $result = call_user_func_array([$this->webPage, self::FALLBACK_FUNCTION], $renderParameters);
      if (!($result instanceof Response)) {
        throw new HttpInternalServerError("The result of initialize has to be of type 'Response'");
      }
      return $result;
    } catch (HttpMethodNotAllowed $exc) {
      // empty on purpose (try render first, if its not overridden, fall through)
    }

    $requestMethodParameters = $this->getParametersForMethod($reflectionObject->getMethod($requestMethod));
    $result = call_user_func_array([$this->webPage, $requestMethod], $requestMethodParameters);
    if (!($result instanceof Response)) {
      throw new HttpInternalServerError("The result of $requestMethod has to be of type 'Response'");
    }
    return $result;
  }
999324
public function callbackAction()
    {
        try {
            $response = $this->getPaymentHandler()->getPaymentCallbackResponse($this->getCurrentRequest());
        } catch (EntityNotFoundException $ex) {
            throw new NotFoundHttpException($ex->getMessage());
        } catch (InvalidTransactionException $ex) {
            throw new UnauthorizedHttpException($ex->getMessage());
        }

        return $response;
    }
650357
public function getResponse()
    {
        if (null === $this->response) {
            @trigger_error(sprintf('Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.', \get_class($this).'::'.__FUNCTION__), E_USER_DEPRECATED);
            // throw new BadMethodCallException(sprintf('The "request()" method must be called before "%s()".', __METHOD__));
        }

        return $this->response;
    }
1103657
public function edit(ServerRequestInterface $request): ResponseInterface
    {
        $user_id = (int) $request->getQueryParams()['user_id'];
        $user    = $this->user_service->find($user_id);

        if ($user === null) {
            throw new NotFoundHttpException(I18N::translate('%1$s does not exist.', 'user_id:' . $user_id));
        }

        return $this->viewResponse('admin/users-edit', [
            'contact_methods' => FunctionsEdit::optionsContactMethods(),
            'default_locale'  => WT_LOCALE,
            'locales'         => I18N::installedLocales(),
            'roles'           => $this->roles(),
            'trees'           => Tree::getAll(),
            'theme_options'   => $this->themeOptions(),
            'title'           => I18N::translate('Edit the user'),
            'user'            => $user,
        ]);
    }
105414
public function indexAction()
    {
        $sitemapindex = $this->getGenerator()->fetch('root');

        if (!$sitemapindex) {
            throw $this->createNotFoundException();
        }

        $response = Response::create($sitemapindex->toXml());
        $response->setPublic();
        $response->setClientTtl($this->getTtl());

        return $response;
    }