i'm trying to invoke an entity getter with reflection but it returns some strange objects:
Proxies__CG__\\Foo\\InvoiceBundle\\Entity\\Invoice
instead of
Foo\\InvoiceBundle\\Entity\\Invoice
Here is my code:
class ProperProperty extends \ReflectionProperty{
public function __construct(){
parent::__construct();
}
private function getGetterName($propertyName){
$ret = "get" . ucfirst($propertyName);
return $ret;
}
public function getDoctrineValue($class, $object){
$propertyName = $this->getName();
$getterName = $this->getGetterName($propertyName);
$reflectionMethod = new \ReflectionMethod($class, $getterName);
$ret = $reflectionMethod->invoke($object);
return $ret;
}
}
I saw that proxy classes where kinda lazy-loaded object, is there anyway to force this load ? Thanks :D
If someone is interested of how to fill your empty proxy:
protected function loadProxy($object){
$class = get_class($object);
if (strpos($class, "Proxies") === false)
return;
$methodName = "__load";
$reflectionMethod = new \ReflectionMethod($class, $methodName);
$ret = $reflectionMethod->invoke($object);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.