I need to redirect according to some conditions in the bootstrap file.
It is done AFTER the front controller and routes are defined.
How do I do that?
(I know I can simply use header( Location: ....) The point is I need to use the Router to build the URL.
是否有办法将浏览器从Zentd Framework的boot锁中转移?
原标题:
最佳回答
more than year later, i m programming in ZF and I got this solution for your problem. Here is my function in bootstrap that determines where the user is logged on.
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
页: 1
protected $_front;
(...)
protected function _initViewController()
页: 1
(...)
$this->bootstrap( FrontController );
$this->_front = $this->getResource( FrontController );
(...)
iii
protected function _initLogado()
页: 1
$router = $this->_front->getRouter();
$req = new Zend_Controller_Request_Http();
$router->route($req);
$module = $req->getModuleName();
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) 页: 1
$this->_view->logado = (array) $auth->getIdentity();
iii else 页: 1
$this->_view->logado = NULL;
if ($module == admin ) 页: 1
$response = new Zend_Controller_Response_Http();
$response->setRedirect( / );
$this->_front->setResponse($response);
iii
iii
iii
iii
问题回答
重新定位实际上不应放在boot陷室档案中...... 这将是一个可怕的夜晚,为军士们打着 de,几年来,军士们最终.着你的手法。
要么使用前主计长Plugin, 行动主计长Plugin,要么在你的行动主计长中使用。 最终应完全避免这种转移。
最好的方法是Controller Plugin。
您可以添加一条路Sh,在行道发生后即叫.,但在行动方法上要求你的控制员。 在这种缩略语中,你可以检查请求数据,或者可以寻求在《欧洲反种族歧视公约》中获得许可,或者只是随意地转播你想要的东西!
你们的选择!
EDIT:重新审视你的问题,它像你一样对路线不感兴趣——将路线规范作为boot后最早的点,以注入你的代码。
我愿从前线控制器中挑选出路人,将其打上<条码>(条码>>方法,然后使用<条码>标题(条码>):
关于
Rob...
您可以检查假肢中“旋转”方法的条件,然后使用thi-&;行动主计长->_helper->redirector()转方向;
相关问题
热门标签
- winforms
- combobox
- fogbugz
- java
- date
- internationalization
- asp.net
- iis
- url-rewriting
- urlrewriter
- c#
- enums
- ocaml
- haxe
- algorithm
- string
- viewstate
- .net
- c++
- c
- symbol-table
- mysql
- database
- postgresql
- licensing
- migration
- vb.net
- vb6
- declaration
- vb6-migration
- python
- psycopg2
- backup
- vmware
- virtualization
- gnu-screen
- authentication
- desktop
- excel
- xll
- cultureinfo
- regioninfo
- oracle
- client
- session
- download
- html
- virtual
- constructor
- scenarios
- perl
- full-text-search
- javascript
- ajax
- testing
- oop
- inheritance
- vim
- encapsulation
- information-hiding