GroupAdmin.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /*
  3. * This file is part of the Sonata package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Sonata\UserBundle\Admin\Model;
  11. use Sonata\AdminBundle\Admin\Admin;
  12. use Sonata\AdminBundle\Form\FormMapper;
  13. use Sonata\AdminBundle\Datagrid\DatagridMapper;
  14. use Sonata\AdminBundle\Datagrid\ListMapper;
  15. class GroupAdmin extends Admin
  16. {
  17. protected $formOptions = array(
  18. 'validation_groups' => 'Registration'
  19. );
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function getNewInstance()
  24. {
  25. $class = $this->getClass();
  26. return new $class('', array());
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. protected function configureListFields(ListMapper $listMapper)
  32. {
  33. $listMapper
  34. ->addIdentifier('name')
  35. ->add('roles')
  36. ;
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. protected function configureDatagridFilters(DatagridMapper $datagridMapper)
  42. {
  43. $datagridMapper
  44. ->add('name')
  45. ;
  46. }
  47. /**
  48. * {@inheritdoc}
  49. */
  50. protected function configureFormFields(FormMapper $formMapper)
  51. {
  52. $formMapper
  53. ->add('name')
  54. ->add('roles', 'sonata_security_roles', array(
  55. 'expanded' => true,
  56. 'multiple' => true,
  57. 'required' => false
  58. ))
  59. ;
  60. }
  61. }