Add check for user class type for cv history #528
This commit is contained in:
parent
ba7948c507
commit
0ff930438b
1 changed files with 21 additions and 14 deletions
|
|
@ -12,6 +12,7 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInt
|
|||
|
||||
use App\Entity\CVWarrantyHistory;
|
||||
use App\Entity\CustomerVehicle;
|
||||
use App\Entity\User;
|
||||
|
||||
class CustomerVehicleSerialListener
|
||||
{
|
||||
|
|
@ -39,15 +40,18 @@ class CustomerVehicleSerialListener
|
|||
$user = $this->ts->getToken()->getUser();
|
||||
|
||||
// error_log('user - ' . $user->getID());
|
||||
// check if user is App\Entity\User
|
||||
if ($user instanceof App\Entity\User)
|
||||
{
|
||||
// add history
|
||||
$history = new CVWarrantyHistory();
|
||||
$history->setCVID($cv->getID())
|
||||
->setWarrantyCode($cv->getWarrantyCode())
|
||||
->setUser($user);
|
||||
$em->persist($history);
|
||||
|
||||
// add history
|
||||
$history = new CVWarrantyHistory();
|
||||
$history->setCVID($cv->getID())
|
||||
->setWarrantyCode($cv->getWarrantyCode())
|
||||
->setUser($user);
|
||||
$em->persist($history);
|
||||
|
||||
$this->history = $history;
|
||||
$this->history = $history;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -76,13 +80,16 @@ class CustomerVehicleSerialListener
|
|||
$warr_code = $cv->getWarrantyCode();
|
||||
|
||||
// add history
|
||||
$history = new CVWarrantyHistory();
|
||||
$history->setCVID($cv->getID())
|
||||
->setWarrantyCode($warr_code)
|
||||
->setUser($user);
|
||||
$em->persist($history);
|
||||
if ($user instanceof App\Entity\User)
|
||||
{
|
||||
$history = new CVWarrantyHistory();
|
||||
$history->setCVID($cv->getID())
|
||||
->setWarrantyCode($warr_code)
|
||||
->setUser($user);
|
||||
$em->persist($history);
|
||||
|
||||
$em->flush();
|
||||
$em->flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue