CakePHP 为什么我的应用程序控制器不能用于管理员?

问题描述 投票:0回答:1

由于某种原因,当我在管理部分时,beforefilter 没有在 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

过滤器之前的应用程序控制器:

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());
    }
}

这是为什么?

php cakephp cakephp-1.3
1个回答
1
投票

特定控制器有beforeFilter吗?它会调用parent::beforeFilter吗?

简单的事情有时会被忽视。

© www.soinside.com 2019 - 2024. All rights reserved.