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