Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3925

Route redirecting in symfony

$
0
0

After i upgrading Symfony from 3.3 to 4.4.7 i'm facing an issue with routing. For example, i'm visiting a url like this abcd.com/secure-admin/subadmin-management it shows the correct page.But if we try to visit another url like this abcd.com/secure-admin/subadmin-management/add-subadmin the url will shown correctly in the address bar but the page showing is from the first url. This was working perfectly before upgrading. When i gone through the documentation of symfony they've mentioned that trouting functionality is changed. I tried to change according as per they mentioned but its not working. The code that i've tried.

class SubAdminListController extends Controller{    /**     * @Route("/subadmin-management/{c}", name="subadmin-listing",defaults={"c" = null})     * @Secure("has_role('ROLE_ADMIN') or has_role('ROLE_SUBADMIN')")     */    public function indexAction(Request $request,$c = null) /*abcd.com/secure-admin/subadmin-management*/    {        $user = $this->getUser();        $role = $user->getRoles();        $entityManager = $this->getDoctrine()->getManager();         $sql = "SELECT * FROM fos_user WHERE roles ='$role' ORDER BY id DESC";        $subadminlist = $entityManager->getConnection()->executeQuery($sql)->fetchAll();         $profileRepo = $this->getDoctrine()->getRepository('AdminBundle:DefaultImageSetting');                $userimage = $profileRepo->findOneBy(array("id" => '1'));        return $this->render('@AdminBundle/Admin/subadminmanage.html.twig',array('data' => $subadminlist,'counter'=>0,'userimage'=>$userimage,'added'=>$c));      }    /**    * @Route("/add-subadmin",name="subadmin")    */    public function addsubadminAction() /*abcd.com/secure-admin/subadmin-management/add-subadmin*/    {        $user = $this->getUser();        $role = $user->getRoles();        $profileRepo = $this->getDoctrine()->getRepository('UserBundle:User');        $user = $this->container->get('security.token_storage')->getToken()->getUser();        $userId = $user->getId();          $timezoneRepo = $this->getDoctrine()->getRepository('AdminBundle:Timezone');         $profile = $profileRepo->findOneBy(array("id" => $userId));        $timezone  = $timezoneRepo->findAll();        return $this->render('@AdminBundle/Admin/subadminprofile.html.twig',array('profile' =>$profile, 'timezone' =>$timezone));     }}

Viewing all articles
Browse latest Browse all 3925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>