فهرست منبع

add get route for organization, fix enum provider

Olivier Massot 2 سال پیش
والد
کامیت
de4d341741
2فایلهای تغییر یافته به همراه9 افزوده شده و 7 حذف شده
  1. 3 1
      src/Entity/Organization/Organization.php
  2. 6 6
      src/State/Provider/Enum/EnumProvider.php

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

@@ -52,7 +52,9 @@ use Symfony\Component\Validator\Constraints as Assert;
  * Security :
  *   * @see App\Doctrine\Organization\CurrentOrganizationExtension
  */
-#[ApiResource(operations: [])] //
+#[ApiResource(operations: [
+    new Get(security: "object.getId() == user.getOrganization().getId()")
+])] //
 //#[Auditable]
 #[ORM\Entity(repositoryClass: OrganizationRepository::class)]
 class Organization

+ 6 - 6
src/State/Provider/Enum/EnumProvider.php

@@ -38,12 +38,12 @@ final class EnumProvider implements ProviderInterface
             throw new RuntimeException('not supported', 500);
         }
 
-        $id = $uriVariables['id'];
+        $name = $uriVariables['name'];
         $enums = $this->parser->yamlParser($this->opentalentConfig, 'enum.yaml');
-        $enumClass = $enums['opentalent'][$id];
+        $enumClass = $enums['opentalent'][$name];
 
         if(!$enumClass) {
-            throw new NotFoundHttpException(sprintf('Enum %s does\'nt exist', $id));
+            throw new NotFoundHttpException(sprintf('Enum %s does\'nt exist', $name));
         }
 
         try{
@@ -52,12 +52,12 @@ final class EnumProvider implements ProviderInterface
                 'toArray'
             );
         }catch (Exception){
-            throw new NotFoundHttpException(sprintf('Enum %s does\'nt exist', $id));
+            throw new NotFoundHttpException(sprintf('Enum %s does\'nt exist', $name));
         }
 
         $enumResponse = new Enum();
-        $enumResponse->setName($id);
+        $enumResponse->setName($name);
         $enumResponse->setItems($items);
         return $enumResponse;
     }
-}
+}