本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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;
}
示例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());
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}