Given the following entities:
class Entity {
protected $id;
}
class User extends Entity {
/** @var Entity */
protected $target;
}
class Document extends Entity {
protected $title;
}
class Report extends Entity {
protected $level;
}
What mapping do I need to create so doctrine can map the User
entity correctly.
The problem here is, I want to be able to have User::$target
use any Entity (hence the Entity
type hint) and later in the code be able to respond accordingly, depending if it's a Document
or a Report
.
This also means, that in the code, I need to be able to fetch either Entity::$title
if it's a Document
or Entity::$level
if it's a Report
.
Can I achieve this with doctrine?