From 0eba7121aa83d24bafa34e93c6dc388e550cf958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Thu, 25 Jun 2026 20:16:44 +0200 Subject: [PATCH] Merged subchildren operations on APIPlatform into one APIResource, as havinng multiple is deprecated --- src/Entity/Attachments/AttachmentType.php | 17 ++++++----------- src/Entity/Parts/Category.php | 19 ++++++------------- src/Entity/Parts/Footprint.php | 19 ++++++------------- src/Entity/Parts/Manufacturer.php | 19 ++++++------------- src/Entity/Parts/MeasurementUnit.php | 19 ++++++------------- src/Entity/Parts/StorageLocation.php | 19 ++++++------------- src/Entity/Parts/Supplier.php | 17 ++++++----------- src/Entity/PriceInformations/Currency.php | 19 ++++++------------- src/Entity/PriceInformations/Orderdetail.php | 20 +++++++------------- src/Entity/ProjectSystem/Project.php | 19 ++++++------------- src/Entity/ProjectSystem/ProjectBOMEntry.php | 19 ++++++------------- 11 files changed, 67 insertions(+), 139 deletions(-) diff --git a/src/Entity/Attachments/AttachmentType.php b/src/Entity/Attachments/AttachmentType.php index 7a314ffe..03bb8031 100644 --- a/src/Entity/Attachments/AttachmentType.php +++ b/src/Entity/Attachments/AttachmentType.php @@ -65,21 +65,16 @@ use Symfony\Component\Validator\Constraints as Assert; new Post(securityPostDenormalize: 'is_granted("create", object)'), new Patch(security: 'is_granted("edit", object)'), new Delete(security: 'is_granted("delete", object)'), + new GetCollection( + uriTemplate: '/attachment_types/{id}/children.{_format}', + uriVariables: ['id' => new Link(fromProperty: 'children', fromClass: AttachmentType::class)], + openapi: new Operation(summary: 'Retrieves the children elements of an attachment type.'), + security: 'is_granted("@attachment_types.read")' + ), ], normalizationContext: ['groups' => ['attachment_type:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'], denormalizationContext: ['groups' => ['attachment_type:write', 'api:basic:write', 'attachment:write', 'parameter:write'], 'openapi_definition_name' => 'Write'], )] -#[ApiResource( - uriTemplate: '/attachment_types/{id}/children.{_format}', - operations: [ - new GetCollection(openapi: new Operation(summary: 'Retrieves the children elements of an attachment type.'), - security: 'is_granted("@attachment_types.read")') - ], - uriVariables: [ - 'id' => new Link(fromProperty: 'children', fromClass: AttachmentType::class) - ], - normalizationContext: ['groups' => ['attachment_type:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'] -)] #[ApiFilter(PropertyFilter::class)] #[ApiFilter(LikeFilter::class, properties: ["name", "comment"])] #[ApiFilter(DateFilter::class, strategy: DateFilterInterface::EXCLUDE_NULL)] diff --git a/src/Entity/Parts/Category.php b/src/Entity/Parts/Category.php index 22f8a3e4..80fcc43c 100644 --- a/src/Entity/Parts/Category.php +++ b/src/Entity/Parts/Category.php @@ -68,23 +68,16 @@ use Symfony\Component\Validator\Constraints as Assert; new Post(securityPostDenormalize: 'is_granted("create", object)'), new Patch(security: 'is_granted("edit", object)'), new Delete(security: 'is_granted("delete", object)'), + new GetCollection( + uriTemplate: '/categories/{id}/children.{_format}', + uriVariables: ['id' => new Link(fromProperty: 'children', fromClass: Category::class)], + openapi: new Operation(summary: 'Retrieves the children elements of a category.'), + security: 'is_granted("@categories.read")' + ), ], normalizationContext: ['groups' => ['category:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'], denormalizationContext: ['groups' => ['category:write', 'api:basic:write', 'attachment:write', 'parameter:write'], 'openapi_definition_name' => 'Write'], )] -#[ApiResource( - uriTemplate: '/categories/{id}/children.{_format}', - operations: [ - new GetCollection( - openapi: new Operation(summary: 'Retrieves the children elements of a category.'), - security: 'is_granted("@categories.read")' - ) - ], - uriVariables: [ - 'id' => new Link(fromProperty: 'children', fromClass: Category::class) - ], - normalizationContext: ['groups' => ['category:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'] -)] #[ApiFilter(PropertyFilter::class)] #[ApiFilter(LikeFilter::class, properties: ["name", "comment"])] #[ApiFilter(DateFilter::class, strategy: DateFilterInterface::EXCLUDE_NULL)] diff --git a/src/Entity/Parts/Footprint.php b/src/Entity/Parts/Footprint.php index 3d8be686..2027a310 100644 --- a/src/Entity/Parts/Footprint.php +++ b/src/Entity/Parts/Footprint.php @@ -67,23 +67,16 @@ use Symfony\Component\Validator\Constraints as Assert; new Post(securityPostDenormalize: 'is_granted("create", object)'), new Patch(security: 'is_granted("edit", object)'), new Delete(security: 'is_granted("delete", object)'), + new GetCollection( + uriTemplate: '/footprints/{id}/children.{_format}', + uriVariables: ['id' => new Link(fromProperty: 'children', fromClass: Footprint::class)], + openapi: new Operation(summary: 'Retrieves the children elements of a footprint.'), + security: 'is_granted("@footprints.read")' + ), ], normalizationContext: ['groups' => ['footprint:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'], denormalizationContext: ['groups' => ['footprint:write', 'api:basic:write', 'attachment:write', 'parameter:write'], 'openapi_definition_name' => 'Write'], )] -#[ApiResource( - uriTemplate: '/footprints/{id}/children.{_format}', - operations: [ - new GetCollection( - openapi: new Operation(summary: 'Retrieves the children elements of a footprint.'), - security: 'is_granted("@footprints.read")' - ) - ], - uriVariables: [ - 'id' => new Link(fromProperty: 'children', fromClass: Footprint::class) - ], - normalizationContext: ['groups' => ['footprint:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'] -)] #[ApiFilter(PropertyFilter::class)] #[ApiFilter(LikeFilter::class, properties: ["name", "comment"])] #[ApiFilter(DateFilter::class, strategy: DateFilterInterface::EXCLUDE_NULL)] diff --git a/src/Entity/Parts/Manufacturer.php b/src/Entity/Parts/Manufacturer.php index 0edf8232..76526c31 100644 --- a/src/Entity/Parts/Manufacturer.php +++ b/src/Entity/Parts/Manufacturer.php @@ -66,23 +66,16 @@ use Symfony\Component\Validator\Constraints as Assert; new Post(securityPostDenormalize: 'is_granted("create", object)'), new Patch(security: 'is_granted("edit", object)'), new Delete(security: 'is_granted("delete", object)'), + new GetCollection( + uriTemplate: '/manufacturers/{id}/children.{_format}', + uriVariables: ['id' => new Link(fromProperty: 'children', fromClass: Manufacturer::class)], + openapi: new Operation(summary: 'Retrieves the children elements of a manufacturer.'), + security: 'is_granted("@manufacturers.read")' + ), ], normalizationContext: ['groups' => ['manufacturer:read', 'company:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'], denormalizationContext: ['groups' => ['manufacturer:write', 'company:write', 'api:basic:write', 'attachment:write', 'parameter:write'], 'openapi_definition_name' => 'Write'], )] -#[ApiResource( - uriTemplate: '/manufacturers/{id}/children.{_format}', - operations: [ - new GetCollection( - openapi: new Operation(summary: 'Retrieves the children elements of a manufacturer.'), - security: 'is_granted("@manufacturers.read")' - ) - ], - uriVariables: [ - 'id' => new Link(fromProperty: 'children', fromClass: Manufacturer::class) - ], - normalizationContext: ['groups' => ['manufacturer:read', 'company:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'] -)] #[ApiFilter(PropertyFilter::class)] #[ApiFilter(LikeFilter::class, properties: ["name", "comment"])] #[ApiFilter(DateFilter::class, strategy: DateFilterInterface::EXCLUDE_NULL)] diff --git a/src/Entity/Parts/MeasurementUnit.php b/src/Entity/Parts/MeasurementUnit.php index 6dd0b9f2..e775b65b 100644 --- a/src/Entity/Parts/MeasurementUnit.php +++ b/src/Entity/Parts/MeasurementUnit.php @@ -71,23 +71,16 @@ use Symfony\Component\Validator\Constraints\Length; new Post(securityPostDenormalize: 'is_granted("create", object)'), new Patch(security: 'is_granted("edit", object)'), new Delete(security: 'is_granted("delete", object)'), + new GetCollection( + uriTemplate: '/measurement_units/{id}/children.{_format}', + uriVariables: ['id' => new Link(fromProperty: 'children', fromClass: MeasurementUnit::class)], + openapi: new Operation(summary: 'Retrieves the children elements of a MeasurementUnit.'), + security: 'is_granted("@measurement_units.read")' + ), ], normalizationContext: ['groups' => ['measurement_unit:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'], denormalizationContext: ['groups' => ['measurement_unit:write', 'api:basic:write', 'attachment:write', 'parameter:write'], 'openapi_definition_name' => 'Write'], )] -#[ApiResource( - uriTemplate: '/measurement_units/{id}/children.{_format}', - operations: [ - new GetCollection( - openapi: new Operation(summary: 'Retrieves the children elements of a MeasurementUnit.'), - security: 'is_granted("@measurement_units.read")' - ) - ], - uriVariables: [ - 'id' => new Link(fromProperty: 'children', fromClass: MeasurementUnit::class) - ], - normalizationContext: ['groups' => ['measurement_unit:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'] -)] #[ApiFilter(PropertyFilter::class)] #[ApiFilter(LikeFilter::class, properties: ["name", "comment", "unit"])] #[ApiFilter(DateFilter::class, strategy: DateFilterInterface::EXCLUDE_NULL)] diff --git a/src/Entity/Parts/StorageLocation.php b/src/Entity/Parts/StorageLocation.php index 7ba400d9..9571da6e 100644 --- a/src/Entity/Parts/StorageLocation.php +++ b/src/Entity/Parts/StorageLocation.php @@ -67,23 +67,16 @@ use Symfony\Component\Validator\Constraints as Assert; new Post(securityPostDenormalize: 'is_granted("create", object)'), new Patch(security: 'is_granted("edit", object)'), new Delete(security: 'is_granted("delete", object)'), + new GetCollection( + uriTemplate: '/storage_locations/{id}/children.{_format}', + uriVariables: ['id' => new Link(fromProperty: 'children', fromClass: StorageLocation::class)], + openapi: new Operation(summary: 'Retrieves the children elements of a storage location.'), + security: 'is_granted("@storelocations.read")' + ), ], normalizationContext: ['groups' => ['location:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'], denormalizationContext: ['groups' => ['location:write', 'api:basic:write', 'attachment:write', 'parameter:write'], 'openapi_definition_name' => 'Write'], )] -#[ApiResource( - uriTemplate: '/storage_locations/{id}/children.{_format}', - operations: [ - new GetCollection( - openapi: new Operation(summary: 'Retrieves the children elements of a storage location.'), - security: 'is_granted("@storelocations.read")' - ) - ], - uriVariables: [ - 'id' => new Link(fromProperty: 'children', fromClass: StorageLocation::class) - ], - normalizationContext: ['groups' => ['location:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'] -)] #[ApiFilter(PropertyFilter::class)] #[ApiFilter(LikeFilter::class, properties: ["name", "comment"])] #[ApiFilter(DateFilter::class, strategy: DateFilterInterface::EXCLUDE_NULL)] diff --git a/src/Entity/Parts/Supplier.php b/src/Entity/Parts/Supplier.php index 2c004e9e..75cf62d1 100644 --- a/src/Entity/Parts/Supplier.php +++ b/src/Entity/Parts/Supplier.php @@ -71,21 +71,16 @@ use Symfony\Component\Validator\Constraints as Assert; new Post(securityPostDenormalize: 'is_granted("create", object)'), new Patch(security: 'is_granted("edit", object)'), new Delete(security: 'is_granted("delete", object)'), + new GetCollection( + uriTemplate: '/suppliers/{id}/children.{_format}', + uriVariables: ['id' => new Link(fromProperty: 'children', fromClass: Supplier::class)], + openapi: new Operation(summary: 'Retrieves the children elements of a supplier.'), + security: 'is_granted("@manufacturers.read")' + ), ], normalizationContext: ['groups' => ['supplier:read', 'company:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'], denormalizationContext: ['groups' => ['supplier:write', 'company:write', 'api:basic:write', 'attachment:write', 'parameter:write'], 'openapi_definition_name' => 'Write'], )] -#[ApiResource( - uriTemplate: '/suppliers/{id}/children.{_format}', - operations: [new GetCollection( - openapi: new Operation(summary: 'Retrieves the children elements of a supplier.'), - security: 'is_granted("@manufacturers.read")' - )], - uriVariables: [ - 'id' => new Link(fromProperty: 'children', fromClass: Supplier::class) - ], - normalizationContext: ['groups' => ['supplier:read', 'company:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'] -)] #[ApiFilter(PropertyFilter::class)] #[ApiFilter(LikeFilter::class, properties: ["name", "comment"])] #[ApiFilter(DateFilter::class, strategy: DateFilterInterface::EXCLUDE_NULL)] diff --git a/src/Entity/PriceInformations/Currency.php b/src/Entity/PriceInformations/Currency.php index 4a811aa0..507ec810 100644 --- a/src/Entity/PriceInformations/Currency.php +++ b/src/Entity/PriceInformations/Currency.php @@ -71,23 +71,16 @@ use Symfony\Component\Validator\Constraints as Assert; new Post(securityPostDenormalize: 'is_granted("create", object)'), new Patch(security: 'is_granted("edit", object)'), new Delete(security: 'is_granted("delete", object)'), + new GetCollection( + uriTemplate: '/currencies/{id}/children.{_format}', + uriVariables: ['id' => new Link(fromProperty: 'children', fromClass: Currency::class)], + openapi: new Operation(summary: 'Retrieves the children elements of a currency.'), + security: 'is_granted("@currencies.read")' + ), ], normalizationContext: ['groups' => ['currency:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'], denormalizationContext: ['groups' => ['currency:write', 'api:basic:write', 'attachment:write', 'parameter:write'], 'openapi_definition_name' => 'Write'], )] -#[ApiResource( - uriTemplate: '/currencies/{id}/children.{_format}', - operations: [ - new GetCollection( - openapi: new Operation(summary: 'Retrieves the children elements of a currency.'), - security: 'is_granted("@currencies.read")' - ) - ], - uriVariables: [ - 'id' => new Link(fromProperty: 'children', fromClass: Currency::class) - ], - normalizationContext: ['groups' => ['currency:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'] -)] #[ApiFilter(PropertyFilter::class)] #[ApiFilter(LikeFilter::class, properties: ["name", "comment", "iso_code"])] #[ApiFilter(DateFilter::class, strategy: DateFilterInterface::EXCLUDE_NULL)] diff --git a/src/Entity/PriceInformations/Orderdetail.php b/src/Entity/PriceInformations/Orderdetail.php index 56428e3a..8b5c9f7b 100644 --- a/src/Entity/PriceInformations/Orderdetail.php +++ b/src/Entity/PriceInformations/Orderdetail.php @@ -71,23 +71,17 @@ use Symfony\Component\Validator\Constraints\Length; new Post(securityPostDenormalize: 'is_granted("create", object)'), new Patch(security: 'is_granted("edit", object)'), new Delete(security: 'is_granted("delete", object)'), + new GetCollection( + uriTemplate: '/parts/{id}/orderdetails.{_format}', + uriVariables: ['id' => new Link(toProperty: 'part', fromClass: Part::class)], + normalizationContext: ['groups' => ['orderdetail:read', 'pricedetail:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'], + openapi: new Operation(summary: 'Retrieves the orderdetails of a part.'), + security: 'is_granted("@parts.read")' + ), ], normalizationContext: ['groups' => ['orderdetail:read', 'orderdetail:read:standalone', 'api:basic:read', 'pricedetail:read'], 'openapi_definition_name' => 'Read'], denormalizationContext: ['groups' => ['orderdetail:write', 'api:basic:write'], 'openapi_definition_name' => 'Write'], )] -#[ApiResource( - uriTemplate: '/parts/{id}/orderdetails.{_format}', - operations: [ - new GetCollection( - openapi: new Operation(summary: 'Retrieves the orderdetails of a part.'), - security: 'is_granted("@parts.read")' - ) - ], - uriVariables: [ - 'id' => new Link(toProperty: 'part', fromClass: Part::class) - ], - normalizationContext: ['groups' => ['orderdetail:read', 'pricedetail:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'] -)] #[ApiFilter(PropertyFilter::class)] #[ApiFilter(PropertyFilter::class)] #[ApiFilter(LikeFilter::class, properties: ["supplierpartnr", "supplier_product_url"])] diff --git a/src/Entity/ProjectSystem/Project.php b/src/Entity/ProjectSystem/Project.php index f4a3e9de..34e77051 100644 --- a/src/Entity/ProjectSystem/Project.php +++ b/src/Entity/ProjectSystem/Project.php @@ -66,23 +66,16 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; new Post(securityPostDenormalize: 'is_granted("create", object)'), new Patch(security: 'is_granted("edit", object)'), new Delete(security: 'is_granted("delete", object)'), + new GetCollection( + uriTemplate: '/projects/{id}/children.{_format}', + uriVariables: ['id' => new Link(fromProperty: 'children', fromClass: Project::class)], + openapi: new Operation(summary: 'Retrieves the children elements of a project.'), + security: 'is_granted("@projects.read")' + ), ], normalizationContext: ['groups' => ['project:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'], denormalizationContext: ['groups' => ['project:write', 'api:basic:write', 'attachment:write', 'parameter:write'], 'openapi_definition_name' => 'Write'], )] -#[ApiResource( - uriTemplate: '/projects/{id}/children.{_format}', - operations: [ - new GetCollection( - openapi: new Operation(summary: 'Retrieves the children elements of a project.'), - security: 'is_granted("@projects.read")' - ) - ], - uriVariables: [ - 'id' => new Link(fromProperty: 'children', fromClass: Project::class) - ], - normalizationContext: ['groups' => ['project:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'] -)] #[ApiFilter(PropertyFilter::class)] #[ApiFilter(LikeFilter::class, properties: ["name", "comment"])] #[ApiFilter(OrderFilter::class, properties: ['name', 'id', 'addedDate', 'lastModified'])] diff --git a/src/Entity/ProjectSystem/ProjectBOMEntry.php b/src/Entity/ProjectSystem/ProjectBOMEntry.php index 2a7862ec..c016d741 100644 --- a/src/Entity/ProjectSystem/ProjectBOMEntry.php +++ b/src/Entity/ProjectSystem/ProjectBOMEntry.php @@ -63,23 +63,16 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; new Post(uriTemplate: '/project_bom_entries.{_format}', securityPostDenormalize: 'is_granted("create", object)',), new Patch(uriTemplate: '/project_bom_entries/{id}.{_format}', security: 'is_granted("edit", object)',), new Delete(uriTemplate: '/project_bom_entries/{id}.{_format}', security: 'is_granted("delete", object)',), + new GetCollection( + uriTemplate: '/projects/{id}/bom.{_format}', + uriVariables: ['id' => new Link(fromProperty: 'bom_entries', fromClass: Project::class)], + openapi: new Operation(summary: 'Retrieves the BOM entries of the given project.'), + security: 'is_granted("@projects.read")' + ), ], normalizationContext: ['groups' => ['bom_entry:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'], denormalizationContext: ['groups' => ['bom_entry:write', 'api:basic:write'], 'openapi_definition_name' => 'Write'], )] -#[ApiResource( - uriTemplate: '/projects/{id}/bom.{_format}', - operations: [ - new GetCollection( - openapi: new Operation(summary: 'Retrieves the BOM entries of the given project.'), - security: 'is_granted("@projects.read")' - ) - ], - uriVariables: [ - 'id' => new Link(fromProperty: 'bom_entries', fromClass: Project::class) - ], - normalizationContext: ['groups' => ['bom_entry:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'] -)] #[ApiFilter(PropertyFilter::class)] #[ApiFilter(LikeFilter::class, properties: ["name", "comment", 'mountnames'])] #[ApiFilter(RangeFilter::class, properties: ['quantity'])]