From 9a2e4755e10204b3c66c59f81c37fe11c3176ac8 Mon Sep 17 00:00:00 2001 From: afornerot Date: Tue, 24 Dec 2024 17:29:46 +0100 Subject: [PATCH] svg --- src/Entity/User.php | 4 ++-- src/EventListener/SessionListener.php | 2 +- src/Form/AccountingType.php | 8 +------- src/Form/DataTransformer/ThreeDigitTransformer.php | 2 +- src/Service/ImageService.php | 14 ++++++++++---- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Entity/User.php b/src/Entity/User.php index d7180d1..3b81972 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -44,7 +44,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface private ?string $email = null; #[ORM\ManyToMany(targetEntity: Company::class, inversedBy: 'users')] - private Collection $companys; + private ?Collection $companys; #[ORM\ManyToOne()] #[ORM\JoinColumn(nullable: true)] @@ -157,7 +157,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface /** * @return Collection */ - public function getCompanys(): Collection + public function getCompanys(): ?Collection { return $this->companys; } diff --git a/src/EventListener/SessionListener.php b/src/EventListener/SessionListener.php index 6eab6cf..b68e4db 100644 --- a/src/EventListener/SessionListener.php +++ b/src/EventListener/SessionListener.php @@ -28,7 +28,7 @@ final class SessionListener $session = $request->getSession(); $user = $this->security->getUser(); - if ($user instanceof User && $user) { + if ($user instanceof User) { // Intialisation de la compagnie en cours if (!$user->getCompany()) { if ($user->getCompanys()) { diff --git a/src/Form/AccountingType.php b/src/Form/AccountingType.php index 437a9e6..7151318 100644 --- a/src/Form/AccountingType.php +++ b/src/Form/AccountingType.php @@ -4,6 +4,7 @@ namespace App\Form; use App\Entity\Accounting; use App\Form\DataTransformer\ThreeDigitTransformer; +use App\Form\Type\FontawsomeType; use App\Form\Type\ThreeDigitType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; @@ -14,13 +15,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class AccountingType extends AbstractType { - private ThreeDigitTransformer $threeDigitTransformer; - - public function __construct(ThreeDigitTransformer $threeDigitTransformer) - { - $this->threeDigitTransformer = $threeDigitTransformer; - } - public function buildForm(FormBuilderInterface $builder, array $options): void { $builder diff --git a/src/Form/DataTransformer/ThreeDigitTransformer.php b/src/Form/DataTransformer/ThreeDigitTransformer.php index 8925735..feb96fb 100644 --- a/src/Form/DataTransformer/ThreeDigitTransformer.php +++ b/src/Form/DataTransformer/ThreeDigitTransformer.php @@ -11,7 +11,7 @@ class ThreeDigitTransformer implements DataTransformerInterface return null !== $value ? str_pad($value, 3, '0', STR_PAD_LEFT) : null; } - public function reverseTransform($value): ?int + public function reverseTransform($value): string { return str_pad($value, 3, '0', STR_PAD_LEFT); } diff --git a/src/Service/ImageService.php b/src/Service/ImageService.php index 21b5abe..d1bf671 100644 --- a/src/Service/ImageService.php +++ b/src/Service/ImageService.php @@ -34,8 +34,8 @@ class ImageService } // Création de l'image redimentionnée - $newImageWidth = ceil($width * $scale); - $newImageHeight = ceil($height * $scale); + $newImageWidth = (int) ceil($width * $scale); + $newImageHeight = (int) ceil($height * $scale); $newImage = imagecreatetruecolor($newImageWidth, $newImageHeight); switch ($imageType) { @@ -54,6 +54,9 @@ class ImageService case 'image/webp': $source = imagecreatefromwebp($image); break; + default: + $source= imagecreatefromgif($image); + break; } imagecopyresampled($newImage, $source, 0, 0, 0, 0, $newImageWidth, $newImageHeight, $width, $height); @@ -88,8 +91,8 @@ class ImageService } // Création de l'image redimentionnée - $newImageWidth = ceil($cropWidth * $scale); - $newImageHeight = ceil($cropHeight * $scale); + $newImageWidth = (int) ceil($cropWidth * $scale); + $newImageHeight = (int) ceil($cropHeight * $scale); $newImage = imagecreatetruecolor($newImageWidth, $newImageHeight); @@ -109,6 +112,9 @@ class ImageService case 'image/webp': $source = imagecreatefromwebp($image); break; + default: + $source= imagecreatefromgif($image); + break; } imagecopyresampled($newImage, $source, 0, 0, $x, $y, $newImageWidth, $newImageHeight, $cropWidth, $cropHeight);