O
O
Oleg Matrozov2012-04-18 14:35:30
Kohana
Oleg Matrozov, 2012-04-18 14:35:30

[Solved] Kohana 3 code execution on shutdown?

I'm just getting acquainted with the kohana, and therefore I may be asking stupidity.
It is necessary to execute some code at the moment the script ends, i.e. regardless of which controller was executed and whether it was executed at all. In Kohana 2.x, Event::add('system.shutdown', ...) was intended for this purpose, which allowed registering a custom event at the moment the kohana shuts down. In Kohana 3, I did not find anything like this. An attempt to use the standard for php register_shutdown_function failed, because by this time the kohana had time to clean up some of its classes, for example, remove Request:: $initial, etc. But they are needed for functionality.
The question is, is there a standard way for Kohana 3.x to execute its code after processing an arbitrary controller and before the kohana itself exits?
upd:Thank you all, in the end I decided to stop at redefining controller-> after.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
aktuba, 2012-04-18
@aktuba

Easy way: create a file application/kohana.php, in it:

class Kohana extends Kohana_Core{
    public static function shutdown_handler(){
        // тут делаете что хотите
        return parent::shutdown_handler();
    }
}

2. Another easy way:
github.com/synapsestudios/kohana-event-dispatcher
github.com/samsoir/kohana-event
github.com/thinkclay/Kohana-Event-Module
3. Hard way: google || yandex: (kohana 3 events) || (kohana 3 shutdown)

I
Ivan, 2012-04-23
@dohlik

I can suggest adding a handler call to the index.php file, right after Request::factory()->..;
Just what you need - the controller has worked, the framework has not closed yet.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question