How to get $settings data out of CakePHP 2.0 FormA

2019-08-29 06:03发布

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条回答
\"骚年 ilove
2楼-- · 2019-08-29 06:32

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]);
查看更多
登录 后发表回答