Phalcon 4.0.6 Static route BUG

Hello, i got WARNING error for static routes, when i use extra params!

Warning : array_flip(): Can only flip STRING and INTEGER values! in path.to.volt.phtml on line 11 Example:

<?php
/*
 * id, title, ident
 */
$categories = Model\Categories::find();

#static route, category is object
foreach ($categories as $category) {
    $router->add('/'.$category->ident, ['category' => $category])->setName('static_route.' . $category->id);
}
?>

Routes are generated, but with WARNING {{ link_to( [ 'for' : 'static_route.1' ], 'Show Invoice', 'class': 'edit-btn') }}

thanks :)

What php version you use?



1.9k

7.3.6 and 7.4.0 same result

edited Aug '20

I think this is a php warning - $category here is an object, and you pass it as paths to route. Phalcon does array_flip and that's why you have error http://sandbox.onlinephpfunctions.com/code/da43d8087692128a2979eb704d3d5603279f0f0f as you can check - same error



1.9k

Solution for routing?

(joke) - turn on error_reporting with E_WARNING flag when application is production model:)

But there is no phalcon bug. You are just passing wrong data.



1.9k

Wrong data in STATIC ROUTE ?

? I don't understand. Phalcon does array_flip for paths parameter, and you pass there object as value, object cant be a key in php for arrays, so i'm not sure what's your problem here.

I faced similar kind of issue last time, I am still searching for some proper solution DQ Fan Feedback