Browse Source

various fixes

Olivier Massot 7 months ago
parent
commit
85b7735a3a

+ 2 - 1
src/ApiResources/Access/AdminAccess.php

@@ -7,6 +7,7 @@ namespace App\ApiResources\Access;
 use ApiPlatform\Metadata\ApiProperty;
 use ApiPlatform\Metadata\ApiResource;
 use ApiPlatform\Metadata\Get;
+use ApiPlatform\Metadata\Patch;
 use ApiPlatform\Metadata\Put;
 use App\ApiResources\ApiResourcesInterface;
 use App\State\Processor\Access\AdminAccessProcessor;
@@ -22,7 +23,7 @@ use Symfony\Component\Validator\Constraints as Assert;
             uriTemplate: '/admin-access/{id}',
             defaults: ['id' => 0]
         ),
-        new Put(
+        new Patch(
             uriTemplate: '/admin-access/{id}',
             defaults: ['id' => 0],
             security: '(is_granted("ROLE_ADMIN_CORE") and object.getOrganizationId() == user.getOrganization().getId() )'

+ 4 - 0
src/Entity/Billing/ResidenceArea.php

@@ -8,6 +8,7 @@ use ApiPlatform\Metadata\ApiResource;
 use ApiPlatform\Metadata\Delete;
 use ApiPlatform\Metadata\Get;
 use ApiPlatform\Metadata\GetCollection;
+use ApiPlatform\Metadata\Patch;
 use ApiPlatform\Metadata\Post;
 use ApiPlatform\Metadata\Put;
 use App\Attribute\BillingSettingDefaultValue;
@@ -30,6 +31,9 @@ use Doctrine\ORM\Mapping as ORM;
         new Get(
             security: 'is_granted(\'ROLE_ORGANIZATION_VIEW\') and object.getBillingSetting().getOrganization().getId() == user.getOrganization().getId()'
         ),
+        new Patch(
+            security: 'is_granted(\'ROLE_ORGANIZATION\') and object.getBillingSetting().getOrganization().getId() == user.getOrganization().getId()'
+        ),
         new Put(
             security: 'is_granted(\'ROLE_ORGANIZATION\') and object.getBillingSetting().getOrganization().getId() == user.getOrganization().getId()'
         ),

+ 4 - 0
src/Entity/Booking/AttendanceBookingReason.php

@@ -8,6 +8,7 @@ use ApiPlatform\Metadata\ApiResource;
 use ApiPlatform\Metadata\Delete;
 use ApiPlatform\Metadata\Get;
 use ApiPlatform\Metadata\GetCollection;
+use ApiPlatform\Metadata\Patch;
 use ApiPlatform\Metadata\Post;
 use ApiPlatform\Metadata\Put;
 use App\Attribute\OrganizationDefaultValue;
@@ -32,6 +33,9 @@ use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
         new Put(
             security: 'is_granted(\'ROLE_ORGANIZATION\') and object.getOrganization().getId() == user.getOrganization().getId()'
         ),
+        new Patch(
+            security: 'is_granted(\'ROLE_ORGANIZATION\') and object.getOrganization().getId() == user.getOrganization().getId()'
+        ),
         new Delete(
             security: 'is_granted(\'ROLE_ORGANIZATION\') and object.getOrganization().getId() == user.getOrganization().getId()'
         ),

+ 2 - 1
src/Entity/Education/Cycle.php

@@ -7,6 +7,7 @@ namespace App\Entity\Education;
 use ApiPlatform\Metadata\ApiResource;
 use ApiPlatform\Metadata\Get;
 use ApiPlatform\Metadata\GetCollection;
+use ApiPlatform\Metadata\Patch;
 use ApiPlatform\Metadata\Put;
 use App\Entity\Organization\Organization;
 use App\Enum\Education\CycleEnum;
@@ -29,7 +30,7 @@ use Doctrine\ORM\Mapping as ORM;
         new Get(
             security: 'is_granted(\'ROLE_ORGANIZATION_VIEW\') and object.getOrganization().getId() == user.getOrganization().getId()'
         ),
-        new Put(
+        new Patch(
             security: 'is_granted(\'ROLE_ORGANIZATION\') and object.getOrganization().getId() == user.getOrganization().getId()'
         ),
         new GetCollection(

+ 5 - 0
src/Entity/Education/EducationTiming.php

@@ -8,6 +8,7 @@ use ApiPlatform\Metadata\ApiResource;
 use ApiPlatform\Metadata\Delete;
 use ApiPlatform\Metadata\Get;
 use ApiPlatform\Metadata\GetCollection;
+use ApiPlatform\Metadata\Patch;
 use ApiPlatform\Metadata\Post;
 use ApiPlatform\Metadata\Put;
 use App\Attribute\OrganizationDefaultValue;
@@ -35,6 +36,10 @@ use Doctrine\ORM\Mapping as ORM;
             security: 'object.getOrganization().getId() == user.getOrganization().getId()',
             securityMessage: 'You do not have access to this course duration'
         ),
+        new Patch(
+            security: 'object.getOrganization().getId() == user.getOrganization().getId()',
+            securityMessage: 'You do not have access to this course duration'
+        ),
         new Delete(
             security: 'object.getOrganization().getId() == user.getOrganization().getId()',
             securityMessage: 'You do not have access to this course duration'

+ 3 - 2
src/Entity/Organization/Parameters.php

@@ -6,6 +6,7 @@ namespace App\Entity\Organization;
 
 use ApiPlatform\Metadata\ApiResource;
 use ApiPlatform\Metadata\Get;
+use ApiPlatform\Metadata\Patch;
 use ApiPlatform\Metadata\Put;
 use App\Entity\Access\Access;
 use App\Entity\Core\File;
@@ -34,7 +35,7 @@ use Symfony\Component\Validator\Constraints as Assert;
         new Get(
             security: 'is_granted("ROLE_ORGANIZATION_VIEW") and object.getOrganization().getId() == user.getOrganization().getId()'
         ),
-        new Put(
+        new Patch(
             security: 'is_granted("ROLE_ORGANIZATION") and object.getOrganization().getId() == user.getOrganization().getId()'
         ),
     ],
@@ -50,7 +51,7 @@ class Parameters
     #[ORM\GeneratedValue]
     private ?int $id = null;
 
-    #[ORM\OneToOne(targetEntity: Organization::class, mappedBy: 'parameters')]
+    #[ORM\OneToOne(targetEntity: Organization::class, mappedBy: 'parameters', cascade: ['persist', 'remove'])]
     private ?Organization $organization = null;
 
     #[ORM\Column(type: 'date', nullable: true)]

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

@@ -9,8 +9,8 @@ use ApiPlatform\Metadata\ApiFilter;
 use ApiPlatform\Metadata\ApiResource;
 use ApiPlatform\Metadata\Get;
 use ApiPlatform\Metadata\GetCollection;
+use ApiPlatform\Metadata\Patch;
 use ApiPlatform\Metadata\Post;
-use ApiPlatform\Metadata\Put;
 use App\Attribute\OrganizationDefaultValue;
 use App\Repository\Organization\SubdomainRepository;
 use App\State\Processor\Organization\SubdomainProcessor;
@@ -28,7 +28,7 @@ use Symfony\Component\Validator\Constraints as Assert;
         new Get(
             security: 'is_granted("ROLE_ORGANIZATION_VIEW") and object.getOrganization().getId() == user.getOrganization().getId()'
         ),
-        new Put(
+        new Patch(
             security: 'is_granted("ROLE_ORGANIZATION") and object.getOrganization().getId() == user.getOrganization().getId()'
         ),
         new GetCollection(

+ 1 - 1
src/Service/OnChange/Organization/OnParametersChange.php

@@ -19,7 +19,7 @@ use App\Service\Organization\Utils as OrganizationUtils;
 use Symfony\Component\Messenger\MessageBusInterface;
 
 /**
- * Classe OnParametersChange qui comporte toutes les opérations automatiquent se produisant lors de l'évolution des paramètres.
+ * Classe OnParametersChange qui comporte toutes les opérations automatiques se produisant lors de l'évolution des paramètres.
  */
 class OnParametersChange extends OnChangeDefault
 {