diff --git a/src/Entity/EDA/EDACategoryInfo.php b/src/Entity/EDA/EDACategoryInfo.php index 2b8ecda7..db56485a 100644 --- a/src/Entity/EDA/EDACategoryInfo.php +++ b/src/Entity/EDA/EDACategoryInfo.php @@ -26,6 +26,7 @@ namespace App\Entity\EDA; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Embeddable; +use Symfony\Component\Serializer\Annotation\Groups; #[Embeddable] class EDACategoryInfo @@ -34,26 +35,32 @@ class EDACategoryInfo * @var string|null The reference prefix of the Part in the schematic. E.g. "R" for resistors, or "C" for capacitors. */ #[Column(type: Types::STRING, nullable: true)] + #[Groups(['full', 'category:read', 'category:write'])] private ?string $reference_prefix = null; /** @var bool|null If this is true, then this part is invisible for the EDA software */ #[Column(type: Types::BOOLEAN, nullable: true)] + #[Groups(['full', 'category:read', 'category:write'])] private ?bool $invisible = null; /** @var bool|null If this is set to true, then this part will be excluded from the BOM */ #[Column(type: Types::BOOLEAN, nullable: true)] + #[Groups(['full', 'category:read', 'category:write'])] private ?bool $exclude_from_bom = null; /** @var bool|null If this is set to true, then this part will be excluded from the board/the PCB */ #[Column(type: Types::BOOLEAN, nullable: true)] + #[Groups(['full', 'category:read', 'category:write'])] private ?bool $exclude_from_board = null; /** @var bool|null If this is set to true, then this part will be excluded in the simulation */ #[Column(type: Types::BOOLEAN, nullable: true)] + #[Groups(['full', 'category:read', 'category:write'])] private ?bool $exclude_from_sim = true; /** @var string|null The KiCAD schematic symbol, which should be used (the path to the library) */ #[Column(type: Types::STRING, nullable: true)] + #[Groups(['full', 'category:read', 'category:write'])] private ?string $kicad_symbol = null; public function getReferencePrefix(): ?string diff --git a/src/Entity/EDA/EDAFootprintInfo.php b/src/Entity/EDA/EDAFootprintInfo.php index 915c1c3d..e8c5719f 100644 --- a/src/Entity/EDA/EDAFootprintInfo.php +++ b/src/Entity/EDA/EDAFootprintInfo.php @@ -26,12 +26,14 @@ namespace App\Entity\EDA; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Embeddable; +use Symfony\Component\Serializer\Annotation\Groups; #[Embeddable] class EDAFootprintInfo { /** @var string|null The KiCAD footprint, which should be used (the path to the library) */ #[Column(type: Types::STRING, nullable: true)] + #[Groups(['full', 'footprint:read', 'footprint:write'])] private ?string $kicad_footprint = null; public function getKicadFootprint(): ?string diff --git a/src/Entity/EDA/EDAPartInfo.php b/src/Entity/EDA/EDAPartInfo.php index 6410a0e2..e314d580 100644 --- a/src/Entity/EDA/EDAPartInfo.php +++ b/src/Entity/EDA/EDAPartInfo.php @@ -26,6 +26,7 @@ namespace App\Entity\EDA; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Embeddable; +use Symfony\Component\Serializer\Annotation\Groups; #[Embeddable] class EDAPartInfo @@ -34,34 +35,42 @@ class EDAPartInfo * @var string|null The reference prefix of the Part in the schematic. E.g. "R" for resistors, or "C" for capacitors. */ #[Column(type: Types::STRING, nullable: true)] + #[Groups(['full', 'eda_info:read', 'eda_info:write'])] private ?string $reference_prefix = null; /** @var string|null The value, which should be shown together with the part (e.g. 470 for a 470 Ohm resistor) */ #[Column(type: Types::STRING, nullable: true)] + #[Groups(['full', 'eda_info:read', 'eda_info:write'])] private ?string $value = null; /** @var bool|null If this is true, then this part is invisible for the EDA software */ #[Column(type: Types::BOOLEAN, nullable: true)] + #[Groups(['full', 'eda_info:read', 'eda_info:write'])] private ?bool $invisible = null; /** @var bool|null If this is set to true, then this part will be excluded from the BOM */ #[Column(type: Types::BOOLEAN, nullable: true)] + #[Groups(['full', 'eda_info:read', 'eda_info:write'])] private ?bool $exclude_from_bom = null; /** @var bool|null If this is set to true, then this part will be excluded from the board/the PCB */ #[Column(type: Types::BOOLEAN, nullable: true)] + #[Groups(['full', 'eda_info:read', 'eda_info:write'])] private ?bool $exclude_from_board = null; /** @var bool|null If this is set to true, then this part will be excluded in the simulation */ #[Column(type: Types::BOOLEAN, nullable: true)] - private ?bool $exclude_from_sim = true; + #[Groups(['full', 'eda_info:read', 'eda_info:write'])] + private ?bool $exclude_from_sim = null; /** @var string|null The KiCAD schematic symbol, which should be used (the path to the library) */ #[Column(type: Types::STRING, nullable: true)] + #[Groups(['full', 'eda_info:read', 'eda_info:write'])] private ?string $kicad_symbol = null; /** @var string|null The KiCAD footprint, which should be used (the path to the library) */ #[Column(type: Types::STRING, nullable: true)] + #[Groups(['full', 'eda_info:read', 'eda_info:write'])] private ?string $kicad_footprint = null; public function __construct() diff --git a/src/Entity/Parts/Category.php b/src/Entity/Parts/Category.php index f2f56e4a..e5e1f907 100644 --- a/src/Entity/Parts/Category.php +++ b/src/Entity/Parts/Category.php @@ -190,6 +190,7 @@ class Category extends AbstractPartsContainingDBElement #[Assert\Valid] #[ORM\Embedded(class: EDACategoryInfo::class)] + #[Groups(['full', 'category:read', 'category:write'])] protected EDACategoryInfo $eda_info; public function __construct() diff --git a/src/Entity/Parts/Footprint.php b/src/Entity/Parts/Footprint.php index ecdec525..d02d010d 100644 --- a/src/Entity/Parts/Footprint.php +++ b/src/Entity/Parts/Footprint.php @@ -143,6 +143,7 @@ class Footprint extends AbstractPartsContainingDBElement #[Assert\Valid] #[ORM\Embedded(class: EDAFootprintInfo::class)] + #[Groups(['full', 'footprint:read', 'footprint:write'])] protected EDAFootprintInfo $eda_info; public function __construct() diff --git a/src/Entity/Parts/Part.php b/src/Entity/Parts/Part.php index 5581a38b..88834191 100644 --- a/src/Entity/Parts/Part.php +++ b/src/Entity/Parts/Part.php @@ -85,7 +85,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; #[ApiResource( operations: [ new Get(normalizationContext: ['groups' => ['part:read', 'provider_reference:read', 'api:basic:read', 'part_lot:read', - 'orderdetail:read', 'pricedetail:read', 'parameter:read', 'attachment:read'], + 'orderdetail:read', 'pricedetail:read', 'parameter:read', 'attachment:read', 'eda_info:read'], 'openapi_definition_name' => 'Read', ], security: 'is_granted("read", object)'), new GetCollection(security: 'is_granted("@parts.read")'), @@ -94,7 +94,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface; new Delete(security: 'is_granted("delete", object)'), ], normalizationContext: ['groups' => ['part:read', 'provider_reference:read', 'api:basic:read', 'part_lot:read'], 'openapi_definition_name' => 'Read'], - denormalizationContext: ['groups' => ['part:write', 'api:basic:write'], 'openapi_definition_name' => 'Write'], + denormalizationContext: ['groups' => ['part:write', 'api:basic:write', 'eda_info:write'], 'openapi_definition_name' => 'Write'], )] #[ApiFilter(PropertyFilter::class)] #[ApiFilter(EntityFilter::class, properties: ["category", "footprint", "manufacturer", "partUnit"])] diff --git a/src/Entity/Parts/PartTraits/EDATrait.php b/src/Entity/Parts/PartTraits/EDATrait.php index d051f4fe..a5bf0daf 100644 --- a/src/Entity/Parts/PartTraits/EDATrait.php +++ b/src/Entity/Parts/PartTraits/EDATrait.php @@ -26,12 +26,14 @@ namespace App\Entity\Parts\PartTraits; use App\Entity\EDA\EDAPartInfo; use Doctrine\ORM\Mapping\Column; use Doctrine\ORM\Mapping\Embedded; +use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints\Valid; trait EDATrait { #[Valid] #[Embedded(class: EDAPartInfo::class)] + #[Groups(['full', 'part:read', 'part:write'])] protected EDAPartInfo $eda_info; public function getEdaInfo(): EDAPartInfo