How can find closures and defines of them?

I am not understand triggers : )
an example. i have trigger he calls ‘cockpit.media.removefiles’

I have searched all the files of the Cocopit globally and at no point found a mapping between the key and the closure. I do not understand in many places the states of the application. I don’t understand which function calls e.g. the ‘call_user_func_array($this->events[$event][$index][‘fn’], $params)’.

where is the value(close) of the key-val-pair? ‘$this->events[$event]’

when i use my debugger, i can see that something exists as a functinon, but neither what exactly, nor from where.

Bildschirmfoto 2022-02-16 um 11.21.10

how do i know what is happening, where is this function coming from and how can i trace this as a developer?

How can I approach this problem?

Translated with www.DeepL.com/Translator (free version)

Triggers are there to call closures that can be attached hook-like from everywhere within cockpit (modules, core, plugins/addons).

So there may be dozens of spots which hook an event (for example like this ->on('some.event')) and will be notified by cockpit as soon as this event happens.

Lets get more concrete:

Here is a list of events that are ‘triggered’ by cockpit:

For example ‘collections.find.before’ is triggered by cockpit before the ‘find’ method on the collection module is called (for example through an api call or through the usage of the local api)

You could now for example write an addon that does something like this:

...->on('collections.find.before', function() {
  die('Only the chosen one may find...');
})

which would prevent the find method to ever happen because that code snippet would quit the execution of the script before the find method can be called.
Everything else which does not trigger ‘collections.find.before’ would work.

You can find more information on the events (tirgger / on) here: