CodeIgniter Forums
Class Destructor usage in a Controller - can anyone see problems - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Class Destructor usage in a Controller - can anyone see problems (/thread-35093.html)



Class Destructor usage in a Controller - can anyone see problems - El Forum - 10-19-2010

[eluser]jdav3579[/eluser]
Hi,

I have code that is repeated of loading a frame view or wrapper view at the end of each controller method which is passed the data for the page.

I want to define page content in a variable by each controller and then write a single destructor that will just load the appropriate wrapper view and put the data in it.
Can anyone see a problem with doing this? I currently define the data as a constant and use a hook to put the data in.

I would also prefer if the above is possible to put it all into a MY_Controller, so the code is written once for all constructors that extend the class.

Is this possible /Wise?

Cheers
John