소스 검색

fix after review

Vincent 2 년 전
부모
커밋
3395a8677e

+ 3 - 0
config/packages/api_platform.yaml

@@ -17,4 +17,7 @@ api_platform:
     defaults:
         pagination_items_per_page: 20
         normalization_context:
+            ## In 3.0, in conformance with the JSON Merge Patch RFC, the default value of the skip_null_values
+            ## property is true which means that from now on null values are omitted during serialization.
+            ## we don't want this => surcharge default value to false
             skip_null_values: false

+ 3 - 3
src/ApiResources/Dolibarr/DolibarrAccount.php

@@ -21,14 +21,14 @@ use Symfony\Component\Serializer\Annotation\Groups;
 #[ApiResource(
     operations: [
         new Get(
+            uriTemplate: '/dolibarr/account/{organizationId}',
+            requirements: ['organizationId' => '\\d+'],
+            normalizationContext: ['groups' => ['dolibarr_get']],
             security: '(is_granted("ROLE_ADMIN_CORE") or 
                             is_granted("ROLE_ADMINISTRATIF_MANAGER_CORE") or 
                             is_granted("ROLE_PEDAGOGICS_MANAGER_CORE") or 
                             is_granted("ROLE_FINANCIAL_MANAGER_CORE")
                            ) and object.getOrganizationId() == user.getOrganization().getId()',
-            uriTemplate: '/dolibarr/account/{organizationId}',
-            requirements: ['organizationId' => '\\d+'],
-            normalizationContext: ['groups' => ['dolibarr_get']],
             provider: DolibarrAccountProvider::class
         )
     ]

+ 1 - 1
src/ApiResources/DownloadRequest.php

@@ -15,9 +15,9 @@ use App\State\Provider\Core\DownloadRequestProvider;
 #[ApiResource(
     operations: [
         new Get(
-            security: 'is_granted("ROLE_FILE")',
             uriTemplate: '/download/{fileId}',
             requirements: ['fileId' => '\\d+'],
+            security: 'is_granted("ROLE_FILE")',
             provider: DownloadRequestProvider::class
         )
     ]

+ 2 - 6
src/ApiResources/Export/LicenceCmf/LicenceCmfOrganizationER.php

@@ -23,13 +23,9 @@ use Symfony\Component\Validator\Constraints as Assert;
  */
 #[ApiResource(
     operations: [
-        new Get(),
-        new Put(),
-        new Patch(),
-        new Delete(),
         new Post(
-            security: '(is_granted("ROLE_ADMIN_CORE") or is_granted("ROLE_ADMINISTRATIF_MANAGER_CORE"))',
-            uriTemplate: '/cmf-licence/organization'
+            uriTemplate: '/cmf-licence/organization',
+            security: '(is_granted("ROLE_ADMIN_CORE") or is_granted("ROLE_ADMINISTRATIF_MANAGER_CORE"))'
         ),
     ],
     routePrefix: '/export',

+ 2 - 2
src/ApiResources/Mobyt/MobytUserStatus.php

@@ -15,14 +15,14 @@ use App\State\Provider\Mobyt\MobytUserStatusProvider;
 #[ApiResource(
     operations: [
         new Get(
+            uriTemplate: '/mobyt/status/{organizationId}',
+            requirements: ['organizationId' => '\\d+'],
             security: '(is_granted("ROLE_ADMIN_CORE") or
                             is_granted("ROLE_ADMINISTRATIF_MANAGER_CORE") or
                             is_granted("ROLE_PEDAGOGICS_MANAGER_CORE") or
                             is_granted("ROLE_FINANCIAL_MANAGER_CORE") or
                             is_granted("ROLE_TEXTO")
                            ) and object.getOrganizationId() == user.getOrganization().getId()',
-            uriTemplate: '/mobyt/status/{organizationId}',
-            requirements: ['organizationId' => '\\d+'],
             provider: MobytUserStatusProvider::class
         )
     ]

+ 1 - 1
src/ApiResources/Profile/AccessProfile.php

@@ -22,9 +22,9 @@ use Doctrine\Common\Collections\Collection;
 #[ApiResource(
     operations: [
         new Get(
-            normalizationContext: ['groups' => ['access_profile_read:output']],
             uriTemplate: '/my_profile/{id}',
             defaults: ['id' => 0],
+            normalizationContext: ['groups' => ['access_profile_read:output']],
             provider: AccessProfileProvider::class
         )
     ]

