Closed tgoeminne closed 2 years ago
Which version of CakePHP and Users plugin are using?
Are you using a custom users table?
The table class is set based on your config, see https://github.com/CakeDC/users/blob/11.next-cake4/config/bootstrap.php#L26
Am using 4.4 cakephp and dcusers 11.1 fresh install, no custom table
also $this->Auth seems to not be available in controllers anymore. Is this normal expected behaviour?
Correct, Auth component is not available, instead of this we are using the plugins https://github.com/cakephp/authentication and https://github.com/cakephp/authorization
About the main issue reported, I have checked the CakePHP source and that is the expected behavior. Also the cakephp/app package have a config to disable fallback classes, see https://github.com/cakephp/app/blob/4.x/src/Application.php#L52
Is a bit strange that it doesnt set the Table class Alias for Users. So you always need to change it to 'className' => 'CakeDC/Users.Users', after you bake anything
I recommend you to check https://github.com/CakeDC/users/blob/11.next-cake4/config/bootstrap.php#L26 and what you get in the TableLocator class.
Table class for alias Users could not be found. Get this message when you use the default config. Before it was not like that.
Correct, cause old app skeleton would use a fallback class (\Cake\ORM\Table), see https://github.com/cakephp/app/blob/4.x/src/Application.php#L52
Also, as I mentioned, if you check (and debug) the TableLocator class you see that for associations is used the model alias as className.
So, this is how CakePHP apllication works and the new change is related to cakephp/app repository.
You used to be able to reference the table as Users now you need to do CakeDC/Users.Users is because the alias is not set? It's eassier when you can just refrence it as Users.
$this->belongsTo('Users', [ 'className' => 'CakeDC/Users.Users', 'foreignKey' => 'user_id', 'joinType' => 'INNER', ]);
$this->belongsTo('Users', [ 'foreignKey' => 'user_id', 'joinType' => 'INNER', ]);