I created a new Table per Migration for my project to enable AutoLogin per Cookie. My problem is, that the TableObject is missing it’s [“connectionName”] property on initialize.
I tried to find a way to fix this, but the only way I found was setting the Connection with the ConnectionManager. This will work for now, but I’d really like to know where I made a mistake, and why the connectionName isn’t set to ‘default’ on its own.
My Migrationfile looks like this:
public function change()
{
$table = $this->table(‘autologins’, [‘id’ => false, ‘primary_key’ => ‘id’]);
$table->addColumn(‘id’, ‘uuid’, [
‘limit’ => 36,
‘null’ => false,
]);
$table->addColumn(‘token’, ‘string’,[
‘null’ => false,
‘limit’ => 32,
]);
$table->addColumn(‘user_agent’, ‘string’,[
‘null’ => false,
‘limit’ => MysqlAdapter::TEXT_TINY,
]);
$table->addColumn(‘user_id’, ‘uuid’,[
‘limit’ => 36,
‘null’ => false,
]);
$table->addColumn(‘expiry_date’, ‘datetime’,[
‘null’ => false,
]);
$table->create();
}
Without setting the Connection
$this->setConnection(ConnectionManager::get(‘default’));
I get the following var_dump:
object(App\Model\Table\AutologinsTable)#486 (8) {
[“registryAlias”]=> string(10) “Autologins”
[“table”]=> string(10) “autologins”
[“alias”]=> string(10) “Autologins”
[“entityClass”]=> string(26) “App\Model\Entity\Autologin”
[“associations”]=> array(0) { }
[“behaviors”]=> array(0) { }
[“defaultConnection”]=> string(7) “default”
[“connectionName”]=> NULL }