public function handleApiVersion($route)
{
$params = $route->getParams();
if (!preg_match('/^\\d+(beta\\d*)?$/', $params['apiversion'])) {
throw new ApiErrorException(400, ErrorMessage::ERR_BAD_REQUEST, 'Invalid API version');
}
$this->settings[static::SETTING_API_VERSION] = $params['apiversion'];
unset($params['apiversion']);
$route->setParams($params);
//This also parses the named route compound handler
$options = $route->getDefaults();
if (!is_callable($options['controller'])) {
$route->setDefaults(['controller' => $this->getRouteHandler($options['controller'])]);
}
}