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


PHP View::createRedirect方法代码示例

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


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

示例1: indexAction

 /**
  * @Route("/extra.{_format}", name="_extra_noname", defaults={"_format"="html"}),
  * @Route("/extra/{name}.{_format}", name="_extra_name", defaults={"_format"="html"})
  * @View()
  */
 public function indexAction($name = null)
 {
     if (!$name) {
         return ViewClass::createRedirect('http://liip.ch');
     }
     return array('name' => $name);
 }
开发者ID:dranzboi,项目名称:LiipHelloBundle,代码行数:12,代码来源:ExtraController.php

示例2: prepareCaptureAction

 /**
  * @param Request $request
  * @param $lastNewPaymentId
  *
  * @return Response
  */
 public function prepareCaptureAction(Request $request, $lastNewPaymentId)
 {
     $configuration = $this->requestConfigurationFactory->create($this->paymentMetadata, $request);
     $payment = $this->paymentRepository->find($lastNewPaymentId);
     Assert::notNull($payment);
     $request->getSession()->set('sylius_order_id', $payment->getOrder()->getId());
     $captureToken = $this->getTokenFactory()->createCaptureToken($payment->getMethod()->getGateway(), $payment, $configuration->getParameters()->get('redirect[route]', null, true), $configuration->getParameters()->get('redirect[parameters]', [], true));
     $view = View::createRedirect($captureToken->getTargetUrl());
     return $this->viewHandler->handle($configuration, $view);
 }
开发者ID:TheMadeleine,项目名称:Sylius,代码行数:16,代码来源:PayumController.php

示例3: cpostAction

 /**
  * Create an organisation
  * @var Request $request
  * @return View|FormInterface
  */
 public function cpostAction(Request $request)
 {
     $organisation = new Organisation();
     $form = $this->formFactory->createNamed('', new OrganisationType(), $organisation);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $this->manager->persist($organisation);
         $this->manager->flush($organisation);
         $url = $this->router->generate('get_organisation', array('organisation' => $organisation->getId()));
         return View::createRedirect($url, Codes::HTTP_CREATED);
     }
     return $form;
 }
开发者ID:HilmiHB,项目名称:Symfony2Rest,代码行数:18,代码来源:OrganisationController.php

示例4: cpostAction

 /**
  * Create a user for an organisation
  * @var Organisation $organisation
  * @var Request $request
  * @return View|FormInterface
  */
 public function cpostAction(Organisation $organisation, Request $request)
 {
     $user = new User($organisation);
     $form = $this->formFactory->createNamed('', 'Nmpolo\\RestBundle\\Form\\UserType', $user);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $this->manager->persist($user);
         $this->manager->flush($user);
         $url = $this->router->generate('get_organisation_user', array('organisation' => $organisation->getId(), 'user' => $user->getId()));
         return View::createRedirect($url, Codes::HTTP_CREATED);
     }
     return $form;
 }
开发者ID:nmpolo,项目名称:Symfony2Rest,代码行数:19,代码来源:UserController.php

示例5: testSetLocation

 public function testSetLocation()
 {
     $url = 'users';
     $code = 500;
     $view = View::createRedirect($url, $code);
     $this->assertAttributeEquals($url, 'location', $view);
     $this->assertAttributeEquals(null, 'route', $view);
     $this->assertEquals($code, $view->getResponse()->getStatusCode());
     $view = new View();
     $location = 'location';
     $view->setLocation($location);
     $this->assertEquals($location, $view->getLocation());
 }
开发者ID:LamaDelRay,项目名称:test_symf,代码行数:13,代码来源:ViewTest.php

示例6: cpostAction

 /**
  * Create a user for an Groups
  * @var Groups $Groups
  * @var Request $request
  * @return View|FormInterface
  */
 public function cpostAction(Groups $Groups, Request $request)
 {
     $user = new User($Groups);
     $form = $this->formFactory->createNamed('', new UserType(), $user);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $this->manager->persist($user);
         $this->manager->flush($user);
         $url = $this->router->generate('get_Groups_user', array('Groups' => $Groups->getId(), 'user' => $user->getId()));
         return View::createRedirect($url, Codes::HTTP_CREATED);
     }
     return $form;
 }
开发者ID:benakacha,项目名称:apisf2,代码行数:19,代码来源:UserController.php

示例7: postAction

 /**
  * Collection post action
  * @var Request $request
  * @return View|array
  */
 public function postAction(Request $request)
 {
     $challenge = new Challenge();
     $form = $this->createForm(new ChallengeType(), $challenge, array('csrf_protection' => false));
     $json_data = json_decode($request->getContent(), true);
     //get the response data as array
     $form->submit($json_data);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($challenge);
         $em->flush();
         $url = $this->generateUrl('bf_rest_api_challenges_get', array('id' => $challenge->getId()));
         return View::createRedirect($url, Codes::HTTP_CREATED);
     }
     return array('form' => $form);
 }
开发者ID:jojotjebaby,项目名称:Bestfootball,代码行数:21,代码来源:ChallengeController.php

