Reputation: 1541
I have problem in retrieving amount from database which is stored in encrypted format.So form defined is showing amount in encrypted format. So I wanted to decrypt amount using key in session in entity class where get method exists
public function getAmount()
{
$amount= $this->amount;
$request = Request::createFromGlobals();
$session=$this->container->getParameter('session');
//get key from session and
$rsa_object = new RSA();
$rsa_object->loadKey($session_pr_key);
if($amount!=null){
$base2Amount=hex2bin($amount);
$base10Amount=$rsa_object->decrypt($base2Amount);
}else{
$base10Amount=$base16Amount;
}
return $amount;
}
But I'm unable to get session. Any suggestions?
Upvotes: 0
Views: 1386
Reputation: 2597
You're doing it wrong. Your entity should just define the class without knowing anything about the container and the session. An entity is a Plain Old PHP Object (POPO). You should have a service or a decrypt object to which pass your entity and the session (or the needed value) and return what you're trying to do in your getAmount.
Upvotes: 1