Fixed excpetion that no IRI could be generated if a new Part was created via POST operation via API

This was because the objectSerializer in PartNormalizer messed up the JSONLD IRI generation of the paramaters property. It tried to generate this IRI via the Part ressource class, which is not possible
This commit is contained in:
Jan Böhmer 2024-01-05 23:38:49 +01:00
parent d20b668e87
commit df23ba07ba
3 changed files with 6 additions and 5 deletions

View file

@ -104,8 +104,6 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
#[ApiFilter(RangeFilter::class, properties: ["mass", "minamount"])]
#[ApiFilter(DateFilter::class, strategy: DateFilter::EXCLUDE_NULL)]
#[ApiFilter(OrderFilter::class, properties: ['name', 'id', 'addedDate', 'lastModified'])]
#[DocumentedAPIProperty(schemaName: 'Part-Read', property: 'total_instock', type: 'number', nullable: false,
description: 'The total amount of this part in stock (sum of all part lots).')]
class Part extends AttachmentContainingDBElement
{
use AdvancedPropertyTrait;

View file

@ -28,6 +28,7 @@ use App\Entity\Parts\PartLot;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Attribute\SerializedName;
use Symfony\Component\Validator\Constraints as Assert;
/**
@ -181,6 +182,8 @@ trait InstockTrait
*
* @return float The amount of parts given in partUnit
*/
#[Groups(['simple', 'extended', 'full', 'part:read'])]
#[SerializedName('total_instock')]
public function getAmountSum(): float
{
//TODO: Find a method to do this natively in SQL, the current method could be a bit slow