loading my model to load_class |
10-31-2017, 10:31 PM
(This post was last modified: 11-01-2017, 01:11 AM by Vitaly83. Edit Reason: RE: ) (10-31-2017, 08:12 AM)dave friend Wrote: A workaround you can use is to name your file and class name using the subclass_prefix. I use to add prefix only for extended classes (like, libraries, core, helpers and etc.) and don't add prefix otherwise. Should I add prefix always? (10-31-2017, 09:18 AM)Narf Wrote: This is very common, both here and on StackOverflow ... People don't ask how to do a thing; they decide how they do it (usually the first idea that comes to mind) and then ask how to make that idea work, when it was never a good idea in the first place. Sorry, my mistake, you are absolutely right. Let me tell why I decided to use this function. I extended the Exception library to send emails on errors. Recipient(s) is(are) not a constant and can be get from a module (that I need to load). To load this module (and email library too) I need to get an CI instance ($CI =& get_instace()). Next, the CSRF Protection is turned on. In Input library constructor we can see this code: PHP Code: public function __construct() Then the Security library's method csrf_verify: PHP Code: public function csrf_verify() The csrf_show_error method just calls the show_error method of the Exception library. As I said before, I extended the Exception library and get $CI instance on every error. On POST requests with wrong csrf data I get such message: Quote:<br /> I just need to be notifed about errors. If you know how to do this another way it would be great. That's why I decided to not to use CI instance and load libraries and modules with load_class method. P.S. Most of these POST requests from outside (not initiated by system). And I need the CSRF Protection to be turned on. UPD: Here is MY_Exceptions class: PHP Code: class MY_Exceptions extends CI_Exceptions I overwrited standart Exceptions methods to just add call of the sendAdminEmail method. Nothing else. |
Messages In This Thread |
loading my model to load_class - by Vitaly83 - 10-31-2017, 06:57 AM
RE: loading my model to load_class - by dave friend - 10-31-2017, 08:12 AM
RE: loading my model to load_class - by Narf - 10-31-2017, 09:18 AM
RE: loading my model to load_class - by Vitaly83 - 10-31-2017, 10:31 PM
RE: loading my model to load_class - by dave friend - 11-01-2017, 09:45 PM
RE: loading my model to load_class - by Narf - 11-01-2017, 05:05 AM
RE: loading my model to load_class - by Vitaly83 - 11-01-2017, 05:51 AM
RE: loading my model to load_class - by Vitaly83 - 11-02-2017, 02:30 AM
RE: loading my model to load_class - by Narf - 11-02-2017, 03:38 AM
RE: loading my model to load_class - by Vitaly83 - 11-02-2017, 04:12 AM
RE: loading my model to load_class - by Narf - 11-02-2017, 06:15 AM
RE: loading my model to load_class - by Vitaly83 - 11-02-2017, 07:30 AM
|