Exemplo n.º 1
0
 /**
  * @Route("/role/{id}", requirements={"id"="\d+"}, name="admin_role_update", options={"expose"=true})
  * @ParamConverter("role", class="WoojinUserBundle:Role")
  * @Method("PUT")
  */
 public function updateAction(Request $request, Role $role)
 {
     $em = $this->getDoctrine()->getManager();
     $lists = $this->getList();
     $a = array();
     for ($i = 0; $i <= 53; $i++) {
         $a[] = null;
     }
     foreach ($lists as $key => $list) {
         $a[constant('Woojin\\UserBundle\\Entity\\Role::' . strtoupper($key))] = (int) $request->request->get(strtolower($key), 0);
     }
     $role->setChmod(implode('', $a));
     $em->persist($role);
     $em->flush();
     $session = $this->get('session');
     $session->getFlashBag()->add('success', $role->getName() . '權限修改完成');
     return $this->redirect($this->generateUrl('admin_role_edit', array('id' => $role->getId())));
 }