V-Beta-1.0.0
Vision is out of alpha !
This commit is contained in:
43
src/Form/AdminGroupType.php
Normal file
43
src/Form/AdminGroupType.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Group;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Vich\UploaderBundle\Form\Type\VichImageType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
|
||||
class AdminGroupType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('name', null, ['label' => 'form_label_name'])
|
||||
->add('shortName', null, ['label' => 'form_label_shortname'])
|
||||
->add('imageFile', VichImageType::class, [
|
||||
'required' => false,
|
||||
'label' => 'form_label_group_logo',
|
||||
'allow_delete' => true,
|
||||
'delete_label' => 'form_label_remove_image',
|
||||
'download_label' => 'form_label_download_image',
|
||||
'download_uri' => false,
|
||||
'image_uri' => false,
|
||||
'asset_helper' => true,
|
||||
])
|
||||
->add('motd', null, ['label' => 'form_label_motd','attr' => ['style' => 'height: 400px;']])
|
||||
->add('submit', SubmitType::class, [
|
||||
'label' => 'form_button_submit',
|
||||
'attr' => ['class' => 'btn-primary'],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Group::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
36
src/Form/AdminRankType.php
Normal file
36
src/Form/AdminRankType.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Rank;
|
||||
use App\Form\Type\PermissionsType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
|
||||
class AdminRankType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
||||
|
||||
$builder
|
||||
->add('name', null, ['label' => 'form_label_name'])
|
||||
->add('shortname', null, ['label' => 'form_label_shortname'])
|
||||
->add('power', null, ['label' => 'form_label_power', 'help' => 'form_help_power'])
|
||||
->add('permissions', PermissionsType::class)
|
||||
->add('submit', SubmitType::class, [
|
||||
'label' => 'form_button_submit',
|
||||
'attr' => ['class' => 'btn-primary'],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Rank::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
33
src/Form/AdminSubGroupType.php
Normal file
33
src/Form/AdminSubGroupType.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\SubGroup;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
|
||||
class AdminSubGroupType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
||||
|
||||
$builder
|
||||
->add('name', null, ['label' => 'form_label_name'])
|
||||
->add('shortname', null, ['label' => 'form_label_shortname'])
|
||||
->add('submit', SubmitType::class, [
|
||||
'label' => 'form_button_submit',
|
||||
'attr' => ['class' => 'btn-primary'],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => SubGroup::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
106
src/Form/AdminUserType.php
Normal file
106
src/Form/AdminUserType.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Rank;
|
||||
use App\Entity\User;
|
||||
use App\Entity\SubGroup;
|
||||
use App\Form\Type\PhoneType;
|
||||
use App\Form\Type\LastnameType;
|
||||
use App\Form\Type\FirstnameType;
|
||||
use App\Repository\RankRepository;
|
||||
use App\Repository\SubGroupRepository;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
|
||||
class AdminUserType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
||||
/**
|
||||
* @var User $User
|
||||
*/
|
||||
$User = $builder->getData();
|
||||
$UserGroup = $User->getMainGroup();
|
||||
|
||||
$builder
|
||||
->add('email', null, ['label' => 'form_label_email'])
|
||||
->add('firstname', FirstnameType::class)
|
||||
->add('lastname', LastnameType::class)
|
||||
->add('phone', PhoneType::class)
|
||||
->add('mainRank', EntityType::class, [
|
||||
'class' => Rank::class,
|
||||
'query_builder' => function (RankRepository $RankRepository) {
|
||||
return $RankRepository->createQueryBuilder('r')
|
||||
->orderBy('r.power', 'DESC');
|
||||
},
|
||||
'choice_label' => 'name',
|
||||
'label' => 'form_label_group_and_rank',
|
||||
'required' => false,
|
||||
'group_by' => function ($choice, $key, $value) {
|
||||
return $choice->getMainGroup()->getName();
|
||||
},
|
||||
]);
|
||||
|
||||
if (!$UserGroup->getSubGroups()->isEmpty()) {
|
||||
$builder
|
||||
->add('subGroups', EntityType::class, [
|
||||
'class' => SubGroup::class,
|
||||
'query_builder' => function (SubGroupRepository $SubGroupRepository) use ($UserGroup) {
|
||||
return $SubGroupRepository->createQueryBuilder('sg')
|
||||
->where('sg.mainGroup =' . $UserGroup->getId())
|
||||
;
|
||||
},
|
||||
'choice_label' => 'name',
|
||||
'label' => 'form_label_subgroups',
|
||||
'required' => false,
|
||||
'multiple' => true,
|
||||
'expanded' => true
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$builder
|
||||
->add('roles', ChoiceType::class, [
|
||||
'choices' => [
|
||||
'form_choice_admin' => 'ROLE_ADMIN'
|
||||
],
|
||||
'expanded' => true,
|
||||
'multiple' => true,
|
||||
'label' => 'form_label_roles',
|
||||
])
|
||||
->add('isVerified', CheckboxType::class, [
|
||||
'label' => 'form_label_checkbox_isverified',
|
||||
'help' => 'form_help_checkbox_isverified',
|
||||
'required' => false
|
||||
])
|
||||
->add('isDesactivated', CheckboxType::class, [
|
||||
'label' => 'form_label_checkbox_isdesactivated',
|
||||
'help' => 'form_help_checkbox_isdesactivated',
|
||||
'required' => false
|
||||
])
|
||||
->add('adminMode', CheckboxType::class, [
|
||||
'label' => 'form_label_checkbox_adminmode',
|
||||
'help' => 'form_help_checkbox_adminmode',
|
||||
'required' => false
|
||||
])
|
||||
->add('submit', SubmitType::class, [
|
||||
'label' => 'form_button_submit',
|
||||
'attr' => ['class' => 'btn-primary'],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => User::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
27
src/Form/AnnounceType.php
Normal file
27
src/Form/AnnounceType.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Announce;
|
||||
use App\Form\Type\ContentType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class AnnounceType extends DocumentType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
parent::buildForm($builder, $options);
|
||||
|
||||
$builder
|
||||
->add('content', ContentType::class)
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Announce::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
46
src/Form/AuthenticateType.php
Normal file
46
src/Form/AuthenticateType.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\User;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
|
||||
class AuthenticateType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('email', EmailType::class, [
|
||||
'label' => false,
|
||||
'attr' => ['placeholder' => 'form_label_email'],
|
||||
])
|
||||
->add('password', PasswordType::class, [
|
||||
'label' => false,
|
||||
'attr' => ['placeholder' => 'form_label_password'],
|
||||
])
|
||||
->add('submit', SubmitType::class, [
|
||||
'label' => 'form_button_login',
|
||||
'attr' => ['class' => 'btn-primary'],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => User::class,
|
||||
'csrf_field_name' => '_csrf_token',
|
||||
'csrf_token_id' => 'authenticate'
|
||||
]);
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return ''; // return an empty string here
|
||||
}
|
||||
}
|
||||
25
src/Form/BraceletType.php
Normal file
25
src/Form/BraceletType.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Bracelet;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class BraceletType extends DocumentType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
parent::buildForm($builder, $options);
|
||||
$builder
|
||||
->add('removingDate', null, ['label' => 'form_label_removing_date'])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Bracelet::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
27
src/Form/CertificateType.php
Normal file
27
src/Form/CertificateType.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Form\DocumentType;
|
||||
use App\Entity\Certificate;
|
||||
use App\Form\Type\ContentType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class CertificateType extends DocumentType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
parent::buildForm($builder, $options);
|
||||
|
||||
$builder
|
||||
->add('content', ContentType::class) ;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Certificate::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
56
src/Form/ChangePasswordFormType.php
Normal file
56
src/Form/ChangePasswordFormType.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
|
||||
class ChangePasswordFormType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('plainPassword', RepeatedType::class, [
|
||||
'type' => PasswordType::class,
|
||||
'first_options' => [
|
||||
'attr' => ['autocomplete' => 'new-password'],
|
||||
'constraints' => [
|
||||
new NotBlank([
|
||||
'message' => 'form_constraint_please_enter_password',
|
||||
]),
|
||||
new Length([
|
||||
'min' => 6,
|
||||
'minMessage' => 'form_constraint_password_min_lenght_6_cars',
|
||||
// max length allowed by Symfony for security reasons
|
||||
'max' => 4096,
|
||||
]),
|
||||
],
|
||||
'label' => 'New password',
|
||||
],
|
||||
'second_options' => [
|
||||
'attr' => ['autocomplete' => 'new-password'],
|
||||
'label' => 'Repeat Password',
|
||||
],
|
||||
'invalid_message' => 'form_constraint_password_mismatch',
|
||||
// Instead of being set onto the object directly,
|
||||
// this is read and encoded in the controller
|
||||
'mapped' => false,
|
||||
])
|
||||
->add('submit', SubmitType::class, [
|
||||
'label' => 'form_button_submit',
|
||||
'attr' => ['class' => 'btn-primary'],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([]);
|
||||
}
|
||||
}
|
||||
31
src/Form/CommentType.php
Normal file
31
src/Form/CommentType.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Comment;
|
||||
use App\Form\Type\ContentType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
|
||||
class CommentType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('content', ContentType::class)
|
||||
->add('submit', SubmitType::class, [
|
||||
'label' => 'form_button_submit',
|
||||
'attr' => ['class' => 'btn-primary'],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Comment::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
40
src/Form/ComplaintType.php
Normal file
40
src/Form/ComplaintType.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Complaint;
|
||||
use App\Form\DocumentType;
|
||||
use App\Form\Type\ContentType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
|
||||
class ComplaintType extends DocumentType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
parent::buildForm($builder, $options);
|
||||
|
||||
$builder
|
||||
->add('versus', null, ['label' => 'form_label_versus', 'help' => 'form_help_versus'])
|
||||
->add('content', ContentType::class)
|
||||
->add('status', ChoiceType::class, [
|
||||
'choices' => [
|
||||
'form_choice_complaint_status_inprogress' => 'form_choice_complaint_status_inprogress',
|
||||
'form_choice_complaint_status_waiting' => 'form_choice_complaint_status_waiting',
|
||||
'form_choice_complaint_status_ended' => 'form_choice_complaint_status_ended',
|
||||
'form_choice_complaint_status_discontinued' => 'form_choice_complaint_status_discontinued',
|
||||
],
|
||||
'label' => 'form_label_complaint_status',
|
||||
'priority' => -800
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Complaint::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
42
src/Form/CriminalType.php
Normal file
42
src/Form/CriminalType.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Criminal;
|
||||
use App\Form\DocumentType;
|
||||
use App\Form\Type\ContentType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class CriminalType extends DocumentType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
|
||||
parent::buildForm($builder, $options);
|
||||
|
||||
$builder
|
||||
|
||||
->add('article', null, ['label' => 'form_label_article', 'help' => 'form_help_article'])
|
||||
->add('amountMoney', null, ['label' => 'form_label_amount', 'help' => 'form_help_amount'])
|
||||
->add('amountTime', null, ['label' => 'form_label_time', 'help' => 'form_help_time'])
|
||||
->add(
|
||||
'accessorySentence',
|
||||
ContentType::class,
|
||||
['label' => 'form_label_accessorySentence',
|
||||
'help' => 'form_help_accessorySentence',
|
||||
'required' => false,
|
||||
'attr' => ['style' => 'height: 200px;']
|
||||
]
|
||||
)
|
||||
->add('content', ContentType::class, ['label' => 'form_label_informations', 'required' => false ])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Criminal::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
224
src/Form/DirectoryType.php
Normal file
224
src/Form/DirectoryType.php
Normal file
@@ -0,0 +1,224 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Directory;
|
||||
use App\Form\Type\PhoneType;
|
||||
use App\Form\Type\GenderType;
|
||||
use App\Form\Type\HeightType;
|
||||
use App\Form\Type\WeightType;
|
||||
use App\Form\Type\AddressType;
|
||||
use App\Form\Type\ContentType;
|
||||
use App\Form\Type\GangListType;
|
||||
use App\Form\Type\LastnameType;
|
||||
use App\Form\Type\FirstnameType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Vich\UploaderBundle\Form\Type\VichImageType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\BirthdayType;
|
||||
|
||||
class DirectoryType extends AbstractType
|
||||
{
|
||||
private $security;
|
||||
|
||||
public function __construct(Security $security)
|
||||
{
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
||||
/**
|
||||
* @var User $user
|
||||
*/
|
||||
$user = $this->security->getUser();
|
||||
$userPermissions = array_map('strtolower', $user->getMainRank()->getPermissions());
|
||||
|
||||
$builder
|
||||
->add('firstname', FirstnameType::class)
|
||||
->add('lastname', LastnameType::class)
|
||||
->add('gender', GenderType::class)
|
||||
->add(
|
||||
'birthdate',
|
||||
BirthdayType::class,
|
||||
[
|
||||
'label' => 'form_label_birthday',
|
||||
'placeholder' => [
|
||||
'year' => 'Year', 'month' => 'Month', 'day' => 'Day',
|
||||
],
|
||||
'required' => false
|
||||
]
|
||||
)
|
||||
->add('phone', PhoneType::class)
|
||||
->add('height', HeightType::class)
|
||||
->add('weight', WeightType::class)
|
||||
->add('address', AddressType::class, ['required' => false])
|
||||
;
|
||||
|
||||
if ($user->getAdminMode() || in_array('general_legal_view', $userPermissions)) {
|
||||
$builder
|
||||
->add('gang', GangListType::class)
|
||||
->add('wanted', null, ['label' => 'form_label_wanted'])
|
||||
->add('wantedReason', null, ['label' => 'form_label_wantedReason', 'help' => 'form_help_wantedReason'])
|
||||
;
|
||||
}
|
||||
|
||||
if ($user->getAdminMode() || in_array('general_medical_view', $userPermissions)) {
|
||||
$builder
|
||||
->add('dead', null, ['label' => 'form_label_dead', 'help' => 'form_help_wanted'])
|
||||
->add(
|
||||
'medicalFamilyHistory',
|
||||
ContentType::class,
|
||||
['label' => 'form_label_medical_family_history',
|
||||
'help' => 'form_help_medical_family_history',
|
||||
'required' => false,
|
||||
'attr' => ['style' => 'height: 400px;']
|
||||
]
|
||||
)
|
||||
->add(
|
||||
'medicalHistory',
|
||||
ContentType::class,
|
||||
['label' => 'form_label_medical_history', 'help' => 'form_help_medical_history',
|
||||
'required' => false,
|
||||
'attr' => ['style' => 'height: 400px;']
|
||||
]
|
||||
)
|
||||
->add(
|
||||
'medicalAllergies',
|
||||
ContentType::class,
|
||||
['label' => 'form_label_medical_allergies', 'help' => 'form_help_medical_allergies',
|
||||
'required' => false,
|
||||
'attr' => ['style' => 'height: 400px;']
|
||||
]
|
||||
)
|
||||
->add(
|
||||
'medicalBloodGroup',
|
||||
null,
|
||||
['label' => 'form_label_medical_blood_group', 'help' => 'form_help_medical_blood_group',
|
||||
'required' => false
|
||||
]
|
||||
)
|
||||
->add(
|
||||
'medicalDrugs',
|
||||
ContentType::class,
|
||||
['label' => 'form_label_medical_drugs', 'help' => 'form_help_medical_drugs',
|
||||
'required' => false,
|
||||
'attr' => ['style' => 'height: 400px;']
|
||||
]
|
||||
)
|
||||
->add(
|
||||
'medicalAlcohol',
|
||||
ContentType::class,
|
||||
['label' => 'form_label_medical_alcohol', 'help' => 'form_help_medical_alcohol',
|
||||
'required' => false,
|
||||
'attr' => ['style' => 'height: 400px;']
|
||||
]
|
||||
)
|
||||
->add(
|
||||
'medicalTreatment',
|
||||
ContentType::class,
|
||||
['label' => 'form_label_medical_treatment','help' => 'form_help_medical_treatment',
|
||||
'required' => false,
|
||||
'attr' => ['style' => 'height: 400px;']
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($user->getAdminMode() || in_array('general_legal_view', $userPermissions)) {
|
||||
$builder->add('faceImageFile', VichImageType::class, [
|
||||
'required' => false,
|
||||
'allow_delete' => false,
|
||||
'download_uri' => false,
|
||||
'image_uri' => false,
|
||||
'asset_helper' => true,
|
||||
'label' => 'form_label_upload_facepicture'
|
||||
])
|
||||
->add('backImageFile', VichImageType::class, [
|
||||
'required' => false,
|
||||
'allow_delete' => false,
|
||||
'download_uri' => false,
|
||||
'image_uri' => false,
|
||||
'asset_helper' => true,
|
||||
'label' => 'form_label_upload_backpicture'
|
||||
])
|
||||
->add('leftImageFile', VichImageType::class, [
|
||||
'required' => false,
|
||||
'allow_delete' => false,
|
||||
'download_uri' => false,
|
||||
'image_uri' => false,
|
||||
'asset_helper' => true,
|
||||
'label' => 'form_label_upload_leftpicture'
|
||||
])
|
||||
->add('rightImageFile', VichImageType::class, [
|
||||
'required' => false,
|
||||
'allow_delete' => false,
|
||||
'download_uri' => false,
|
||||
'image_uri' => false,
|
||||
'asset_helper' => true,
|
||||
'label' => 'form_label_upload_rightpicture'
|
||||
]);
|
||||
}
|
||||
|
||||
$builder
|
||||
|
||||
|
||||
->add('idCardImageFile', VichImageType::class, [
|
||||
'required' => false,
|
||||
'allow_delete' => false,
|
||||
'download_uri' => false,
|
||||
'image_uri' => false,
|
||||
'asset_helper' => true,
|
||||
'label' => 'form_label_upload_idcard'
|
||||
])
|
||||
->add('carLicenceImageFile', VichImageType::class, [
|
||||
'required' => false,
|
||||
'allow_delete' => false,
|
||||
'download_uri' => false,
|
||||
'image_uri' => false,
|
||||
'asset_helper' => true,
|
||||
'label' => 'form_label_upload_carlicence'
|
||||
])
|
||||
->add('motorcycleLicenceImageFile', VichImageType::class, [
|
||||
'required' => false,
|
||||
'allow_delete' => false,
|
||||
'download_uri' => false,
|
||||
'image_uri' => false,
|
||||
'asset_helper' => true,
|
||||
'label' => 'form_label_upload_motorcyclelicence'
|
||||
])
|
||||
->add('truckLicenceImageFile', VichImageType::class, [
|
||||
'required' => false,
|
||||
'allow_delete' => false,
|
||||
'download_uri' => false,
|
||||
'image_uri' => false,
|
||||
'asset_helper' => true,
|
||||
'label' => 'form_label_upload_trucklicence'
|
||||
])
|
||||
->add('boatLicenceImageFile', VichImageType::class, [
|
||||
'required' => false,
|
||||
'allow_delete' => false,
|
||||
'download_uri' => false,
|
||||
'image_uri' => false,
|
||||
'asset_helper' => true,
|
||||
'label' => 'form_label_upload_boatlicence'
|
||||
])
|
||||
->add('submit', SubmitType::class, [
|
||||
'label' => 'form_button_submit',
|
||||
'attr' => ['class' => 'btn-primary'],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Directory::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
90
src/Form/DocumentType.php
Normal file
90
src/Form/DocumentType.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Document;
|
||||
use App\Form\Type\AllowedGroupsType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use App\Form\Type\UserGroupSubGroupsType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
|
||||
class DocumentType extends AbstractType
|
||||
{
|
||||
private TokenStorageInterface $TokenStorage;
|
||||
|
||||
public function __construct(TokenStorageInterface $TokenStorage)
|
||||
{
|
||||
$this->TokenStorage = $TokenStorage;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
/**
|
||||
* @var Document $Document
|
||||
*/
|
||||
$Document = $builder->getData();
|
||||
|
||||
/**
|
||||
* @var User $User
|
||||
*/
|
||||
$User = $this->TokenStorage->getToken()->getUser();
|
||||
|
||||
$builder
|
||||
->add('title', null, [
|
||||
'label' => 'form_label_title',
|
||||
'priority' => 999
|
||||
]);
|
||||
|
||||
if (!$Document->getIsPublic()) {
|
||||
if ($Document->getMainGroup() == $User->getMainGroup()) {
|
||||
$builder
|
||||
->add(
|
||||
'allowedGroups',
|
||||
AllowedGroupsType::class,
|
||||
[
|
||||
'priority' => -900,
|
||||
]
|
||||
)
|
||||
->add(
|
||||
'allowedSubGroups',
|
||||
UserGroupSubGroupsType::class,
|
||||
[
|
||||
'priority' => -900
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$builder
|
||||
->add(
|
||||
'allowShare',
|
||||
null,
|
||||
[
|
||||
'priority' => -900,
|
||||
'label' => 'form_label_allowShare'
|
||||
]
|
||||
)
|
||||
->add('submit', SubmitType::class, [
|
||||
'label' => 'form_button_submit',
|
||||
'priority' => -900,
|
||||
'attr' => ['class' => 'btn-primary'],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Document::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
79
src/Form/EmployeeType.php
Normal file
79
src/Form/EmployeeType.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Rank;
|
||||
use App\Entity\SubGroup;
|
||||
use App\Entity\User;
|
||||
use App\Form\Type\PhoneType;
|
||||
use App\Repository\RankRepository;
|
||||
use App\Repository\SubGroupRepository;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
|
||||
class EmployeeType extends AbstractType
|
||||
{
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(TranslatorInterface $translator)
|
||||
{
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
|
||||
/**
|
||||
* @var User $User
|
||||
*/
|
||||
$User = $builder->getData();
|
||||
$UserGroup = $User->getMainGroup();
|
||||
|
||||
$builder
|
||||
->add('phone', PhoneType::class)
|
||||
->add('mainRank', EntityType::class, [
|
||||
'class' => Rank::class,
|
||||
'query_builder' => function (RankRepository $RankRepository) use ($UserGroup) {
|
||||
return $RankRepository->createQueryBuilder('r')
|
||||
->where('r.mainGroup =' . $UserGroup->getId())
|
||||
->orderBy('r.power', 'DESC');
|
||||
},
|
||||
'choice_label' => 'name',
|
||||
'label' => 'form_label_rank',
|
||||
'placeholder' => $this->translator->trans('form_placeholder_group_and_rank'),
|
||||
'required' => false,
|
||||
'expanded' => true
|
||||
])
|
||||
|
||||
->add('subGroups', EntityType::class, [
|
||||
'class' => SubGroup::class,
|
||||
'query_builder' => function (SubGroupRepository $SubGroupRepository) use ($UserGroup) {
|
||||
return $SubGroupRepository->createQueryBuilder('sg')
|
||||
->where('sg.mainGroup =' . $UserGroup->getId())
|
||||
;
|
||||
},
|
||||
'choice_label' => 'name',
|
||||
'label' => 'form_label_subgroups',
|
||||
'required' => false,
|
||||
'multiple' => true,
|
||||
'expanded' => true
|
||||
])
|
||||
|
||||
->add('submit', SubmitType::class, [
|
||||
'label' => 'form_button_submit',
|
||||
'attr' => ['class' => 'btn-primary'],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => User::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
28
src/Form/FolderType.php
Normal file
28
src/Form/FolderType.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Folder;
|
||||
use App\Form\DocumentType;
|
||||
use App\Form\Type\ContentType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class FolderType extends DocumentType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
parent::buildForm($builder, $options);
|
||||
|
||||
$builder
|
||||
->add('content', ContentType::class, ['required' => false])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Folder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
34
src/Form/GangType.php
Normal file
34
src/Form/GangType.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Gang;
|
||||
use App\Form\DocumentType;
|
||||
use App\Form\Type\ContentType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class GangType extends DocumentType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
|
||||
parent::buildForm($builder, $options);
|
||||
$builder
|
||||
->add(
|
||||
'content',
|
||||
ContentType::class,
|
||||
['label' => 'form_label_informations',
|
||||
'required' => false,
|
||||
]
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Gang::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
28
src/Form/InfringementType.php
Normal file
28
src/Form/InfringementType.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Form\DocumentType;
|
||||
use App\Entity\Infringement;
|
||||
use App\Form\Type\ContentType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class InfringementType extends DocumentType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
parent::buildForm($builder, $options);
|
||||
|
||||
$builder
|
||||
->add('content', ContentType::class)
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Infringement::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
33
src/Form/JailType.php
Normal file
33
src/Form/JailType.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Jail;
|
||||
use App\Form\DocumentType;
|
||||
use App\Form\Type\ContentType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
|
||||
class JailType extends DocumentType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
parent::buildForm($builder, $options);
|
||||
|
||||
$builder
|
||||
->add('arrestedAt', null, ['label' => 'form_label_arrested_at', 'help' => 'form_help_arrested_at'])
|
||||
->add('jailedAt', null, ['label' => 'form_label_jailed_at', 'help' => 'form_help_jailed_at'])
|
||||
->add('lawyer', CheckboxType::class, ['label' => 'form_label_asked_for_lawyer', 'required' => false])
|
||||
->add('medic', CheckboxType::class, ['label' => 'form_label_asked_for_medic', 'required' => false])
|
||||
->add('content', ContentType::class)
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Jail::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
31
src/Form/LicenceWithdrawalType.php
Normal file
31
src/Form/LicenceWithdrawalType.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Form\DocumentType;
|
||||
use App\Form\Type\VehicleType;
|
||||
use App\Entity\LicenceWithdrawal;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class LicenceWithdrawalType extends DocumentType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
|
||||
parent::buildForm($builder, $options);
|
||||
|
||||
$builder
|
||||
|
||||
->add('type', VehicleType::class)
|
||||
->add('until', null, ['label' => 'form_label_until', 'help' => 'form_help_until'])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => LicenceWithdrawal::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
31
src/Form/MePasswordType.php
Normal file
31
src/Form/MePasswordType.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Form\Type\RepeatedPasswordType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
|
||||
class MePasswordType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('plainPassword', RepeatedPasswordType::class)
|
||||
->add('submit', SubmitType::class, [
|
||||
'label' => 'form_button_change_password',
|
||||
'attr' => ['class' => 'btn-primary'],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => User::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
52
src/Form/MeType.php
Normal file
52
src/Form/MeType.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Form\Type\PhoneType;
|
||||
use App\Form\Type\LastnameType;
|
||||
use App\Form\Type\FirstnameType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
|
||||
class MeType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
|
||||
->add('firstname', FirstnameType::class, ['disabled' => true, 'help' => 'form_help_cant_edit_firstname'])
|
||||
->add('lastname', LastnameType::class, ['disabled' => true, 'help' => 'form_help_cant_edit_lastname'])
|
||||
->add('email', EmailType::class, [
|
||||
'label' => false,
|
||||
'attr' => ['placeholder' => 'form_placeholder_email'],
|
||||
])
|
||||
->add('phone', PhoneType::class)
|
||||
->add('locale', ChoiceType::class, [
|
||||
'choices' => [
|
||||
'form_choice_default' => null,
|
||||
'form_choice_english' => 'en',
|
||||
'form_choice_french' => 'fr'
|
||||
],
|
||||
'expanded' => false,
|
||||
'multiple' => false,
|
||||
'label' => 'form_label_language',
|
||||
])
|
||||
->add('submit', SubmitType::class, [
|
||||
'label' => 'form_button_update',
|
||||
'attr' => ['class' => 'btn-primary'],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => User::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
28
src/Form/MedicalType.php
Normal file
28
src/Form/MedicalType.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Medical;
|
||||
use App\Form\DocumentType;
|
||||
use App\Form\Type\ContentType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class MedicalType extends DocumentType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
parent::buildForm($builder, $options);
|
||||
|
||||
$builder
|
||||
->add('content', ContentType::class)
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Medical::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
30
src/Form/MotdType.php
Normal file
30
src/Form/MotdType.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Group;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
|
||||
class MotdType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('motd', null, ['label' => false,'attr' => ['style' => 'height: 400px;']])
|
||||
->add('submit', SubmitType::class, [
|
||||
'label' => 'form_button_update_motd',
|
||||
'attr' => ['class' => 'btn-primary'],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Group::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
42
src/Form/RegistrationFormType.php
Normal file
42
src/Form/RegistrationFormType.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Form\Type\GroupType;
|
||||
use App\Form\Type\LastnameType;
|
||||
use App\Form\Type\FirstnameType;
|
||||
use App\Form\Type\RepeatedPasswordType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
|
||||
class RegistrationFormType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('email', EmailType::class, [
|
||||
'label' => false,
|
||||
'attr' => ['placeholder' => 'form_placeholder_email'],
|
||||
])
|
||||
->add('firstName', FirstnameType::class)
|
||||
->add('lastName', LastnameType::class)
|
||||
->add('plainPassword', RepeatedPasswordType::class)
|
||||
->add('mainGroup', GroupType::class)
|
||||
->add('submit', SubmitType::class, [
|
||||
'label' => 'form_button_register',
|
||||
'attr' => ['class' => 'btn-primary'],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => User::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
28
src/Form/ReportType.php
Normal file
28
src/Form/ReportType.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Report;
|
||||
use App\Form\DocumentType;
|
||||
use App\Form\Type\ContentType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class ReportType extends DocumentType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
parent::buildForm($builder, $options);
|
||||
|
||||
$builder
|
||||
->add('content', ContentType::class)
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Report::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
37
src/Form/ResetPasswordRequestFormType.php
Normal file
37
src/Form/ResetPasswordRequestFormType.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
|
||||
class ResetPasswordRequestFormType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('email', EmailType::class, [
|
||||
'attr' => ['autocomplete' => 'email'],
|
||||
'label' => 'form_label_email',
|
||||
'constraints' => [
|
||||
new NotBlank([
|
||||
'message' => 'form_constraint_please_enter_email',
|
||||
]),
|
||||
],
|
||||
])
|
||||
->add('submit', SubmitType::class, [
|
||||
'label' => 'form_button_submit',
|
||||
'attr' => ['class' => 'btn-primary'],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([]);
|
||||
}
|
||||
}
|
||||
28
src/Form/SanctionType.php
Normal file
28
src/Form/SanctionType.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Sanction;
|
||||
use App\Form\DocumentType;
|
||||
use App\Form\Type\ContentType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class SanctionType extends DocumentType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
parent::buildForm($builder, $options);
|
||||
|
||||
$builder
|
||||
->add('content', ContentType::class)
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Sanction::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
31
src/Form/SearchBarType.php
Normal file
31
src/Form/SearchBarType.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Form\Type\SearchType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class SearchBarType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('subject', SearchType::class)
|
||||
->setMethod('GET')
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'csrf_protection' => false
|
||||
]);
|
||||
}
|
||||
|
||||
public function getBlockPrefix()
|
||||
{
|
||||
return ''; // return an empty string here
|
||||
}
|
||||
}
|
||||
34
src/Form/StolenvehicleType.php
Normal file
34
src/Form/StolenvehicleType.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Form\DocumentType;
|
||||
use App\Entity\Stolenvehicle;
|
||||
use App\Form\Type\ContentType;
|
||||
use App\Form\Type\VehicleType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class StolenvehicleType extends DocumentType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
parent::buildForm($builder, $options);
|
||||
|
||||
$builder
|
||||
->add('type', VehicleType::class)
|
||||
->add('numberplate', null, ['label' => 'form_label_numberplate'])
|
||||
->add('model', null, ['label' => 'form_label_model'])
|
||||
->add('color', null, ['label' => 'form_label_color'])
|
||||
->add('content', ContentType::class, ['label' => 'form_label_informations', 'required' => false])
|
||||
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Stolenvehicle::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
28
src/Form/TemplateType.php
Normal file
28
src/Form/TemplateType.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Template;
|
||||
use App\Form\DocumentType;
|
||||
use App\Form\Type\ContentType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class TemplateType extends DocumentType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
parent::buildForm($builder, $options);
|
||||
|
||||
$builder
|
||||
->add('content', ContentType::class)
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Template::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
60
src/Form/TestType.php
Normal file
60
src/Form/TestType.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Document;
|
||||
use App\Entity\User;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
|
||||
class TestType extends AbstractType
|
||||
{
|
||||
private TokenStorageInterface $TokenStorage;
|
||||
|
||||
public function __construct(TokenStorageInterface $TokenStorage)
|
||||
{
|
||||
$this->TokenStorage = $TokenStorage;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
/**
|
||||
* @var User $user
|
||||
*/
|
||||
$User = $this->TokenStorage->getToken()->getUser();
|
||||
|
||||
dd($User);
|
||||
|
||||
$builder
|
||||
->add('title', null, [
|
||||
'label' => 'form_label_title',
|
||||
'priority' => 999
|
||||
]);
|
||||
|
||||
$builder
|
||||
->add(
|
||||
'allowShare',
|
||||
null,
|
||||
[
|
||||
'priority' => -900,
|
||||
'label' => 'form_label_allowShare'
|
||||
]
|
||||
)
|
||||
->add('submit', SubmitType::class, [
|
||||
'label' => 'form_button_submit',
|
||||
'priority' => -900,
|
||||
'attr' => ['class' => 'btn-primary'],
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Document::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
23
src/Form/Type/AddressType.php
Normal file
23
src/Form/Type/AddressType.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
|
||||
class AddressType extends AbstractType
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'attr' => ['style' => 'height: 200px;'],
|
||||
'label' => 'form_label_address'
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent(): string
|
||||
{
|
||||
return TextareaType::class;
|
||||
}
|
||||
}
|
||||
33
src/Form/Type/AllowedGroupsType.php
Normal file
33
src/Form/Type/AllowedGroupsType.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use App\Entity\Group;
|
||||
use App\Repository\GroupRepository;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class AllowedGroupsType extends AbstractType
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'class' => Group::class,
|
||||
'query_builder' => function (GroupRepository $GroupRepository) {
|
||||
return $GroupRepository->createQueryBuilder('r')
|
||||
->orderBy('r.name', 'ASC');
|
||||
},
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'choice_label' => 'name',
|
||||
'label' => 'form_label_allowedgroups',
|
||||
'help' => 'form_help_allowedgroups',
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent(): string
|
||||
{
|
||||
return EntityType::class;
|
||||
}
|
||||
}
|
||||
23
src/Form/Type/ContentType.php
Normal file
23
src/Form/Type/ContentType.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
|
||||
class ContentType extends AbstractType
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'attr' => ['style' => 'height: 600px;'],
|
||||
'label' => 'form_label_content'
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent(): string
|
||||
{
|
||||
return TextareaType::class;
|
||||
}
|
||||
}
|
||||
24
src/Form/Type/FirstnameType.php
Normal file
24
src/Form/Type/FirstnameType.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
|
||||
class FirstnameType extends AbstractType
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'attr' => ['placeholder' => 'form_placeholder_firstname'],
|
||||
'help' => 'form_help_firstname',
|
||||
'label' => false
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent(): string
|
||||
{
|
||||
return TextType::class;
|
||||
}
|
||||
}
|
||||
34
src/Form/Type/GangListType.php
Normal file
34
src/Form/Type/GangListType.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use App\Entity\Gang;
|
||||
use App\Repository\GangRepository;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class GangListType extends AbstractType
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
|
||||
$resolver->setDefaults([
|
||||
'class' => Gang::class,
|
||||
'query_builder' => function (GangRepository $GangRepository) {
|
||||
return $GangRepository->createQueryBuilder('g')
|
||||
->orderBy('g.title', 'ASC');
|
||||
},
|
||||
'choice_label' => 'title',
|
||||
'placeholder' => 'form_placeholder_gang',
|
||||
'help' => 'form_help_gang',
|
||||
'label' => false,
|
||||
'required' => false
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent(): string
|
||||
{
|
||||
return EntityType::class;
|
||||
}
|
||||
}
|
||||
25
src/Form/Type/GenderType.php
Normal file
25
src/Form/Type/GenderType.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
|
||||
class GenderType extends AbstractType
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'attr' => ['placeholder' => 'form_placeholder_gender'],
|
||||
'help' => 'form_help_gender',
|
||||
'label' => false,
|
||||
'required' => true
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent(): string
|
||||
{
|
||||
return TextType::class;
|
||||
}
|
||||
}
|
||||
34
src/Form/Type/GroupType.php
Normal file
34
src/Form/Type/GroupType.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use App\Entity\Group;
|
||||
use App\Repository\GroupRepository;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class GroupType extends AbstractType
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
|
||||
$resolver->setDefaults([
|
||||
'class' => Group::class,
|
||||
'query_builder' => function (GroupRepository $GroupRepository) {
|
||||
return $GroupRepository->createQueryBuilder('r')
|
||||
->orderBy('r.name', 'ASC');
|
||||
},
|
||||
'choice_label' => 'name',
|
||||
'placeholder' => 'form_placeholder_group',
|
||||
'help' => 'form_help_group',
|
||||
'label' => false,
|
||||
'required' => true
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent(): string
|
||||
{
|
||||
return EntityType::class;
|
||||
}
|
||||
}
|
||||
25
src/Form/Type/HeightType.php
Normal file
25
src/Form/Type/HeightType.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
|
||||
class HeightType extends AbstractType
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'attr' => ['placeholder' => 'form_placeholder_height'],
|
||||
'help' => 'form_help_height',
|
||||
'label' => false,
|
||||
'required' => false
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent(): string
|
||||
{
|
||||
return TextType::class;
|
||||
}
|
||||
}
|
||||
24
src/Form/Type/LastnameType.php
Normal file
24
src/Form/Type/LastnameType.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
|
||||
class LastnameType extends AbstractType
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'attr' => ['placeholder' => 'form_placeholder_lastname'],
|
||||
'help' => 'form_help_lastname',
|
||||
'label' => false
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent(): string
|
||||
{
|
||||
return TextType::class;
|
||||
}
|
||||
}
|
||||
48
src/Form/Type/PermissionsType.php
Normal file
48
src/Form/Type/PermissionsType.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use App\PermissionsList;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Contracts\Cache\ItemInterface;
|
||||
use Symfony\Contracts\Cache\CacheInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
|
||||
class PermissionsType extends AbstractType
|
||||
{
|
||||
private CacheInterface $cache;
|
||||
|
||||
public function __construct(CacheInterface $CacheInterface)
|
||||
{
|
||||
$this->cache = $CacheInterface;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
if ($_ENV['APP_ENV'] === 'dev') {
|
||||
$permissionList = new PermissionsList();
|
||||
$permissions = $permissionList->getPermissionList();
|
||||
} else {
|
||||
$permissions = $this->cache->get('vision_permissions', function (ItemInterface $item) {
|
||||
$permissionList = new PermissionsList();
|
||||
return $permissionList->getPermissionList();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
$resolver->setDefaults([
|
||||
'choices' => $permissions,
|
||||
'expanded' => true,
|
||||
'multiple' => true,
|
||||
'label' => 'form_label_permissions',
|
||||
'attr' => ['class' => 'form-switch'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent(): string
|
||||
{
|
||||
return ChoiceType::class;
|
||||
}
|
||||
}
|
||||
29
src/Form/Type/PhoneType.php
Normal file
29
src/Form/Type/PhoneType.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Validator\Constraints\Regex;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TelType;
|
||||
|
||||
class PhoneType extends AbstractType
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'constraints' => [
|
||||
new Regex('/^[0-9]*$/', 'form_constraint_digit_only')
|
||||
],
|
||||
'attr' => ['placeholder' => 'form_placeholder_phone'],
|
||||
'help' => 'form_help_phone',
|
||||
'label' => false,
|
||||
'required' => false
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent(): string
|
||||
{
|
||||
return TelType::class;
|
||||
}
|
||||
}
|
||||
42
src/Form/Type/RepeatedPasswordType.php
Normal file
42
src/Form/Type/RepeatedPasswordType.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
|
||||
class RepeatedPasswordType extends AbstractType
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'type' => PasswordType::class,
|
||||
'mapped' => false,
|
||||
'invalid_message' => 'form_constraint_password_mismatch',
|
||||
'options' => ['attr' => ['class' => 'password-field']],
|
||||
'required' => true,
|
||||
'first_options' => ['label' => false, 'attr' => ['placeholder' => 'form_placeholder_password']],
|
||||
'second_options' => ['label' => false, 'attr' => ['placeholder' => 'form_placeholder_password_repeat']],
|
||||
'constraints' => [
|
||||
new NotBlank([
|
||||
'message' => 'form_constraint_please_enter_password',
|
||||
]),
|
||||
new Length([
|
||||
'min' => 6,
|
||||
'minMessage' => 'form_constraint_password_min_lenght_6_cars',
|
||||
// max length allowed by Symfony for security reasons
|
||||
'max' => 4096,
|
||||
]),
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent(): string
|
||||
{
|
||||
return RepeatedType::class;
|
||||
}
|
||||
}
|
||||
24
src/Form/Type/SearchType.php
Normal file
24
src/Form/Type/SearchType.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
|
||||
class SearchType extends AbstractType
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'label' => false,
|
||||
'required' => false,
|
||||
'help' => 'form_help_search'
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent(): string
|
||||
{
|
||||
return TextType::class;
|
||||
}
|
||||
}
|
||||
43
src/Form/Type/SubGroupsType.php
Normal file
43
src/Form/Type/SubGroupsType.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use App\Entity\SubGroup;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class SubGroupsType extends AbstractType
|
||||
{
|
||||
private $security;
|
||||
|
||||
public function __construct(Security $security)
|
||||
{
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
|
||||
/**
|
||||
* @var User $user
|
||||
*/
|
||||
$user = $this->security->getUser();
|
||||
|
||||
|
||||
$resolver->setDefaults([
|
||||
'class' => SubGroup::class,
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'choice_label' => 'name',
|
||||
'label' => 'form_label_allowedsubgroups',
|
||||
'help' => 'form_help_allowedsubgroups',
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent(): string
|
||||
{
|
||||
return EntityType::class;
|
||||
}
|
||||
}
|
||||
44
src/Form/Type/UserGroupSubGroupsType.php
Normal file
44
src/Form/Type/UserGroupSubGroupsType.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use App\Entity\SubGroup;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class UserGroupSubGroupsType extends AbstractType
|
||||
{
|
||||
private $security;
|
||||
|
||||
public function __construct(Security $security)
|
||||
{
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
|
||||
/**
|
||||
* @var User $user
|
||||
*/
|
||||
$user = $this->security->getUser();
|
||||
|
||||
|
||||
$resolver->setDefaults([
|
||||
'class' => SubGroup::class,
|
||||
'choices' => $user->getmainGroup()->getSubGroups(),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'choice_label' => 'name',
|
||||
'label' => 'form_label_allowedsubgroups',
|
||||
'help' => 'form_help_allowedsubgroups',
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent(): string
|
||||
{
|
||||
return EntityType::class;
|
||||
}
|
||||
}
|
||||
44
src/Form/Type/UserSubGroupsType.php
Normal file
44
src/Form/Type/UserSubGroupsType.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use App\Entity\SubGroup;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class UserSubGroupsType extends AbstractType
|
||||
{
|
||||
private $security;
|
||||
|
||||
public function __construct(Security $security)
|
||||
{
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
|
||||
/**
|
||||
* @var User $user
|
||||
*/
|
||||
$user = $this->security->getUser();
|
||||
|
||||
|
||||
$resolver->setDefaults([
|
||||
'class' => SubGroup::class,
|
||||
'choices' => $user->getSubGroups(),
|
||||
'multiple' => true,
|
||||
'expanded' => true,
|
||||
'choice_label' => 'name',
|
||||
'label' => 'form_label_allowedsubgroups',
|
||||
'help' => 'form_help_allowedsubgroups',
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent(): string
|
||||
{
|
||||
return EntityType::class;
|
||||
}
|
||||
}
|
||||
19
src/Form/Type/UsernameType.php
Normal file
19
src/Form/Type/UsernameType.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
|
||||
class UsernameType extends AbstractType
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
}
|
||||
|
||||
public function getParent(): string
|
||||
{
|
||||
return TextType::class;
|
||||
}
|
||||
}
|
||||
32
src/Form/Type/VehicleType.php
Normal file
32
src/Form/Type/VehicleType.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
|
||||
class VehicleType extends AbstractType
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'choices' => [
|
||||
'form_choice_car' => 'form_choice_car',
|
||||
'form_choice_motorcycle' => 'form_choice_motorcycle',
|
||||
'form_choice_plane' => 'form_choice_plane',
|
||||
'form_choice_boat' => 'form_choice_boat',
|
||||
'form_choice_helicopter' => 'form_choice_helicopter',
|
||||
'form_choice_bike' => 'form_choice_bike',
|
||||
'form_choice_truck' => 'form_choice_truck',
|
||||
'form_choice_other' => 'form_choice_other'
|
||||
],
|
||||
'label' => 'form_label_vehicle_type',
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent(): string
|
||||
{
|
||||
return ChoiceType::class;
|
||||
}
|
||||
}
|
||||
25
src/Form/Type/WeightType.php
Normal file
25
src/Form/Type/WeightType.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
|
||||
class WeightType extends AbstractType
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'attr' => ['placeholder' => 'form_placeholder_weight'],
|
||||
'help' => 'form_help_weight',
|
||||
'label' => false,
|
||||
'required' => false
|
||||
]);
|
||||
}
|
||||
|
||||
public function getParent(): string
|
||||
{
|
||||
return TextType::class;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user