GroupAdmin.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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\Entity;
  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. use Sonata\AdminBundle\Route\RouteCollection;
  16. class GroupAdmin extends Admin
  17. {
  18. protected $formOptions = array(
  19. 'validation_groups' => 'Registration'
  20. );
  21. public function getNewInstance()
  22. {
  23. $class = $this->getClass();
  24. return new $class('', array());
  25. }
  26. protected function configureListFields(ListMapper $listMapper)
  27. {
  28. $listMapper
  29. ->addIdentifier('name')
  30. ->add('roles')
  31. ;
  32. }
  33. protected function configureDatagridFilters(DatagridMapper $datagridMapper)
  34. {
  35. $datagridMapper
  36. ->add('name')
  37. ;
  38. }
  39. protected function configureFormFields(FormMapper $formMapper)
  40. {
  41. $formMapper
  42. ->add('name')
  43. ->add('roles', 'sonata_security_roles', array( 'multiple' => true, 'required' => false))
  44. ;
  45. }
  46. }