Fix fields and add warning on content too long

This commit is contained in:
Xbird
2022-10-01 22:55:58 +00:00
parent 1a38d3e854
commit f815cfa58a
30 changed files with 681 additions and 597 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Command;
use App\Entity\User;
use App\Entity\Group;
use App\Entity\Rank;
use Doctrine\ORM\Query;
use App\Repository\GroupRepository;
use Doctrine\ORM\EntityManagerInterface;
@@ -143,7 +144,7 @@ class AddUserCommand extends Command
/**
* @var RankRepository $rankRepository
*/
$rankRepository = $this->entityManager->getRepository("App:Rank");
$rankRepository = $this->entityManager->getRepository(Rank::class);
if ($rankid && null === $rankRepository->find($rankid)) {
$rankid = '';
@@ -163,7 +164,7 @@ class AddUserCommand extends Command
);
}
global $groupRepository;
if (null === $this->entityManager->getRepository("App:Rank")->find($answer)) {
if (null === $this->entityManager->getRepository(Rank::class)->find($answer)) {
throw new \RuntimeException(
'No rank find for this id'
);

View File

@@ -181,6 +181,8 @@ class AdminController extends AbstractController
$this->addFlash('danger', 'alert_error_saving_user');
return $this->redirectToRoute('admin_user_edit', ['id' => $User->getId()]);
}
} elseif ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('warning', 'alert_error_form_post');
}
return $this->render('admin/user_edit.html.twig', [
@@ -284,6 +286,8 @@ class AdminController extends AbstractController
}
$this->addFlash('danger', 'alert_error_creating_group');
}
} elseif ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('warning', 'alert_error_form_post');
}
return $this->render('admin/group_add.html.twig', [
@@ -314,6 +318,8 @@ class AdminController extends AbstractController
}
$this->addFlash('danger', 'alert_error_editing_group');
}
} elseif ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('warning', 'alert_error_form_post');
}
return $this->render('admin/group_edit.html.twig', [
@@ -377,6 +383,8 @@ class AdminController extends AbstractController
}
$this->addFlash('danger', 'alert_error_editing_rank');
}
} elseif ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('warning', 'alert_error_form_post');
}
return $this->render('admin/group_rank_edit.html.twig', [
@@ -411,6 +419,8 @@ class AdminController extends AbstractController
}
$this->addFlash('danger', 'alert_error_creating_rank');
}
} elseif ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('warning', 'alert_error_form_post');
}
return $this->render('admin/group_rank_add.html.twig', [
@@ -496,6 +506,8 @@ class AdminController extends AbstractController
}
$this->addFlash('danger', 'alert_error_editing_subgroup');
}
} elseif ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('warning', 'alert_error_form_post');
}
return $this->render('admin/group_subgroup_edit.html.twig', [
@@ -530,6 +542,8 @@ class AdminController extends AbstractController
}
$this->addFlash('danger', 'alert_error_creating_subgroup');
}
} elseif ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('warning', 'alert_error_form_post');
}
return $this->render('admin/group_subgroup_add.html.twig', [

View File

@@ -51,6 +51,8 @@ class CommentController extends AbstractController
$this->addFlash('success', 'alert_success_creating_comment');
return $this->redirectToRoute('document_view', ['id' => $Document->getId()]);
} elseif ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('warning', 'alert_error_form_post');
}
return $this->redirectToRoute('document_view', ['id' => $Document->getId()]);
@@ -109,6 +111,8 @@ class CommentController extends AbstractController
$this->addFlash('success', 'alert_success_editing_comment');
return $this->redirectToRoute('document_view', ['id' => $Comment->getDocument()->getId()]);
} elseif ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('warning', 'alert_error_form_post');
}
return $this->render('comment/edit.html.twig', [

View File

@@ -144,7 +144,10 @@ class DirectoryController extends AbstractController
$this->addFlash('success', 'alert_success_creating_directory');
return $this->redirectToRoute('directory_view', ['id' => $Directory->getId()]);
} elseif ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('warning', 'alert_error_form_post');
}
return $this->render('directory/create.html.twig', [
'controller_name' => 'DirectoryController',
'directory' => $Directory,
@@ -177,7 +180,10 @@ class DirectoryController extends AbstractController
$this->addFlash('success', 'alert_success_editing_directory');
return $this->redirectToRoute('directory_view', ['id' => $Directory->getId()]);
} elseif ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('warning', 'alert_error_form_post');
}
return $this->render('directory/edit.html.twig', [
'controller_name' => 'DirectoryController',
'directory' => $Directory,

View File

@@ -140,6 +140,7 @@ class DocumentController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
/**
* @var User $loggedUser
*/
@@ -176,6 +177,8 @@ class DocumentController extends AbstractController
$this->addFlash('success', 'alert_success_creating_document');
return $this->redirectToRoute('document_view', ['id' => $Document->getId()]);
} elseif ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('warning', 'alert_error_form_post');
}
return $this->render('document/create.html.twig', [
@@ -199,8 +202,6 @@ class DocumentController extends AbstractController
$form = $this->getFormByDocumentType($Document);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
/**
@@ -253,6 +254,8 @@ class DocumentController extends AbstractController
$this->addFlash('success', 'alert_success_editing_document');
return $this->redirectToRoute('document_view', ['id' => $Document->getId()]);
} elseif ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('warning', 'alert_error_form_post');
}
return $this->render('document/edit.html.twig', [
'controller_name' => 'DocumentController',

View File

@@ -58,6 +58,8 @@ class GroupController extends AbstractController
}
$this->addFlash('danger', 'alert_error_editing_motd');
}
} elseif ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('warning', 'alert_error_form_post');
}
return $this->render('group/index.html.twig', [
@@ -203,6 +205,8 @@ class GroupController extends AbstractController
}
$this->addFlash('danger', 'alert_error_editing_employee');
}
} elseif ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('warning', 'alert_error_form_post');
}
return $this->render('group/employee.html.twig', [

View File

@@ -54,6 +54,8 @@ class MeController extends AbstractController
$this->addFlash('success', 'alert_success_editing_profile');
$request->getSession()->set('_locale', $user->getLocale());
return $this->redirectToRoute('me_index');
} elseif ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('warning', 'alert_error_form_post');
}
@@ -104,6 +106,8 @@ class MeController extends AbstractController
$this->addFlash('success', 'alert_success_editing_password');
$request->getSession()->set('_locale', $user->getLocale());
return $this->redirectToRoute('me_index');
} elseif ($form->isSubmitted() && !$form->isValid()) {
$this->addFlash('warning', 'alert_error_form_post');
}

View File

@@ -6,6 +6,7 @@ use App\Entity\Document;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\AnnounceRepository;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=AnnounceRepository::class)
@@ -13,8 +14,12 @@ use Gedmo\Mapping\Annotation as Gedmo;
class Announce extends Document
{
/**
* @ORM\Column(type="text")
* @ORM\Column(type="text", length=65535)
* @Gedmo\Versioned
* @Assert\Length(
* max=65535,
* maxMessage="Content too long : {{ limit }} max"
* )
*/
private $content;

View File

@@ -5,6 +5,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use App\Repository\CertificateRepository;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=CertificateRepository::class)
@@ -12,8 +13,12 @@ use App\Repository\CertificateRepository;
class Certificate extends Document
{
/**
* @ORM\Column(type="text")
* @ORM\Column(type="text", length=65535)
* @Gedmo\Versioned
* @Assert\Length(
* max=65535,
* maxMessage="Content too long : {{ limit }} max"
* )
*/
private $content;

View File

@@ -5,6 +5,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\CommentRepository;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=CommentRepository::class)
@@ -20,8 +21,12 @@ class Comment
private $id;
/**
* @ORM\Column(type="text")
* @ORM\Column(type="text", length=65535)
* @Gedmo\Versioned
* @Assert\Length(
* max=65535,
* maxMessage="Content too long : {{ limit }} max"
* )
*/
private $content;

View File

@@ -6,6 +6,7 @@ use App\Entity\Document;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use App\Repository\ComplaintRepository;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=ComplaintRepository::class)
@@ -19,8 +20,12 @@ class Complaint extends Document
private $directory;
/**
* @ORM\Column(type="text")
* @ORM\Column(type="text", length=65535)
* @Gedmo\Versioned
* @Assert\Length(
* max=65535,
* maxMessage="Content too long : {{ limit }} max"
* )
*/
private $content;

