简体   繁体   English

从学说代理对象获取列表ReflectionProperty

[英]Get list ReflectionProperty from doctrine proxy object

Example i got a proxy object from Doctrine manager. 例子我从教义管理器那里得到了一个代理对象。

// $entity is an proxy object from doctrine
$relectionClass = new \ReflectionClass($entity);
$properties = $class->getProperties();

$properties will return us an empty array, because it reflected from doctrine proxy object. $properties将返回一个空数组,因为它从学说代理对象反映出来。

How i can get list of all properties from my object if it's an doctrine proxy object? 如果是教义代理对象,如何从对象中获取所有属性的列表?

You should reflect the real class instead of the proxy. 您应该反映真实的类而不是代理。

Try this (not tested): 试试看(未测试):

$realClass = \Doctrine\Common\Util\ClassUtils::getRealClass(get_class($entity));
$properties = (new \ReflectionClass($realClass))->getProperties();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM