当前位置: 首页>>代码示例>>PHP>>正文


PHP RedirectResponse::setContent方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpFoundation\RedirectResponse::setContent方法的典型用法代码示例。如果您正苦于以下问题:PHP RedirectResponse::setContent方法的具体用法?PHP RedirectResponse::setContent怎么用?PHP RedirectResponse::setContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpFoundation\RedirectResponse的用法示例。


在下文中一共展示了RedirectResponse::setContent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postPostEdit

 public function postPostEdit($request, $response, $args)
 {
     if (!$this->app->auth()->isLoggedIn()) {
         $response = new RedirectResponse('/unauthorised');
         return $response;
     }
     $template = $this->twig->loadTemplate('post/edit.twig');
     $validator = new \Valitron\Validator(array('title' => $this->app->input()->post('title'), 'body' => $this->app->input()->post('body'), 'status' => $this->app->input()->post('status')));
     $validator->rule('required', ['title', 'body', 'status']);
     $validator->rule('integer', ['status']);
     if ($validator->validate()) {
         $post = \Model::factory('\\App\\Models\\Post')->find_one($args['id']);
         if ($post) {
             $post->title = $this->app->input()->post('title');
             $post->body = $this->app->input()->post('body');
             $post->updated_at = date('Y-m-d H:i:s');
             $post->status = $this->app->input()->post('status');
             if ($post->save()) {
                 $response = new RedirectResponse('/');
                 return $response;
             } else {
                 $response->setContent($template->render(['errors' => [['Unable to edit post']], 'input' => $this->app->input()->all('post')]));
             }
         } else {
             $response->setContent($template->render(['errors' => $validator->errors(), 'input' => $this->app->input()->all('post')]));
             return $response;
         }
     } else {
         $response->setContent($template->render(['errors' => $validator->errors(), 'input' => $this->app->input()->all('post')]));
         return $response;
     }
 }
开发者ID:signalfire,项目名称:whatblog,代码行数:32,代码来源:PostEditController.php

示例2: postLogin

 public function postLogin($request, $response, $args)
 {
     $template = $this->twig->loadTemplate('login.twig');
     $validator = new \Valitron\Validator(array('email' => $this->app->input()->post('email'), 'password' => $this->app->input()->post('password')));
     $validator->rule('required', ['email', 'password']);
     $validator->rule('email', 'email');
     $validator->rule('lengthMin', 'password', 6);
     if ($validator->validate()) {
         if ($this->app->auth()->login($this->app->input()->post('email'), $this->app->input()->post('password'))) {
             $response = new RedirectResponse('/');
             return $response;
         } else {
             $response->setContent($template->render(['errors' => [['Unable to login, username and/or password may be incorrect']], 'input' => $this->app->input()->all('post')]));
             return $response;
         }
     } else {
         $response->setContent($template->render(['errors' => $validator->errors(), 'input' => $this->app->input()->all('post')]));
         return $response;
     }
 }
开发者ID:signalfire,项目名称:whatblog,代码行数:20,代码来源:LoginController.php

示例3: onAuthorizationRequest

 /**
  * @param GetResponseForAuthenticationEvent $event
  */
 public function onAuthorizationRequest(GetResponseForAuthenticationEvent $event)
 {
     if ($event->getResponse() !== null) {
         return;
     }
     $request = $event->getRequest();
     // Only act on response_type=token
     $responseType = $request->get("response_type");
     if ($responseType !== "token") {
         return;
     }
     // Verify that implicit grants are allowed
     $client = $event->getClient();
     if (!$client->isAllowedGrantType("implicit")) {
         return;
     }
     $user = $event->getUser();
     $content = $this->getResponseContent($client, $user);
     $redirectUri = $request->get("redirect_uri");
     $state = $request->get("state");
     $queryData = ["state" => $state];
     $queryString = http_build_query($queryData);
     $url = $redirectUri . "?" . $queryString;
     $response = new RedirectResponse($url);
     $response->setContent(json_encode($content));
     $event->setResponse($response);
 }
开发者ID:koenreiniers,项目名称:oauth-server-bundle,代码行数:30,代码来源:TokenResponseSubscriber.php

示例4: redirectTo

 public function redirectTo(string $route, array $routeParams = []) : RedirectResponse
 {
     $url = $this->router->generate($route, $routeParams, true);
     $response = new RedirectResponse($url);
     $response->setContent(sprintf('<!DOCTYPE html><html><head></head><script>window.location.href = "%s";</script></html>', htmlspecialchars($url, ENT_QUOTES, 'UTF-8')));
     return $response;
 }
开发者ID:WellCommerce,项目名称:CoreBundle,代码行数:7,代码来源:RouterHelper.php


注:本文中的Symfony\Component\HttpFoundation\RedirectResponse::setContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。