View File

@@ -6,6 +6,7 @@ use App\Entity\Document;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\CriminalRepository;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=CriminalRepository::class)
@@ -31,8 +32,12 @@ class Criminal extends Document
private $amountTime;
/**
* @ORM\Column(type="text", nullable=true)
* @ORM\Column(type="text", length=65535)
* @Gedmo\Versioned
* @Assert\Length(
* max=65535,
* maxMessage="Content too long : {{ limit }} max"
* )
*/
private $content;

View File

@@ -8,6 +8,7 @@ use App\Repository\FolderRepository;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=FolderRepository::class)
@@ -15,8 +16,12 @@ use Doctrine\Common\Collections\ArrayCollection;
class Folder extends Document
{
/**
* @ORM\Column(type="text", nullable=true)
* @ORM\Column(type="text", length=65535)
* @Gedmo\Versioned
* @Assert\Length(
* max=65535,
* maxMessage="Content too long : {{ limit }} max"
* )
*/
private $content;

View File

@@ -8,6 +8,7 @@ use App\Repository\GangRepository;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=GangRepository::class)
@@ -23,8 +24,12 @@ class Gang extends Document
}
/**
* @ORM\Column(type="text", nullable=true)
* @ORM\Column(type="text", length=65535)
* @Gedmo\Versioned
* @Assert\Length(
* max=65535,
* maxMessage="Content too long : {{ limit }} max"
* )
*/
private $content;

