Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grouping routes should let me pass additional variables within the closure function #3691

Closed
crustamet opened this issue Sep 28, 2020 · 1 comment

Comments

@crustamet
Copy link
Contributor

I want to dynamically make the routes from the database with a tree model.

i have an array with all my routes that i need to parse them recursively.

so in my config routes file i have like this.

use RoutesModel as RoutesModel;

$RoutesModel = new RoutesModel();
$DBRoutes = $RoutesModel->findTree();

    $module = $DBRoutes[1];

$routes->group($module['url'], ['namespace' => $module['namespace']], function($routes, $DBRoutes)
{
	print_r($DBRoutes);die();
});

If you check the second parameter when i group this gives me an error of course it gives an error.
Too few arguments to function Config{closure}(), 1 passed in /project/system/Router/RouteCollection.php on line 753 and exactly 2 expected

I've tried to put this DBRoutes into options that i can get inside the grouping method but no luck.

I request for the grouping method to be able to pass multiple variables not just the routes.

@crustamet
Copy link
Contributor Author

Upps sorry i found how to do it

$routes->group($module['url'], ['namespace' => $module['namespace']], function($routes) use ($DBRoutes)
{
print_r($DBRoutes);die();
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant