Skip to content

Instantly share code, notes, and snippets.

@clemherreman
Created February 20, 2020 16:31
Show Gist options
  • Save clemherreman/165a56b11f04807c52b792b2845f7dbc to your computer and use it in GitHub Desktop.
Save clemherreman/165a56b11f04807c52b792b2845f7dbc to your computer and use it in GitHub Desktop.
APIP single table inheritance
<?php
/**
* @ORM\Entity
*
* @ApiResource(
* normalizationContext={"groups"={"creditNote:read"}},
* collectionOperations={
* "get"={"controller"=NotFoundAction::class}
* },
* itemOperations={
* "get"
* }
* )
*/
class CreditNote extends Redeemable
{
}
<?php
/**
* Class representing either a Voucher or a CreditNote.
*
* @ORM\Entity
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({"voucher"=Voucher::class, "credit_note"=CreditNote::class})
*/
abstract class Redeemable
{
}
<?php
/**
* @ORM\Entity
*
* @ApiResource(
* normalizationContext={"groups"={"voucher:read"}},
* collectionOperations={
* "get"={"controller"=NotFoundAction::class}
* },
* itemOperations={
* "get"
* }
* )
*/
class Voucher extends Redeemable
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment