RegistryAlias is not the right one
Cyrille37 opened this issue · 4 comments
Cyrille37 commented
Hi
- cakedc/users 11.0.0
- cakephp/cakephp 4.3.5
After login the user entity is of the right type App\Model\Entity\UserOverride
which I configured in Config.Users.table
but its property _registryAlias
is 'Users'
where it should be 'UserOverrides'
.
Here is a var_export( $user ) extract :
2022-02-23 06:49:16 debug: App\Model\Entity\UserOverride::__set_state(array(
'_accessible' =>
array (
'*' => true,
'id' => false,
'is_superuser' => false,
'role' => false,
'group_id' => true,
),
...
'_dirty' =>
array (
'last_login' => true,
),
'_new' => false,
'_errors' =>
array (
),
'_invalid' =>
array (
),
'_registryAlias' => 'Users',
))
steinkel commented
How are you extending/configuring the UserOverride
Entity & the UserOverridesTable
please?
Cyrille37 commented
Yes :-)
namespace App\Model\Table;
use CakeDC\Users\Model\Table\UsersTable;
/**
* Application specific Users Table with non plugin conform field(s)
*/
class UserOverridesTable extends UsersTable
{
/**
* CakeDc table name.
*/
const TABLENAME = 'users';
public function initialize(array $config): void
{
parent::initialize($config);
$this->setTable( self::TABLENAME );
$this->addBehavior('Timestamp');
}
}
namespace App\Model\Entity;
use CakeDC\Users\Model\Entity\User;
/**
* @inheritdoc
* @property integer $group_id
*/
class UserOverride extends User
{
public function __construct(array $properties = [], array $options = [])
{
parent::__construct($properties, $options);
$this->_accessible['group_id'] = true;
}
}
steinkel commented
Using $this->setRegistryAlias()
or not extending directly the UsersTable, but appending the behaviors you need should do the trick for you...