$app['session']->getFlashBag()->add('success', 'L\'utilisateur a correctément été modifé'); } return $app['twig']->render('user_form.html.twig', array('level' => 2, 'title' => 'Modifier mon profil', 'userForm' => $userForm->createView())); })->bind('myprofile'); // Remove a user $app->match('/manage_users/{id}/delete', function ($id, Request $request) use($app) { $app['dao.user']->delete($id); $app['session']->getFlashBag()->add('success', 'The user was succesfully removed.'); // Redirect to admin home page return $app->redirect($app['url_generator']->generate('manage_users')); })->bind('manage_users_delete'); //Add a screen and display slides $app->match('/client', function (Request $request) use($app) { $screen = $app['dao.screen']->findByKey($request->server->get('REMOTE_ADDR')); if (is_null($screen)) { $screen = new Screen(); $screen->setKey($request->server->get('REMOTE_ADDR')); $screenForm = $app['form.factory']->create(new ScreenType(), $screen, array('groups' => $app['dao.screen_group']->findAll())); $screenForm->handleRequest($request); if ($screenForm->isSubmitted() && $screenForm->isValid()) { $app['dao.screen']->save($screen); return $app->redirect($request->getRequestUri()); } $screenFormView = $screenForm->createView(); return $app['twig']->render('client/new_client_form.html.twig', array('screenForm' => $screenFormView)); } else { $slides = $app['dao.slide']->findByScreen($screen->getId()); foreach ($slides as &$slide) { $slide->formatContent(); } return $app['twig']->render('client/display_screen_slides.html.twig', array('slides' => $slides));
public function save(Screen $screen) { $screenData = array('screen_key' => $screen->getKey(), 'screen_name' => $screen->getName(), 'screen_group_id' => !is_null($screen->getGroup()) ? $screen->getGroup()->getId() : null); //Si y'a déjà un id, donc déjà en base if ($screen->getId()) { $this->getDb()->update('screen', $screenData, array('screen_id' => $screen->getId())); } else { $this->getDb()->insert('screen', $screenData); $id = $this->getDb()->lastInsertId(); $screen->setId($id); } }