0
出於某種原因,當我在管理部分中時,在appcontroller中未執行過濾器。CakePHP爲什麼我的appcontroller不能用於管理員?
我用die();
測試它,它仍然通過。可能是什麼問題呢?
當我註銷時,它轉發到登錄,appcontroller被執行。當我登錄時,我遇到了問題。
路由器:
Router::connect('/', array('controller' => 'static', 'action' => 'index'));
/**
* ...and connect the rest of 'Pages' controller's urls.
*/
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/**
* PLUGIN MATCH
*/
if ($plugins = Configure::listObjects('plugin')) {
$pluginMatch = implode('|', array_map(array('Inflector', 'underscore'), $plugins));
Router::connect("/:language/:plugin/:controller/:action/*", array('action' => null), array('plugin' => $pluginMatch) );
}
/**
* ADMIN
*/
Router::connect('/:language/admin/:controller/:action/*', array('action' => null, 'admin'=> true), array('language' => '[a-z]{3}'));
Router::connect('/:language/admin', array('controller' => 'admin', 'action' => 'index'), array('language' => '[a-z]{3}')); //...and set the admin default page
/**
* LANGUAGES
*/
Router::connect('/:language/home', array('controller' => 'static', 'action' => 'index'));
Router::connect('/:language/about', array('controller' => 'static', 'action' => 'about'));
// ...and more of those regular redirects here
AppController的beforeFilter:
function beforeFilter(){
die();
// LANGUAGES
$this->_setLanguage();
$this->Auth->authorize = 'actions'; // CAN SOMEBODY EXPLAIN TO ME WHAT THIS DOES?
$this->Auth->logoutRedirect = array('controller' => 'static', 'action' => 'index', 'language'=>$this->Session->read('Config.language'));
$this->Auth->loginRedirect = array('controller' => 'galleries', 'action' => 'index', 'language'=>$this->Session->read('Config.language'));
$this->Auth->loginAction = array('controller'=>'users', 'action'=>'login', 'plugin'=>null,'language'=>$this->Session->read('Config.language'));
// ACO
$this->Auth->actionPath = 'controllers/'; // The main ACO. Maybe we need to change something for languages?
if($this->Auth->user()){
$this->set('u', $this->Auth->user());
}
}
這是爲什麼?
特定的控制器是否有beforeFilter?並調用parent :: beforeFilter嗎? – mark 2012-01-26 23:31:01
呃...對。想寫答案,所以我可以標記它的權利? – mgPePe 2012-01-26 23:53:21