MaGeFH
Active member
Hello there,
I'm currently working on an addon that extends the advertising system shipping with XF2. In here, i've extended the advertising position entity to require a type (class string), type data (json) and some more fields. This also means that
The problem i'm currentyl wrestling with is this: If i don't specify some defaults for the new fields in the database, the installation process will abort because it tries to import the data using the un-extended version of
What we need would be the ability to defer the data import to a job that runs on the next app cycle (see
My current approach would be to specify some defaults in the table and put deferred job to re-import the data onto the job queue. That should run on the next application call and import the data properly.
Has anyone faced similar "problems", or has a clean solution to this?
I'm currently working on an addon that extends the advertising system shipping with XF2. In here, i've extended the advertising position entity to require a type (class string), type data (json) and some more fields. This also means that
XF/AddOn/DataType/AdvertsingPosition
will be extended to read and write the entity fields.The problem i'm currentyl wrestling with is this: If i don't specify some defaults for the new fields in the database, the installation process will abort because it tries to import the data using the un-extended version of
XF/AddOn/DataType/AdvertsingPosition
during the installation process. This makes sense and should stay that way.What we need would be the ability to defer the data import to a job that runs on the next app cycle (see
XF/Job/Manager::enqueueLater
). Ideally that would be a setting of the addon's setup class:
PHP:
class Setup extends AbstractSetup
{
// Maybe put it into a trait
use XF\AddOn\DeferDataImportTrait;
// This method could be omitted, maybe?
// The DataType classes could be generated automatically
// by looking at the class extensions data...
public function getDataImportToDefer()
{
// Return each base class that can't
// or should'nt be imported straigt away
return [
'XF\AddOn\DataType\AdvertisingPosition',
];
}
/* ... */
}
My current approach would be to specify some defaults in the table and put deferred job to re-import the data onto the job queue. That should run on the next application call and import the data properly.
Has anyone faced similar "problems", or has a clean solution to this?
Last edited: