My Entity Card has fields: id, code and token. Two points:
1) I need to generate 'code' with something like this:
 ...
 public function __construct(){
    $date = new \DateTime();
    $year = $date->format('Y');
    $month = $date->format('m');
    $this->codigo = $year . $month . ($this->id + 150);
 }
But Id always return 0; I try to use LifeCycleCallBacks. But not works.
2) I need too generate one secure token with 5 digits. Like this:
$this->token = mt_rand(11111,99999);
But how to save it in the database (with sha1 encoder) and retrieve it decrypted.
I'm using Symfony2.2.
All my objects Card will be generated in administration. I need to populate the database with 2000 Cards.
Thank you all
