Welcome Guest, Not a member yet? Register   Sign In
Hooks
#1

[eluser]tomdelonge[/eluser]
I've never used hooks. I was wondering though. If I have a user gallery and when a user uploads a photo, I want to do several things to the photo. I want to put it on amazon s3 after several sizes of it have been made. Could I use the post_system hook to let the user go about their business after an image upload and have the system keep working on playing with the image? Is that a good idea or not.

Your thoughts...
#2

[eluser]xwero[/eluser]
It makes no sense. It doesn't matter if you put it in the controller or in the post_system hook the user will not notice. Technically using a hook is slower than putting the code in the controller as the hook file needs to be loaded too.

Hooks should be used for actions that happen on (nearly) all pages as they get executed on every request.

if you want to separate the amazon functionality, you could create a library you call whenever it's needed.
#3

[eluser]tomdelonge[/eluser]
This is what the user guide says in the hook section:

Code:
post_system
Called after the final rendered page is sent to the browser, at the end of system execution after the finalized data is sent to the browser.

Doesn't that mean the user will already be seeing the page but the script can keep going?
#4

[eluser]xwero[/eluser]
No because CI finishes when the front controller stops executing. If you look at the system/codeigniter/CodeIgniter.php file you see the guts of CI. It's nothing more than an inclusion of all the different files that generate a page, so as long the included files keep running nothing is going to be displayed.

What they meant in the user guide is that the content of the page is echoed already which makes it impossible to alter it using the post_system hook.




Theme © iAndrew 2016 - Forum software by © MyBB