public function routeAction(Request $request) { $id = $request->getSession()->get('userId'); $user = new User(); $user->load($id); if (!$user->getPatientId()) { $user->transfer(); } return $this->redirectToRoute('patient_homepage', array('id' => $user->getPatientId())); }