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/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Class Destructor usage in a Controller - can anyone see problems (/showthread.php?tid=35093)



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