From 678dfcc65d2ed061852c035f05a621e7f61795fd Mon Sep 17 00:00:00 2001 From: Kendrick Chan Date: Sun, 23 Aug 2020 01:26:19 +0800 Subject: [PATCH] Fix generate url inside rider api handler #472 --- src/Service/RiderAPIHandler/CMBRiderAPIHandler.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php b/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php index d7b97186..94c213f8 100644 --- a/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php +++ b/src/Service/RiderAPIHandler/CMBRiderAPIHandler.php @@ -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;