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

php bakery route:list error on procedural routes #1162

Closed
JosefMor opened this issue Jul 3, 2021 · 0 comments · Fixed by #1165
Closed

php bakery route:list error on procedural routes #1162

JosefMor opened this issue Jul 3, 2021 · 0 comments · Fixed by #1165
Milestone

Comments

@JosefMor
Copy link

JosefMor commented Jul 3, 2021

Useful command route:list is not functional for procedural routes like:

    $app->get('/old/dumb/url', function (Request $request, Response $response) {
        $target = $this->router->pathFor('newUrl');
        return $response->withRedirect($target, 301);
    });

If any route in filter is procedural, error message from SymfonyStyle.php block output

** A cell must be a TableCell, a scalar or an object implementing "__toString()", "object" given. **

===
dirty solution - filter route array, only strings in 'action field:

app/sprinkles/core/src/Bakery/RouteListCommand.php

  /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
....
        // Apply reverse if required
        if ($input->getOption('reverse')) {
            $routes = array_reverse($routes);
        }
       
        // Display routes
        // bug - not for procedural routes  - $this->io->table($this->headers, array_filter($routes));
       
       $routes = array_filter($routes);

        // filter 'action' field = only strings
        foreach($routes as $rid=>$r) {
                if(!is_string($r['action'])) {
                        $routes[$rid]['action'] = 'procedural in routes file';
                }
        }

        $this->io->table($this->headers, $routes);
    }
@lcharette lcharette added this to the 4.5.1 milestone Jul 8, 2021
lcharette added a commit that referenced this issue Jul 12, 2021
@lcharette lcharette mentioned this issue Jul 12, 2021
2 tasks
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

Successfully merging a pull request may close this issue.

2 participants