Fix generate url inside rider api handler #472

This commit is contained in:
Kendrick Chan 2020-08-23 01:26:19 +08:00
parent 01f5717c1c
commit 678dfcc65d

View file

@ -5,6 +5,7 @@ namespace App\Service\RiderAPIHandler;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use App\Ramcar\CMBServiceType;
use App\Ramcar\TradeInType;
@ -55,13 +56,15 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
protected $session;
protected $upload_dir;
protected $nm;
protected $router;
public function __construct(EntityManagerInterface $em, RedisClientProvider $redis,
EncoderFactoryInterface $ef, RiderCache $rcache,
string $country_code, MQTTClient $mclient,
WarrantyHandler $wh, JobOrderHandlerInterface $jo_handler,
InvoiceGeneratorInterface $ic, string $upload_dir,
RiderTracker $rider_tracker, NotificationManager $nm)
RiderTracker $rider_tracker, NotificationManager $nm,
UrlGeneratorInterface $router)
{
$this->em = $em;
$this->redis = $redis;
@ -75,6 +78,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
$this->upload_dir = $upload_dir;
$this->rider_tracker = $rider_tracker;
$this->nm = $nm;
$this->router = $router;
// one device = one session, since we have control over the devices
// when a rider logs in, we just change the rider assigned to the device
@ -1157,7 +1161,7 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
$this->mclient->publish($channel, $rider_status);
$notif_url = $this->generateUrl('jo_onestep_edit_form', ['id' => $jo->getID()]);
$notif_url = $this->router->generate('jo_onestep_edit_form', ['id' => $jo->getID()]);
$this->nm->sendNotification(0, 'Job order has been rejected by rider.', $notif_url);
return $data;