How to get $settings data out of CakePHP 2.0 FormAuthenticate object

僤鯓⒐⒋嵵緔 提交于 2020-01-06 07:57:07

问题


I am building a RememberMe Component using the AuthComponent and would like to get the BaseAuthenticate::$settings data (userModel and fields) data out of the XxxxAuthenticate object so I can know what model and fields I should be dealing with, but I can't seem to figure out how to get that data back out.

Any suggestions?

Basically I need something with the same functionality as Auth::getModel( ) or Auth::$userModel from Cake 1.X.

Cake- 2.0.3


回答1:


Auth::$userModel still exists in 2.0. However, you probably have to access it via the instantied object rather than statically:

$modelData = $this->Auth->userModel;

If this isn't set, then it defaults to User.

You can then get the model by looking at the first array key that is returned:

$modelName = key($modelData[0]);


来源:https://stackoverflow.com/questions/8198125/how-to-get-settings-data-out-of-cakephp-2-0-formauthenticate-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!