Fixed problem that no datastructures with an parent element could be created/edited via API

This fixes issue #512.
The error was introduced when trying to allow the modification of attachments/parameters throught the parent element. We need a seperate write scope to the element, or we end up with an infinite loop.
This commit is contained in:
Jan Böhmer 2024-02-06 22:42:25 +01:00
parent fea8109789
commit 3cc1fb40f0
2 changed files with 4 additions and 4 deletions

View file

@ -77,7 +77,7 @@ use LogicException;
new Delete(security: 'is_granted("delete", object)'),
],
normalizationContext: ['groups' => ['attachment:read', 'attachment:read:standalone', 'api:basic:read'], 'openapi_definition_name' => 'Read'],
denormalizationContext: ['groups' => ['attachment:write', 'api:basic:write'], 'openapi_definition_name' => 'Write'],
denormalizationContext: ['groups' => ['attachment:write', 'attachment:write:standalone', 'api:basic:write'], 'openapi_definition_name' => 'Write'],
)]
#[DocumentedAPIProperty(schemaName: 'Attachment-Read', property: 'media_url', type: 'string', nullable: true,
description: 'The URL to the file, where the attachment file can be downloaded. This can be an internal or external URL.',
@ -142,7 +142,7 @@ abstract class Attachment extends AbstractNamedDBElement
* ORM mapping is done in subclasses (like PartAttachment).
* @phpstan-param T|null $element
*/
#[Groups(['attachment:read:standalone', 'attachment:write'])]
#[Groups(['attachment:read:standalone', 'attachment:write:standalone'])]
protected ?AttachmentContainingDBElement $element = null;
#[ORM\Column(type: Types::BOOLEAN)]

View file

@ -87,7 +87,7 @@ use function sprintf;
new Delete(security: 'is_granted("delete", object)'),
],
normalizationContext: ['groups' => ['parameter:read', 'parameter:read:standalone', 'api:basic:read'], 'openapi_definition_name' => 'Read'],
denormalizationContext: ['groups' => ['parameter:write', 'api:basic:write'], 'openapi_definition_name' => 'Write'],
denormalizationContext: ['groups' => ['parameter:write', 'parameter:write:standalone', 'api:basic:write'], 'openapi_definition_name' => 'Write'],
)]
#[ApiFilter(LikeFilter::class, properties: ["name", "symbol", "unit", "group", "value_text"])]
#[ApiFilter(DateFilter::class, strategy: DateFilter::EXCLUDE_NULL)]
@ -161,7 +161,7 @@ abstract class AbstractParameter extends AbstractNamedDBElement
*
* @var AbstractDBElement|null the element to which this parameter belongs to
*/
#[Groups(['parameter:read:standalone', 'parameter:write'])]
#[Groups(['parameter:read:standalone', 'parameter:write:standalone'])]
protected ?AbstractDBElement $element = null;
public function __construct()