1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| public function ajouterAction( ) {
$em = $this->getDoctrine();
$repo = $em->getRepository("UserBundle:User"); //Entity Repository
$user = $this->getUser();
if (!$user) {
throw new UsernameNotFoundException("User not found");
} else {
$token = new UsernamePasswordToken($user, null, "your_firewall_name", $user->getRoles());
$this->get("security.context")->setToken($token); //now the user is logged in
//now dispatch the login event
$request = $this->get("request");
$event = new InteractiveLoginEvent($request, $token);
$this->get("event_dispatcher")->dispatch("security.interactive_login", $event);
}
$msg = 'ajouter Apps';
$em = $this->getDoctrine()->getManager();
$app = new Apps();
$form = $this->createForm(new AppsType , $app);
$request = $this->getRequest();
if ($request->getMethod() == 'POST') {
$form->handleRequest($request);
$app->upload();
$em->persist($app);
$em->flush();
$msg = 'Apps ajouter avec success';
}
return $this->render('MedBundle:Apps:ajouter.html.twig',array(
'form'=>$form->createView(),
'msg'=>$msg
)
);
} |
Partager