Welcome Guest, Not a member yet? Register   Sign In
Potential Bug Report: Presenter::show(id) Overwrites Custom Functions
#1

(This post was last modified: 06-12-2024, 02:35 AM by MZahov.)

When using CodeIgniter 4, the Presenter show(id) method appears to overwrite custom functions that I have added. This results in a 404 error when trying to access these functions, with the message:

Code:
{
    "status": 404,
    "error": 404,
    "messages": {
        "error": "Nothing found for customFunction1."
    }
}

However, if I configure the routes in Routes.php to exclude the show method using ['except' => 'show'], the custom functions work correctly.

PHP Code:
$routes->presenter('example', ['except' => 'show''filter'=> 'jwt''namespace' => '\App\Controllers\Api']);

$routes->group('example', ['filter'=>'jwt''namespace'=>'\App\Controllers\Api'], static function($routes) {
    $routes->get('customFunction1''Example::customFunction1');
    $routes->get('customFunction2''Example::customFunction2');

}); 

How to exclude only example/(;segment). So additional functions will not be overwritten. Any suggestions?

Code:
+--------+-------------------------+--------------------+--------------------------------------------------------------------+----------------+---------------+
| Method | Route                  | Name              | Handler                                                            | Before Filters | After Filters |
+--------+-------------------------+--------------------+--------------------------------------------------------------------+----------------+---------------+
| GET    | example/(.*)           | »                 | \App\Controllers\Api\Example::show/$1                              | jwt            | jwt           |



https://codeigniter.com/user_guide/incom...comparison
Reply
#2

Define the routes for the custom functions before calling the `$routes->presenter('example', ...)`.
Reply
#3

(06-12-2024, 02:47 AM)kenjis Wrote: Define the routes for the custom functions before calling the `$routes->presenter('example', ...)`.
Thanks. Feeling stupid that I didn't move it Smile
Reply




Theme © iAndrew 2016 - Forum software by © MyBB