示例8: redirectView

 /**
  * Creates a Redirect view.
  *
  * Convenience method to allow for a fluent interface.
  *
  * @param string $url
  * @param int    $statusCode
  * @param array  $headers
  *
  * @return View
  */
 protected function redirectView($url, $statusCode = Codes::HTTP_FOUND, array $headers = array())
 {
     return View::createRedirect($url, $statusCode, $headers);
 }
开发者ID:anhpha,项目名称:reports,代码行数:15,代码来源:FOSRestController.php

示例9: create

 /**
  * Convenience method to allow for a fluent interface.
  *
  * @param string  $url
  * @param integer $statusCode
  * @param array   $headers
  *
  * @deprecated To be removed in FOSRestBundle 2.0.0. Use View::createRedirect instead.
  */
 public static function create($url, $statusCode = Codes::HTTP_FOUND, array $headers = array())
 {
     return View::createRedirect($url, $statusCode, $headers);
 }
开发者ID:kasobus,项目名称:EDENS-Mautic,代码行数:13,代码来源:RedirectView.php

示例10: redirectView

 /**
  * Creates a Redirect view.
  *
  * Convenience method to allow for a fluent interface.
  *
  * @param string $url
  * @param int    $statusCode
  * @param array  $headers
  *
  * @return View
  */
 protected function redirectView($url, $statusCode = Response::HTTP_FOUND, array $headers = [])
 {
     return View::createRedirect($url, $statusCode, $headers);
 }
开发者ID:fengxw,项目名称:dirty,代码行数:15,代码来源:ControllerTrait.php

示例11: process

 /**
  * @param array  $parameters
  * @param OrmPersistible|null   $object
  * @param string $method
  *
  * @return View
  */
 protected function process(array $parameters, $object, $method = 'PUT')
 {
     $class = $this->getTypeClassString();
     $type = class_exists($this->getTypeClassString()) ? new $class() : $this->getTypeClassString();
     $bag = array();
     list($object, $bag, $parameters) = $this->preSubmit($object, $bag, $parameters);
     $form = $this->formfactory->create($type, $object);
     $form->submit($this->camelizeParamers($parameters), 'PATCH' !== $method);
     $url = $this->getRouteName();
     /** @var OrmPersistible $object */
     if ($form->isValid()) {
         $code = $object->getId() ? Codes::HTTP_NO_CONTENT : Codes::HTTP_CREATED;
         list($object, ) = $this->preFlush($object, $bag);
         $this->getEm()->persist($object);
         $this->getEm()->flush();
         $view = View::createRedirect($this->router->generate($url, array('id' => $object->getId())), $code);
         return $view;
     }
     $this->logger->error((string) $form->getErrors(false, true) . " PARAMETERS: " . json_encode($parameters));
     return View::create($form, Codes::HTTP_BAD_REQUEST);
 }
开发者ID:bixlabs,项目名称:concepto-sises,代码行数:28,代码来源:RestHandler.php

示例12: prepareCaptureAction

 /**
  * @param Request $request
  * @param mixed $tokenValue
  *
  * @return Response
  */
 public function prepareCaptureAction(Request $request, $tokenValue)
 {
     $configuration = $this->requestConfigurationFactory->create($this->orderMetadata, $request);
     /** @var OrderInterface $order */
     $order = $this->orderRepository->findOneByTokenValue($tokenValue);
     if (null === $order) {
         throw new NotFoundHttpException(sprintf('Order with token "%s" does not exist.', $tokenValue));
     }
     $request->getSession()->set('sylius_order_id', $order->getId());
     $options = $configuration->getParameters()->get('redirect');
     $payment = $order->getLastPayment(PaymentInterface::STATE_NEW);
     if (null === $payment) {
         throw new NotFoundHttpException(sprintf('Order with token "%s" has no pending payments.', $tokenValue));
     }
     $captureToken = $this->getTokenFactory()->createCaptureToken($payment->getMethod()->getGateway(), $payment, isset($options['route']) ? $options['route'] : null, isset($options['parameters']) ? $options['parameters'] : []);
     $view = View::createRedirect($captureToken->getTargetUrl());
     return $this->viewHandler->handle($configuration, $view);
 }
开发者ID:NeverResponse,项目名称:Sylius,代码行数:24,代码来源:PayumController.php

示例13: putAction

 /**
  * Put action
  * @var Request $request
  * @var integer $id Id of the user
  * @return View|array
  */
 public function putAction(Request $request, $id)
 {
     $user = $this->getEntity($id);
     $form = $this->createForm(new UserType(), $user, array('csrf_protection' => false));
     $json_data = json_decode($request->getContent(), true);
     //get the response data as array
     $form->submit($json_data);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($user);
         $em->flush();
         return View::createRedirect($url, Codes::HTTP_NO_CONTENT);
     }
     return array('form' => $form);
 }
开发者ID:jojotjebaby,项目名称:Bestfootball,代码行数:21,代码来源:UserController.php


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