Created
February 20, 2020 16:31
-
-
Save clemherreman/165a56b11f04807c52b792b2845f7dbc to your computer and use it in GitHub Desktop.
APIP single table inheritance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @ORM\Entity | |
* | |
* @ApiResource( | |
* normalizationContext={"groups"={"creditNote:read"}}, | |
* collectionOperations={ | |
* "get"={"controller"=NotFoundAction::class} | |
* }, | |
* itemOperations={ | |
* "get" | |
* } | |
* ) | |
*/ | |
class CreditNote extends Redeemable | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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