LazyLoadingValueHolderGenerator example

use ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator;
use ProxyManager\ProxyGenerator\ProxyGeneratorInterface;
use Symfony\Component\DependencyInjection\Definition;

/** * @internal */
class ProxyGenerator implements ProxyGeneratorInterface
{
    public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator, array $proxyOptions = []): void
    {
        (new LazyLoadingValueHolderGenerator())->generate($originalClass$classGenerator$proxyOptions);

        foreach ($classGenerator->getMethods() as $method) {
            if (str_starts_with($originalClass->getFilename(), __FILE__)) {
                $method->setBody(str_replace(var_export($originalClass->name, true), '__CLASS__', $method->getBody()));
            }
        }

        if (str_starts_with($originalClass->getFilename(), __FILE__)) {
            $interfaces = $classGenerator->getImplementedInterfaces();
            array_pop($interfaces);
            $classGenerator->setImplementedInterfaces(array_merge($interfaces$originalClass->getInterfaceNames()));
        }
Home | Imprint | This part of the site doesn't use cookies.