protected function makeEntityProxy($entity, $relation, $class)
    {
        $proxyPath = Manager::getInstance()->getProxyPath();

        if ($proxyPath !== null) {
            $proxyConfig = new Configuration();
            $proxyConfig->setProxiesTargetDir($proxyPath);

            $factory = new LazyLoadingValueHolderFactory($proxyConfig);
        } else {
            $factory = new LazyLoadingValueHolderFactory();
        }

        $initializer = function (&$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer) use ($entity, $relation) {
            $entityMap = Manager::getMapper($entity)->getEntityMap();

            $wrappedObject = $entityMap->$relation($entity)->getResults($relation);

            $initializer = null; // disable initialization
            return true; // confirm that initialization occurred correctly
        };

        return $factory->createProxy($class, $initializer);
    }
protected function makeEntityProxy($entity, $relation, $class)
    {
        $proxyPath = Manager::getInstance()->getProxyPath();

        if ($proxyPath !== null) {
            $proxyConfig = new Configuration();
            $proxyConfig->setProxiesTargetDir($proxyPath);

            $factory = new LazyLoadingValueHolderFactory($proxyConfig);
        } else {
            $factory = new LazyLoadingValueHolderFactory();
        }

        $initializer = function (&$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer) use ($entity, $relation) {
            $entityMap = Manager::getMapper($entity)->getEntityMap();

            $wrappedObject = $entityMap->$relation($entity)->getResults($relation);

            $initializer = null; // disable initialization
            return true; // confirm that initialization occurred correctly
        };

        return $factory->createProxy($class, $initializer);
    }
protected function makeEntityProxy ( $ entity , $ relation , $ class ) { $ proxyPath = Manager :: getInstance ( ) -> getProxyPath ( ) ; if ( $ proxyPath !== null ) { $ proxyConfig = new Configuration ( ) ; $ proxyConfig -> setProxiesTargetDir ( $ proxyPath ) ; $ factory = new LazyLoadingValueHolderFactory ( $ proxyConfig ) ; } else { $ factory = new LazyLoadingValueHolderFactory ( ) ; } $ initializer = function ( & $ wrappedObject , LazyLoadingInterface $ proxy , $ method , array $ parameters , & $ initializer ) use ( $ entity , $ relation ) { $ entityMap = Manager :: getMapper ( $ entity ) -> getEntityMap ( ) ; $ wrappedObject = $ entityMap -> $ relation ( $ entity ) -> getResults ( $ relation ) ; $ initializer = null ; // disable initialization return true ; // confirm that initialization occurred correctly } ; return $ factory -> createProxy ( $ class , $ initializer ) ; }
Create an instance of a proxy object, extending the actual
related class.

@param mixed  $entity   parent object
@param string $relation the name of the relationship method
@param string $class    the class name of the related object

@return mixed
Create an instance of a proxy object extending the actual related class .