Bug? CI 4 not remove method from params when use routes ? |
Url: site[.]com/p/seo-url/param1/param2/...
app/Config/Routes.php PHP Code: $routes->add('p/(:any)', 'Post::index'); app/Controllers/BaseController.php PHP Code: public function _remap($method, ...$params) { In CI 3 it works perfect but in CI 4 i have some problems... In CI3 $method from _remap is seo-url => the second element from uri_string In CI4 $method from _remap is index => the method from routes In CI3 $params from _remap is [param1, param2] In CI4 $params from _remap is [] If i use this $routes->add('p/(:any)', 'Post::index/$1'); i recive this params [index, param1, param2] in _remap The method index is not removed from params when use this $routes->add('p/(:any)', 'Post::index/$1'); How can i receive parameters without method in _remap when use routes ? I think this is a bug in CI 4 because: $routes->add('p/(:any)', 'Post::index'); This url ( site[.]com/p/seo-url/param1/param2/ ) will return this parameters [seo-url, param1, param2] => here the first element from parameters is the method This url ( site[.]com/post/seo-url/param1/param2/ ) will return this parameters [param1, param2] => here the method is removed from parameters
In CI 3 i use this _remap in MY_Controller and work perfectly for my app.
PHP Code: public function _remap($method, $params = array()) { For some days i try to find a good solution for this _remap in CI 4 for migrate my app to ci 4. Original url: site[.]com/post/seo-url/param1/param2 $routes->add('p(/.*)?', 'Post::index'); $routes->add('post(/.*)?', '404'); After route: site[.]com/p/seo-url/param1/param2 But in CI4 i received empty params after use this route in _remap In CI3 i received params without method and folders in _remap I need receive params without method and folders in CI 4 _remap. Can someone help me please ? Thank you!
This is my solution for CI 4. If someone have a good idea please tell me.
PHP Code: public function _remap($method, ...$params) { |
Welcome Guest, Not a member yet? Register Sign In |