/** * * @Route("/admin/account/role/update/{field}/{value}", name="admin_update_role") * @Template() */ public function updateAction($field, $value, Request $request) { $Object = $this->get('grid_factory')->LoadUpdate($request, array($value)); $Object->setThemes(array('form/fields.html.twig', 'ProshutUserBundle:Role/form:access.html.twig')); $Form = $Object->getForm(); if (!$Object->getEntity() || $Object->getEntity()->getParent() <= RoleRepository::getRoleLevel($this->getUser())) { return $this->redirect($this->get('grid_factory')->getRedirectPage()); } if ($Form->isValid()) { try { $Object->getEntityManager()->persist($Object->getEntity()); $Object->getEntityManager()->flush(); } catch (Exception $Error) { $Form->get('role')->addError(new FormError($this->get('translator')->trans('role.message.error.alias'))); return $Object->renderCRUDView(); } $this->get('grid_factory')->makeMessage($this->get('translator')->trans('role.message.success.update'), 'notice'); return $this->redirect($this->get('grid_factory')->getRedirectPage()); } return $Object->renderCRUDView(); }
public function search() { return $this->Container->get('doctrine')->getRepository('ProshutUserBundle:Role')->searchByPagination($this->Query['form']['query'], $this->Query['first'], $this->Query['item'], $this->Query['order'] ?: array('created', 'DESC'), RoleRepository::getRoleLevel($this->Container->get('security.token_storage')->getToken()->getUser())); }