Doctrine如何在从存储库获取时不调用__construct方法创建实体


How Doctrine create an entity without call __construct method when fetch from repository?

我在构造函数中写了下面的代码:

public function __construct()
{
    die('creating entity');
}

当我创建具有new操作符的实体实例时,如:

$entity = new Entity();

我看到creating entity的文本。

但是当我从repo获取实体时:

$em->getRepository('AcmeDemoBundle:Entity')->find(1)

学说创建实体对象而不调用__construct()方法,我没有看到creating entity文本。

谁能解释一下Doctrine是如何在从存储库加载对象时创建对象的?

创建一个实例而不调用ReflectionClass::newInstanceWithoutConstructor提供的构造函数

Doctrine创建映射实体的实例而不调用Doctrine'ORM'Mapping'ClassMetadataInfo::newInstance()