我在为cakephp 3编写的组件插件中有一点问题
我想重定向到另一个页面,但似乎我无法正确使用我的控制器参考。 当我重定向到另一个页面时,启动一个漫长的等待时间,例如它找不到页面但没有错误。
在我的组件中,我写了这样的东西:
namespace UserPermissions\Controller\Component;
use Cake\Controller\Component;
use Cake\Controller\ComponentRegistry;
use Cake\Datasource\ConnectionManager;
use Cake\ORM\TableRegistry;
use Cake\Controller\Component\FlashComponent;
class UserPermissionsComponent extends Component {
public $controller = null;
public function initialize(array $config)
{
parent::initialize($config);
$this->controller = $this->_registry->getController();
$this->session = $this->controller->request->session();
}
public function redirect () {
return $this->controller->redirect(
['controller' => 'example2', 'action' => 'index']
);
}
}
重定向方法似乎不起作用
引用控制器的正确方法是什么?
由于