當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Controller::redirect方法代碼示例

本文整理匯總了PHP中Symfony\Bundle\FrameworkBundle\Controller\Controller::redirect方法的典型用法代碼示例。如果您正苦於以下問題:PHP Controller::redirect方法的具體用法?PHP Controller::redirect怎麽用?PHP Controller::redirect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Bundle\FrameworkBundle\Controller\Controller的用法示例。


在下文中一共展示了Controller::redirect方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: redirect

 public function redirect($url, $status = 302)
 {
     if ($url instanceof Request) {
         $url = $this->generateUrl($url);
     }
     return parent::redirect($url, $status);
 }
開發者ID:stopsopa,項目名稱:utils,代碼行數:7,代碼來源:AbstractController.php

示例2: internalRedirect

 public function internalRedirect(WebLocation $webLocation, $status = 302)
 {
     $uniqid = uniqid();
     $webLocation->setParameters(array_merge($webLocation->getParameters(), array(ViewState::REQUEST_PARAM_NAME => $uniqid)));
     $this->get('session')->set($uniqid, $this->getViewState()->getData());
     $url = "TO-DO";
     // $this->generateUrl($routeData['route'], $params)
     return parent::redirect($url, $status);
 }
開發者ID:bluegrass,項目名稱:blues,代碼行數:9,代碼來源:Controller.php

示例3: redirect

 public function redirect($url, $status = 302)
 {
     $request = $this->getRequest();
     if ($request->isMethod('POST') && $request->isXmlHttpRequest()) {
         $jsonResponse = new JsonResponse();
         return $jsonResponse->setData(array('redirect' => $url));
     } else {
         return parent::redirect($url, $status);
     }
 }
開發者ID:BelkaB,項目名稱:tangara-server,代碼行數:10,代碼來源:TangaraController.php

示例4: onController

 public function onController(Controller $controller, Request $request)
 {
     $object = $this->admin->getRouteObject();
     $list_url = $this->admin->path('list');
     if (!$object) {
         $request->getSession()->getFlashBag()->add('error', 'not exists!');
         return $controller->redirect($list_url);
     }
     /*
         $tr = $controller->get('translator') ;
     */
     $this->admin->setFormOriginalObject($object);
     $builder = $controller->createFormBuilder($object, array('label' => $this->admin->getFormLabel()));
     $this->admin->buildUpdateForm($controller, $object, $builder, $this);
     $this->buildFormReferer($request, $builder, $object, $list_url);
     $form = $builder->getForm();
     $this->setForm($form);
     $dispatcher = $this->admin->getService('event_dispatcher');
     $event = new \Symforce\AdminBundle\Event\FormEvent($form, $request);
     $dispatcher->dispatch('sf.event.form', $event);
     if (null !== $event->getResponse()) {
         return $event->getResponse();
     }
     if ($request->isMethod('POST')) {
         $form->bind($request);
         $this->admin->fireEvent('submit', $form);
         if ($form->isValid()) {
             $this->admin->onUpdate($controller, $request, $this, $object, $form);
             if ($form->isValid()) {
                 $this->admin->update($object);
                 return $this->admin->afterUpdate($controller, $request, $this, $object, $form);
             }
         }
     }
     return $controller->render($this->template, array('sf_admin_loader' => $controller->get('sf.admin.loader'), 'admin' => $this->admin, 'action' => $this, 'form' => $form->createView()));
 }
開發者ID:symforce,項目名稱:symforce-admin,代碼行數:36,代碼來源:UpdateActionCache.php

示例5: testRedirect

 public function testRedirect()
 {
     $controller = new Controller();
     $response = $controller->redirect('http://dunglas.fr', 301);
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $response);
     $this->assertSame('http://dunglas.fr', $response->getTargetUrl());
     $this->assertSame(301, $response->getStatusCode());
 }
開發者ID:neartux,項目名稱:visitayucatan2.0,代碼行數:8,代碼來源:ControllerTest.php

示例6: redirect

 public function redirect($url, $status = 302)
 {
     return parent::redirect($url, $status);
 }
開發者ID:symfony,項目名稱:symfony,代碼行數:4,代碼來源:ControllerTest.php

示例7: onController

 public function onController(Controller $controller, Request $request)
 {
     $object = $this->admin->getRouteObject();
     $list_url = $this->admin->path('list');
     if (!$object) {
         $request->getSession()->getFlashBag()->add('error', 'not exists!');
         return $controller->redirect($this->admin->path('list'));
     }
     $admin_children = array();
     $children = $this->admin->getAdminRouteChildren();
     if ($children) {
         foreach ($children as $child_admin_name => $o) {
             if ($o[0]) {
                 throw new \Exception("unimplement");
             }
             $admin_children[$child_admin_name] = array();
             $child_admin = $this->admin->getAdminLoader()->getAdminByName($child_admin_name);
             $properties = $o[0] ? $o[1] : array($o[1]);
             foreach ($properties as $config) {
                 $child_property = $config[0];
                 $my_property = $config[1];
                 $count = $child_admin->countBy($child_property, $object);
                 $admin_children[$child_admin_name][$child_property] = $count;
             }
         }
     }
     /**
      * @var \Symfony\Component\Form\FormBuilder
      */
     $builder = $controller->createFormBuilder($object, array('label' => $this->admin->getFormLabel(), 'constraints' => array(new \Symfony\Component\Validator\Constraints\Callback(function ($object, \Symfony\Component\Validator\Context\ExecutionContext $context) use($controller, $admin_children) {
         foreach ($admin_children as $child_admin_name => $list) {
             $child_admin = $this->admin->getAdminLoader()->getAdminByName($child_admin_name);
             foreach ($list as $count) {
                 if ($count > 0) {
                     if (!$child_admin->auth('delete')) {
                         $error = $this->admin->trans('sf.action.delete.error.child', array('%admin%' => $this->admin->getLabel(), '%child%' => $child_admin->getLabel(), '%count%' => $count), $this->sf_domain);
                         $context->addViolation($error);
                     }
                 }
             }
         }
     }))));
     $this->buildFormReferer($request, $builder, $object, $list_url);
     $form = $builder->getForm();
     $this->setForm($form);
     $dispatcher = $this->admin->getService('event_dispatcher');
     $event = new \Symforce\AdminBundle\Event\FormEvent($form, $request);
     $dispatcher->dispatch('sf.event.form', $event);
     if (null !== $event->getResponse()) {
         return $event->getResponse();
     }
     if ($request->isMethod('POST')) {
         $form->bind($request);
         $this->admin->fireEvent('submit', $form);
         if ($form->isValid()) {
             $msg = $this->trans('sf.action.delete.finish', $object);
             $this->admin->remove($object);
             $request->getSession()->getFlashBag()->add('info', $msg);
             return $controller->redirect($this->getFormReferer($form));
         }
     }
     return $controller->render($this->template, array('sf_admin_loader' => $controller->get('sf.admin.loader'), 'admin' => $this->admin, 'action' => $this, 'form' => $form->createView()));
 }
開發者ID:symforce,項目名稱:symforce-admin,代碼行數:63,代碼來源:DeleteActionCache.php

示例8: afterCreate

 public function afterCreate(Controller $controller, Request $request, ActionCache $action, $object, \Symfony\Component\Form\Form $form)
 {
     $request->getSession()->getFlashBag()->add('info', $this->trans('sf.action.create.finish', $object));
     return $controller->redirect($action->getFormReferer($form));
 }
開發者ID:symforce,項目名稱:symforce-admin,代碼行數:5,代碼來源:AdminCache.php


注:本文中的Symfony\Bundle\FrameworkBundle\Controller\Controller::redirect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。