问题
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