I am wondering how to approach the use case that I need different types of an entity. In my case, I want to create an Approval-Entity. Yet there are different kinds of approvals I have to tell apart.
I am wondering if I should create a type
field and then handle the different types via type constants that I also store in the database, e.g.:
use Doctrine\ORM\Mapping as ORM;
/**
* Approval
*
* @ORM\Table()
* @ORM\Entity(repositoryClass="Hn\AssetDbBundle\Entity\ApprovalRepository")
*/
class Approval
{
const SOME_TYPE = 1;
const SOME_OTHER_TYPE = 2;
/**
* @var integer
* @ORM\Column(name="type", type="integer")
*/
private $type;
}
Another approach would be to make my Approval
Entity abstract then extend SomeTypeApproval
and SomeOtherTypeApproval
from it. This seems like a more OOP solution to me but as the question should imply, I am somewhat unsure.
So I am wondering what the up- and downsides of each approach are in order to decide which route I should follow.