Closed Cyrille37 closed 2 years ago
How are you extending/configuring the UserOverride
Entity & the UserOverridesTable
please?
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;
}
}
Using $this->setRegistryAlias()
or not extending directly the UsersTable, but appending the behaviors you need should do the trick for you...
Thanks @steinkel setRegistryAlias()
do the job :-)
Hi
After login the user entity is of the right type
App\Model\Entity\UserOverride
which I configured inConfig.Users.table
but its property_registryAlias
is'Users'
where it should be'UserOverrides'
.Here is a var_export( $user ) extract :