<?php
namespace App\Form\Forms\Security\Profile;
use App\Entity\System\School;
use App\Form\Type\Select2EntityType;
use Doctrine\ORM\EntityRepository;
use Platform\SecurityBundle\Entity\Access\Role;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\NotNull;
class SchoolRoleType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('school', Select2EntityType::class, [
'required' => false,
'label_tooltip' => true,
'placeholder' => '[Global]',
'class' => School::class,
'empty_data' => null,
'choice_label' => 'name',
'query_builder' => function (EntityRepository $repo) {
return $repo
->createQueryBuilder('school')
->addOrderBy('school.name', 'ASC');
},
]);
}
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'class' => Role\NotificationRole::class,
]);
}
/**
* {@inheritdoc}
*/
public function getParent(): string
{
return RoleType::class;
}
}