Merge branch '528-app-cannot-add-customer-vehicle' into 'master'
Add check for user class type for cv history #528 Closes #528 See merge request jankstudio/resq!613
This commit is contained in:
commit
83e5ea3810
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\CVWarrantyHistory;
|
||||||
use App\Entity\CustomerVehicle;
|
use App\Entity\CustomerVehicle;
|
||||||
|
use App\Entity\User;
|
||||||
|
|
||||||
class CustomerVehicleSerialListener
|
class CustomerVehicleSerialListener
|
||||||
{
|
{
|
||||||
|
|
@ -39,7 +40,9 @@ class CustomerVehicleSerialListener
|
||||||
$user = $this->ts->getToken()->getUser();
|
$user = $this->ts->getToken()->getUser();
|
||||||
|
|
||||||
// error_log('user - ' . $user->getID());
|
// error_log('user - ' . $user->getID());
|
||||||
|
// check if user is App\Entity\User
|
||||||
|
if ($user instanceof App\Entity\User)
|
||||||
|
{
|
||||||
// add history
|
// add history
|
||||||
$history = new CVWarrantyHistory();
|
$history = new CVWarrantyHistory();
|
||||||
$history->setCVID($cv->getID())
|
$history->setCVID($cv->getID())
|
||||||
|
|
@ -50,6 +53,7 @@ class CustomerVehicleSerialListener
|
||||||
$this->history = $history;
|
$this->history = $history;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function postUpdate(CustomerVehicle $cv, LifecycleEventArgs $args)
|
public function postUpdate(CustomerVehicle $cv, LifecycleEventArgs $args)
|
||||||
{
|
{
|
||||||
|
|
@ -76,6 +80,8 @@ class CustomerVehicleSerialListener
|
||||||
$warr_code = $cv->getWarrantyCode();
|
$warr_code = $cv->getWarrantyCode();
|
||||||
|
|
||||||
// add history
|
// add history
|
||||||
|
if ($user instanceof App\Entity\User)
|
||||||
|
{
|
||||||
$history = new CVWarrantyHistory();
|
$history = new CVWarrantyHistory();
|
||||||
$history->setCVID($cv->getID())
|
$history->setCVID($cv->getID())
|
||||||
->setWarrantyCode($warr_code)
|
->setWarrantyCode($warr_code)
|
||||||
|
|
@ -85,4 +91,5 @@ class CustomerVehicleSerialListener
|
||||||
$em->flush();
|
$em->flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue