Doctrine 中的多态单向关系就像 Eloquent 中的那样?

Ark*_*ias 6 symfony doctrine-orm

我的网站上有通知,每个通知都可以单向与帖子或视频相关。

我们需要显示网站的所有通知,并为每一个通知显示有关相关实体(照片或视频)的一些信息。我永远不需要获取与视频相关的所有通知,这就是它是单向的原因。

在 Eloquent (Laravel) 中,我们可以这样做:https://laravel.com/docs/5.3/eloquent-relationships#polymorphic-relations

posts
    id - integer
    title - string
    body - text

videos
    id - integer
    title - string
    url - string

notifications
    id - integer
    body - text
    notificationable_id - integer
    notificationable_type - string
Run Code Online (Sandbox Code Playgroud)

现在,如何在 Doctrine 中使用 Symfony 做同样的事情?

我希望最终能达到这样的代码:

interface NotificationableInterface {}

class Video implements NotificationableInterface {}
class Post implements NotificationableInterface {}

class Notification {
    ....
    /**
     * @return NotificationableInterface
     */
    public function getRelatedEntity() {
    }
Run Code Online (Sandbox Code Playgroud)

Doctrine 可以做到这一点吗?如何实施?

感谢您的帮助。