I wrote next code in constructor:
public function __construct()
{
die('creating entity');
}
When I create instance of entity with new
operator like:
$entity = new Entity();
I see the creating entity
text.
But when I get entity from repo:
$em->getRepository('AcmeDemoBundle:Entity')->find(1)
Doctrine create an object of entity without calling __construct()
method and I don't see the creating entity
text.
Can anybody explain how Doctrine creating an object when loading them from repository?
To create an instance without invoking constructor available with ReflectionClass::newInstanceWithoutConstructor
Doctrine create instances of mapped entities without invoking constructor in Doctrine\ORM\Mapping\ClassMetadataInfo::newInstance()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With