1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- /*
- * This file is part of the Sonata Project package.
- *
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- namespace Sonata\UserBundle\Admin\Model;
- use Sonata\AdminBundle\Admin\AbstractAdmin;
- use Sonata\AdminBundle\Datagrid\DatagridMapper;
- use Sonata\AdminBundle\Datagrid\ListMapper;
- use Sonata\AdminBundle\Form\FormMapper;
- class GroupAdmin extends AbstractAdmin
- {
- /**
- * {@inheritdoc}
- */
- protected $formOptions = array(
- 'validation_groups' => 'Registration',
- );
- /**
- * {@inheritdoc}
- */
- public function getNewInstance()
- {
- $class = $this->getClass();
- return new $class('', array());
- }
- /**
- * {@inheritdoc}
- */
- protected function configureListFields(ListMapper $listMapper)
- {
- $listMapper
- ->addIdentifier('name')
- ->add('roles')
- ;
- }
- /**
- * {@inheritdoc}
- */
- protected function configureDatagridFilters(DatagridMapper $datagridMapper)
- {
- $datagridMapper
- ->add('name')
- ;
- }
- /**
- * {@inheritdoc}
- */
- protected function configureFormFields(FormMapper $formMapper)
- {
- // NEXT_MAJOR: Keep FQCN when bumping Symfony requirement to 2.8+.
- $securityRolesType = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
- ? 'Sonata\UserBundle\Form\Type\SecurityRolesType'
- : 'sonata_security_roles';
- $formMapper
- ->tab('Group')
- ->with('General', array('class' => 'col-md-6'))
- ->add('name')
- ->end()
- ->end()
- ->tab('Security')
- ->with('Roles', array('class' => 'col-md-12'))
- ->add('roles', $securityRolesType, array(
- 'expanded' => true,
- 'multiple' => true,
- 'required' => false,
- ))
- ->end()
- ->end()
- ;
- }
- }
|