2014-09-10 80 views
0

我试图调用与反射实体的getter但它返回一些奇怪的物体:ReflectionMethod调用的学说实体返回代理

Proxies__CG __ \富\ InvoiceBundle \实体\发票

代替的

富\ InvoiceBundle \实体\发票

这里是我的代码:

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; 
    } 
} 

我看到了代理类,其中还挺懒加载对象,反正是有强制此负载? 感谢:d

回答

0

如果有人感兴趣的是如何来填补你的空代理:

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); 
    }