core icon indicating copy to clipboard operation
core copied to clipboard

Notice: Event 'notFound' has been overridden!

Open samuel-bolle opened this issue 2 years ago • 5 comments

Hello,

First of all, thank you for taking such an active role in the project. It's very cool that new life has been breathed into it.

I have a problem. If I overwrite the "notFound" method via Map, as it is written in the docu (https://docs.flightphp.com/learn/extending), I get the error message "Notice: Event 'notFound' has been overridden!" which came in due to the changes for 3.4. Is this intentional? How should I proceed if I want to overwrite "notFound"? The error message breaks the output of the endpoint.

<?php
include './app/vendor/autoload.php';

Flight::map('notFound', function () {
    Flight::json([], 404);
});

Flight::route('/', function () {
    echo 'hello world!';
});

Flight::start();

samuel-bolle avatar Feb 09 '24 11:02 samuel-bolle

I have the same problem with Flight::map('error', ...) which is what the documentation says here: https://docs.flightphp.com/learn/configuration

neeo avatar Feb 09 '24 11:02 neeo

Thanks for reporting these things guys. We might have missed some test cases. I'll take a peek here in a minute and get back to you.

n0nag0n avatar Feb 09 '24 14:02 n0nag0n

You are right guys, it will be corrected in a few minutes, thanks for reporting.

fadrian06 avatar Feb 09 '24 14:02 fadrian06

This will be fixed with https://github.com/flightphp/core/pull/542, hopefully this will be merged and versioned in the next few hours.

n0nag0n avatar Feb 09 '24 15:02 n0nag0n