cakephp where to write custom functions -


i working on cakephp 2.3 ..in modals doing encryption decryption in these 2 functions beforesave , afterfind .. again , again have write

  security::rijndael($text, configure::read('constants.crypt_key'), 'encrypt'); 

so decided make function have done this

static public function encrypt($text) {     return security::rijndael($text, configure::read('constants.crypt_key'), 'encrypt'); }    static public function decrypt($text) {     return security::rijndael($text), configure::read('constants.crypt_key'), 'decrypt'); } 

but want know should write these function.. should in app/lib/utility or app/vendors directory , after suggesting, tell me how can access function in model ..how can import class in model..thanks in advance

it depends want calling them from. if you're calling them model (which think makes sense in case), should place them in appmodel.php, models inherit from.

however, having seen previous question, if you're having write encrypt/decrypt function "again , again", you're not designing app well.

really, should need call encrypt once, in beforesave, , decrypt once, in afterfind. if have call them in 1 or 2 other places... ok. if you're having call them on place, you're going things wrong way.

and also, there should no need make static function.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -