How Doctrine create an entity without call __construct method when fetch from repository?(从存储库获取时,Doctrine 如何在不调用 __construct 方法的情况下创建实体?)
问题描述
我在构造函数中写了下一段代码:
I wrote next code in constructor:
public function __construct()
{
die('creating entity');
}
当我使用 new
运算符创建实体实例时,例如:
When I create instance of entity with new
operator like:
$entity = new Entity();
我看到 creating entity
文本.
但是当我从 repo 中获取实体时:
But when I get entity from repo:
$em->getRepository('AcmeDemoBundle:Entity')->find(1)
Doctrine 创建实体对象而不调用 __construct()
方法,我没有看到 creating entity
文本.
Doctrine create an object of entity without calling __construct()
method and I don't see the creating entity
text.
谁能解释 Doctrine 在从存储库加载对象时如何创建对象?
Can anybody explain how Doctrine creating an object when loading them from repository?
推荐答案
在不调用构造函数的情况下创建实例 ReflectionClass::newInstanceWithoutConstructor
To create an instance without invoking constructor available with ReflectionClass::newInstanceWithoutConstructor
Doctrine 创建映射实体的实例而不在 DoctrineORMMappingClassMetadataInfo::newInstance()
Doctrine create instances of mapped entities without invoking constructor in DoctrineORMMappingClassMetadataInfo::newInstance()
这篇关于从存储库获取时,Doctrine 如何在不调用 __construct 方法的情况下创建实体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从存储库获取时,Doctrine 如何在不调用 __construct 方法的情况下创建实体?


- 从 PHP 中的输入表单获取日期 2022-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- Laravel 仓库 2022-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01