View File

@@ -5,6 +5,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use App\Repository\InfringementRepository;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=InfringementRepository::class)
@@ -12,8 +13,12 @@ use App\Repository\InfringementRepository;
class Infringement extends Document
{
/**
* @ORM\Column(type="text")
* @ORM\Column(type="text", length=65535)
* @Gedmo\Versioned
* @Assert\Length(
* max=65535,
* maxMessage="Content too long : {{ limit }} max"
* )
*/
private $content;

View File

@@ -8,6 +8,7 @@ use App\Entity\Document;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\JailRepository;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=JailRepository::class)
@@ -33,8 +34,12 @@ class Jail extends Document
private $directory;
/**
* @ORM\Column(type="text")
* @ORM\Column(type="text", length=65535)
* @Gedmo\Versioned
* @Assert\Length(
* max=65535,
* maxMessage="Content too long : {{ limit }} max"
* )
*/
private $content;

View File

@@ -6,6 +6,7 @@ use App\Entity\Document;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\MedicalRepository;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=MedicalRepository::class)
@@ -19,8 +20,12 @@ class Medical extends Document
private $directory;
/**
* @ORM\Column(type="text")
* @ORM\Column(type="text", length=65535)
* @Gedmo\Versioned
* @Assert\Length(
* max=65535,
* maxMessage="Content too long : {{ limit }} max"
* )
*/
private $content;

View File

@@ -5,6 +5,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use App\Repository\NotificationRepository;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=NotificationRepository::class)
@@ -35,7 +36,11 @@ class Notification
private $icon;
/**
* @ORM\Column(type="text")
* @ORM\Column(type="text", length=65535)
* @Assert\Length(
* max=65535,
* maxMessage="Content too long : {{ limit }} max"
* )
*/
private $content;

View File

@@ -6,6 +6,7 @@ use App\Entity\Document;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\ReportRepository;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=ReportRepository::class)
@@ -13,8 +14,12 @@ use Gedmo\Mapping\Annotation as Gedmo;
class Report extends Document
{
/**
* @ORM\Column(type="text")
* @ORM\Column(type="text", length=65535)
* @Gedmo\Versioned
* @Assert\Length(
* max=65535,
* maxMessage="Content too long : {{ limit }} max"
* )
*/
private $content;

View File

@@ -5,6 +5,7 @@ namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\SanctionRepository;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=SanctionRepository::class)
@@ -12,8 +13,12 @@ use Gedmo\Mapping\Annotation as Gedmo;
class Sanction extends Document
{
/**
* @ORM\Column(type="text")
* @ORM\Column(type="text", length=65535)
* @Gedmo\Versioned
* @Assert\Length(
* max=65535,
* maxMessage="Content too long : {{ limit }} max"
* )
*/
private $content;

View File

@@ -6,6 +6,7 @@ use App\Entity\Document;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use App\Repository\StolenvehicleRepository;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=StolenvehicleRepository::class)
@@ -31,8 +32,12 @@ class Stolenvehicle extends Document
private $model;
/**
* @ORM\Column(type="text", nullable=true)
* @ORM\Column(type="text", length=65535)
* @Gedmo\Versioned
* @Assert\Length(
* max=65535,
* maxMessage="Content too long : {{ limit }} max"
* )
*/
private $content;

View File

@@ -6,6 +6,7 @@ use App\Entity\Document;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\TemplateRepository;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=TemplateRepository::class)
@@ -18,8 +19,12 @@ class Template extends Document
}
/**
* @ORM\Column(type="text")
* @ORM\Column(type="text", length=65535)
* @Gedmo\Versioned
* @Assert\Length(
* max=65535,
* maxMessage="Content too long : {{ limit }} max"
* )
*/
private $content;

View File

@@ -4,7 +4,7 @@ namespace App\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
class HeightType extends AbstractType
{
@@ -20,6 +20,6 @@ class HeightType extends AbstractType
public function getParent(): string
{
return TextType::class;
return NumberType::class;
}
}

View File

@@ -4,7 +4,7 @@ namespace App\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
class WeightType extends AbstractType
{
@@ -20,6 +20,6 @@ class WeightType extends AbstractType
public function getParent(): string
{
return TextType::class;
return NumberType::class;
}
}