+ 2 - 2
src/ApiResources/Utils/GpsCoordinate.php

@@ -15,11 +15,11 @@ use App\State\Provider\Utils\GpsCoordinateSearchingProvider;
  * Classe resource qui contient les champs de recherche des coordonnées GPS d'une adresse
  */
 #[ApiResource(
-    provider: GpsCoordinateSearchingProvider::class,
     operations: [
         new Get(uriTemplate: '/gps-coordinate-reverse/{latitude}/{longitude}'),
         new GetCollection(uriTemplate: '/gps-coordinate-searching')
-    ]
+    ],
+    provider: GpsCoordinateSearchingProvider::class
 )]
 class GpsCoordinate implements ApiResourcesInterface
 {

+ 2 - 4
src/Annotation/ActivityYearConstraintAware.php → src/Attribute/ActivityYearConstraintAware.php

@@ -1,14 +1,12 @@
 <?php
 declare(strict_types=1);
 
-namespace App\Annotation;
-
-use Attribute;
+namespace App\Attribute;
 
 /**
  * Classe ActivityYearConstraintAware qui gère l'annotation pour le Doctrine filter
  */
-#[Attribute(Attribute::TARGET_CLASS)]
+#[\Attribute(\Attribute::TARGET_CLASS)]
 final class ActivityYearConstraintAware
 {
     public string $startYearFieldName;

+ 2 - 4
src/Annotation/BillingSettingDefaultValue.php → src/Attribute/BillingSettingDefaultValue.php

@@ -1,14 +1,12 @@
 <?php
 declare(strict_types=1);
 
-namespace App\Annotation;
-
-use Attribute;
+namespace App\Attribute;
 
 /**
  * Classe BillingSettingDefaultValue qui gère l'annotation pour mettre le billing setting de l'organization comme valeur par défaut
  */
-#[Attribute(Attribute::TARGET_CLASS)]
+#[\Attribute(\Attribute::TARGET_CLASS)]
 final class BillingSettingDefaultValue
 {
     public string $fieldName;

+ 2 - 4
src/Annotation/DateTimeConstraintAware.php → src/Attribute/DateTimeConstraintAware.php

@@ -1,14 +1,12 @@
 <?php
 declare(strict_types=1);
 
-namespace App\Annotation;
-
-use Attribute;
+namespace App\Attribute;
 
 /**
  * Classe DateTimeConstraintAware qui gère l'annotation pour le Doctrine filter
  */
-#[Attribute(Attribute::TARGET_CLASS)]
+#[\Attribute(\Attribute::TARGET_CLASS)]
 final class DateTimeConstraintAware
 {
     public string $startDateFieldName;

+ 2 - 4
src/Annotation/OrganizationDefaultValue.php → src/Attribute/OrganizationDefaultValue.php

@@ -1,14 +1,12 @@
 <?php
 declare(strict_types=1);
 
-namespace App\Annotation;
-
-use Attribute;
+namespace App\Attribute;
 
 /**
  * Classe OrganizationDefaultValue qui gère l'annotation pour mettre l'organization comme valeur par défaut
  */
-#[Attribute(Attribute::TARGET_CLASS)]
+#[\Attribute(\Attribute::TARGET_CLASS)]
 final class OrganizationDefaultValue
 {
     public string $fieldName;

+ 1 - 1
src/Entity/Access/OrganizationFunction.php

@@ -4,7 +4,7 @@ declare (strict_types=1);
 namespace App\Entity\Access;
 
 use ApiPlatform\Metadata\ApiResource;
-use App\Annotation\DateTimeConstraintAware;
+use App\Attribute\DateTimeConstraintAware;
 use App\Entity\Organization\Activity;
 use App\Entity\Traits\ActivityPeriodTrait;
 use App\Repository\Access\OrganizationFunctionRepository;

+ 1 - 1
src/Entity/Billing/ResidenceArea.php

@@ -9,7 +9,7 @@ use ApiPlatform\Metadata\Delete;
 use ApiPlatform\Metadata\Put;
 use ApiPlatform\Metadata\Get;
 use ApiPlatform\Metadata\ApiResource;
-use App\Annotation\BillingSettingDefaultValue;
+use App\Attribute\BillingSettingDefaultValue;
 use App\Entity\Product\IntangibleDiscountDetail;
 use App\Repository\Billing\ResidenceAreaRepository;
 //use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;

+ 2 - 9
src/Entity/Booking/AbstractBooking.php

@@ -3,17 +3,10 @@ declare(strict_types=1);
 
 namespace App\Entity\Booking;
 
-use App\Annotation\ActivityYearConstraintAware;
-use App\Annotation\OrganizationDefaultValue;
-use App\Entity\Access\Access;
-use App\Entity\Core\Tagg;
-use App\Entity\Organization\Organization;
-use App\Entity\Place\Place;
-use App\Entity\Place\Room;
+use App\Attribute\ActivityYearConstraintAware;
+use App\Attribute\OrganizationDefaultValue;
 use App\Entity\Traits\ActivityYearTrait;
-use Doctrine\Common\Collections\Collection;
 use Doctrine\ORM\Mapping as ORM;
-use Symfony\Component\Serializer\Annotation\Groups;
 
 /**
  * Classe ... qui ...

+ 1 - 1
src/Entity/Core/Notification.php

@@ -30,8 +30,8 @@ use Symfony\Component\Serializer\Annotation\Context;
     operations: [
         new Get(),
         new GetCollection(
-            paginationClientItemsPerPage: true,
             paginationMaximumItemsPerPage: 20,
+            paginationClientItemsPerPage: true,
             order: ['id' => 'DESC']
         )
     ]

+ 1 - 1
src/Entity/Education/EducationNotationConfig.php

@@ -7,7 +7,7 @@ use ApiPlatform\Metadata\GetCollection;
 use ApiPlatform\Metadata\Put;
 use ApiPlatform\Metadata\Get;
 use ApiPlatform\Metadata\ApiResource;
-use App\Annotation\OrganizationDefaultValue;
+use App\Attribute\OrganizationDefaultValue;
 use App\Entity\Access\Access;
 use App\Repository\Education\EducationNotationConfigRepository;
 use App\Entity\Organization\Organization;

+ 1 - 1
src/Entity/Education/EducationTiming.php

@@ -9,7 +9,7 @@ use ApiPlatform\Metadata\Delete;
 use ApiPlatform\Metadata\Put;
 use ApiPlatform\Metadata\Get;
 use ApiPlatform\Metadata\ApiResource;
-use App\Annotation\OrganizationDefaultValue;
+use App\Attribute\OrganizationDefaultValue;
 use App\Entity\Organization\Organization;
 use App\Repository\Education\EducationTimingRepository;
 

+ 1 - 1
src/Entity/Message/AbstractMessage.php

@@ -3,7 +3,7 @@ declare(strict_types=1);
 
 namespace App\Entity\Message;
 
-use App\Annotation\OrganizationDefaultValue;
+use App\Attribute\OrganizationDefaultValue;
 use App\Entity\Organization\Organization;
 use App\Enum\Message\MessageStatusEnum;
 use Doctrine\ORM\Mapping as ORM;

+ 3 - 3
src/Entity/Network/NetworkOrganization.php

@@ -6,7 +6,7 @@ namespace App\Entity\Network;
 use ApiPlatform\Metadata\GetCollection;
 use ApiPlatform\Metadata\Get;
 use ApiPlatform\Metadata\ApiResource;
-use App\Annotation\DateTimeConstraintAware;
+use App\Attribute\DateTimeConstraintAware;
 use App\Entity\Organization\Organization;
 use App\Repository\Network\NetworkOrganizationRepository;
 
@@ -26,9 +26,9 @@ use Symfony\Component\Serializer\Annotation\Groups;
             security: 'is_granted(\'ROLE_ORGANIZATION_VIEW\')'
         )
     ],
-    security: 'is_granted(\'ROLE_ORGANIZATION\')',
     normalizationContext: ['groups' => ['network']
-    ]
+    ],
+    security: 'is_granted(\'ROLE_ORGANIZATION\')'
 )]
 //#[Auditable]
 #[ORM\Entity(repositoryClass: NetworkOrganizationRepository::class)]

+ 3 - 3
src/Entity/Organization/OrganizationAddressPostal.php

@@ -9,7 +9,7 @@ use ApiPlatform\Metadata\Delete;
 use ApiPlatform\Metadata\Put;
 use ApiPlatform\Metadata\Get;
 use ApiPlatform\Metadata\ApiResource;
-use App\Annotation\OrganizationDefaultValue;
+use App\Attribute\OrganizationDefaultValue;
 use App\Entity\Core\AddressPostal;
 use App\Repository\Organization\OrganizationAddressPostalRepository;
 
@@ -35,9 +35,9 @@ use App\Validator\Organization as OpentalentAssert;
         ),
         new Post()
     ],
-    security: 'is_granted(\'ROLE_ORGANIZATION\')',
+    normalizationContext: ['groups' => ['address']],
     denormalizationContext: ['groups' => ['address']],
-    normalizationContext: ['groups' => ['address']]
+    security: 'is_granted(\'ROLE_ORGANIZATION\')'
 )]
 //#[Auditable]
 #[ORM\Entity(repositoryClass: OrganizationAddressPostalRepository::class)]

+ 1 - 1
src/Entity/Organization/Subdomain.php

@@ -10,7 +10,7 @@ use ApiPlatform\Metadata\Get;
 use ApiPlatform\Metadata\ApiResource;
 use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
 use ApiPlatform\Metadata\ApiFilter;
-use App\Annotation\OrganizationDefaultValue;
+use App\Attribute\OrganizationDefaultValue;
 use App\Repository\Organization\SubdomainRepository;
 use App\State\Processor\Organization\SubdomainProcessor;
 

+ 1 - 1
src/Entity/Traits/ActivityPeriodTrait.php

@@ -3,7 +3,7 @@ declare(strict_types=1);
 
 namespace App\Entity\Traits;
 
-use App\Annotation\DateTimeAware;
+use App\Attribute\DateTimeConstraintAware;
 use Doctrine\ORM\Mapping as ORM;
 
 trait ActivityPeriodTrait

+ 1 - 3
src/Filter/DoctrineFilter/AbstractTimeFilter.php

@@ -3,11 +3,9 @@ declare(strict_types=1);
 
 namespace App\Filter\DoctrineFilter;
 
-use App\Annotation\DateTimeConstraintAware;
+use App\Attribute\DateTimeConstraintAware;
 use App\Service\Constraint\DateTimeConstraint;
-use App\Service\Utils\StringsUtils;
 use App\Tests\Filter\DoctrineFilter\DateTimeFilterTest;
-use Doctrine\ORM\Mapping\ClassMetadata;
 use Doctrine\ORM\Query\Filter\SQLFilter;
 
 /**

+ 1 - 1
src/Filter/DoctrineFilter/ActivityYearFilter.php

@@ -3,7 +3,7 @@ declare(strict_types=1);
 
 namespace App\Filter\DoctrineFilter;
 
-use App\Annotation\ActivityYearConstraintAware;
+use App\Attribute\ActivityYearConstraintAware;
 use App\Service\Constraint\ActivityYearConstraint;
 use App\Service\Utils\StringsUtils;
 use Doctrine\ORM\Mapping\ClassMetadata;

+ 1 - 1
src/Filter/DoctrineFilter/DateTimeFilter.php

@@ -3,7 +3,7 @@ declare(strict_types=1);
 
 namespace App\Filter\DoctrineFilter;
 
-use App\Annotation\DateTimeConstraintAware;
+use App\Attribute\DateTimeConstraintAware;
 use App\Service\Constraint\DateTimeConstraint;
 use App\Service\Utils\StringsUtils;
 use Doctrine\ORM\Mapping\ClassMetadata;

+ 2 - 2
src/Service/Utils/EntityUtils.php

@@ -3,8 +3,8 @@ declare(strict_types=1);
 
 namespace App\Service\Utils;
 
-use App\Annotation\BillingSettingDefaultValue;
-use App\Annotation\OrganizationDefaultValue;
+use App\Attribute\BillingSettingDefaultValue;
+use App\Attribute\OrganizationDefaultValue;
 use App\Entity\Access\Access;
 
 /**

+ 23 - 0
tests/Doctrine/Billing/CurrentResidenceAreaExtensionTest.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace App\Tests\Doctrine\Billing;
+
+use App\Doctrine\Billing\CurrentResidenceAreaExtension;
+use Symfony\Bundle\SecurityBundle\Security;
+use PHPUnit\Framework\TestCase;
+
+class CurrentResidenceAreaExtensionTest extends TestCase
+{
+    private CurrentResidenceAreaExtension $currentResidenceAreaExtension;
+
+    public function setUp(): void
+    {
+        $security = $this->getMockBuilder(Security::class)->disableOriginalConstructor()->getMock();
+        $this->currentResidenceAreaExtension = new CurrentResidenceAreaExtension($security);
+    }
+
+    public function testSmoke():void
+    {
+        $this->assertTrue(true, true);
+    }
+}