DragonByte Tech
Well-known member
At the moment, it is not possible for add-ons to add custom fields to the route cache data without re-fetching all the data.
Use case: I want to create an extension to the API system that allows for per-route rate limits. I want to be able to extend the Route entity and add new fields to the
However, this is not possible as it stands. Therefore, please consider changing this:
To this:
So that what I need can be implemented without having to re-fetch all data.
Thank you.
Fillip
Use case: I want to create an extension to the API system that allows for per-route rate limits. I want to be able to extend the Route entity and add new fields to the
$data
array, like so:
PHP:
$data = [
'format' => $route->format,
'build_callback' => $route->build_class ? [$route->build_class, $route->build_method] : null,
'controller' => $route->controller,
'context' => $route->context,
'action_prefix' => $route->action_prefix,
'dbtech_api_rate_limit_amount' => $route->dbtech_api_rate_limit_amount,
'dbtech_api_rate_limit_minutes' => $route->dbtech_api_rate_limit_minutes
];
However, this is not possible as it stands. Therefore, please consider changing this:
PHP:
$data = [
'format' => $route->format,
'build_callback' => $route->build_class ? [$route->build_class, $route->build_method] : null,
'controller' => $route->controller,
'context' => $route->context,
'action_prefix' => $route->action_prefix
];
if ($route->AddOn && $route->AddOn->is_processing)
{
$this->disableProcessingAddOnRoute($route, $data);
}
To this:
PHP:
$data = $this->buildRouteCacheData($route);
So that what I need can be implemented without having to re-fetch all data.
Thank you.
Fillip
Upvote
1