asprin
Active member
Use case scenario:
I'm building an addon which will allow certain limited users to create a new record of a custom entity (let's call this entity Foo). The create form has a date time field where the user will select a value (always a date in future) and will be in
So let's assume a user selects a date time value which is like 30 hours from now and creates the record by clicking the submit button. Now is there a way to:
One way I thought of achieving this is why page loads but I don't feel it's a very good approach since it will require querying the database on every page load.
I'm building an addon which will allow certain limited users to create a new record of a custom entity (let's call this entity Foo). The create form has a date time field where the user will select a value (always a date in future) and will be in
Y-m-d hh:mm
format which then gets stored as unix timestamp in the database.
PHP:
public static function getStructure(Structure $structure)
{
$structure->table = 'xf_asp_fb_foo';
$structure->shortName = 'Asprin\FB:Foo';
$structure->contentType = 'asprin_fb_foo';
$structure->primaryKey = 'sys_id';
$structure->columns = [
'sys_id' => ['type' => self::UINT, 'autoIncrement' => true],
'close_time' => ['type' => self::UINT, 'required' => true], // user entered value will be stored here
'is_time_over' => ['type' => self::BOOL, 'required' => false, 'default' => 0]
];
$structure->getters = [];
$structure->relations = [];
$structure->defaultWith = [];
return $structure;
}
So let's assume a user selects a date time value which is like 30 hours from now and creates the record by clicking the submit button. Now is there a way to:
- Execute something after 30 hours which will update
is_time_over
value to 1? - Cron seems to be a way forward, but not sure if there's an example of how this can be done programmatically.
- It would be great if I can pass some arguments to the function that will be called after 30 hours (so that I can use the finder class to fetch that exact row)
One way I thought of achieving this is why page loads but I don't feel it's a very good approach since it will require querying the database on every page load.