Lifecycle
Each node can run callbacks while Qore handles a node request and while it prepares the node response.
Use request callbacks for incoming state, such as button clicks or form interactions. Use response callbacks for derived output, such as table pagination, disabled dates or final node properties.
On Node Request
Runs before serialization, while the backend is handling incoming node state. For example, ButtonNode checks whether the user clicked it:
$myNode->onNodeRequest(function (NodeManager $manager) {
if (! $manager->getStateByKey($this->id)) {
return;
}
$listener = $this->onClickListener;
$listener(new ClickEvent($this, $manager));
});
On Node Response
Runs after request callbacks and before serialization.
For example, EloquentTableNode uses this stage to handle pagination, sorting and filtering:
$myNode->onNodeResponse(function (NodeManager $nodeManager) {
$this->handleTableResponse($nodeManager);
});
On Form Request
Fields inside a FormNode also have a form request lifecycle. For example, FileField builds its hint while the form request is being handled:
$this->onFormRequest(function () {
$parts = [];
if ($this->getMinFiles() !== null) {
$parts[] = __('qore::common.file_hint.min_files', [
'count' => $this->getMinFiles(),
]);
}
// ..
$hint = implode(' • ', $parts);
if ($hint) {
$this->setHint($hint);
}
});
On Form Response
Use the form response lifecycle when the field needs to add response-only data after form request handling is complete.
$this->onFormResponse(function (Form $form) {
if ($this->disabledDatesCallback) {
$callback = $this->disabledDatesCallback;
$this->disabledDates = $this->parseDisabledDates($callback($form));
}
// ...
});