Lack of interest [Developer Tool] Consider splitting \XF\Repository\Route :: getRouteCacheData $data array creation into a function

This suggestion has been closed automatically because it did not receive enough votes over an extended period of time. If you wish to see this, please search for an open suggestion and, if you don't find any, post a new one.

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 $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
This suggestion has been closed. Votes are no longer accepted.
Top Bottom