php - generate sha1 field for entity symfony2 -


my entity card has fields: id, code , token. 2 points:

1) need generate 'code' this:

 ...  public function __construct(){     $date = new \datetime();     $year = $date->format('y');     $month = $date->format('m');     $this->codigo = $year . $month . ($this->id + 150);  } 

but id return 0; try use lifecyclecallbacks. not works.

2) need generate 1 secure token 5 digits. this:

$this->token = mt_rand(11111,99999); 

but how save in database (with sha1 encoder) , retrieve decrypted.

i'm using symfony2.2.

all objects card generated in administration. need populate database 2000 cards.

thank all


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -