tom3
Active member
I'm currently trying to create an ApiKey directly during the installation, in installation step number one I add a boolean field to the entity.
In step two I try to create an ApiKey with the help of the Entity Manager but I get the error message that the field does not exist (probably because the event listener has not been run yet?).
Same goes for uninstalling.
How can I create an entity during installation while extending?
In step two I try to create an ApiKey with the help of the Entity Manager but I get the error message that the field does not exist (probably because the event listener has not been run yet?).
Same goes for uninstalling.
Code:
In Finder.php line 1640:
[InvalidArgumentException]
Unknown column test on XF:ApiKey
PHP:
public function installStep1()
{
$this->schemaManager()->alterTable('xf_api_key', function(Alter $table)
{
$table->addColumn('test', 'tinyint')->setDefault(0);
});
}
public function installStep2()
{
if (!$this->assertExistingKey())
{
$key = \XF::em()->create('XF:ApiKey');
$key->set('title', 'testkey');
$key->set('test', true);
$key->save();
}
}
public function uninstallStep1()
{
if ($key = $this->assertExistingKey())
{
$key->delete();
}
}
public function uninstallStep2()
{
$this->schemaManager()->alterTable('xf_api_key', function(Alter $table)
{
$table->dropColumns('test');
});
}
How can I create an entity during installation while extending?