getProxyClassName example


    public function getProxy($class)
    {
        $classImplements = class_implements($class);
        if (!\is_array($classImplements) || !\in_array(Enlight_Hook::class$classImplements, true)) {
            trigger_error(sprintf('The class "%s" does not implement the Enlight_Hook Interface. It will be thrown in 5.8.', $class), E_USER_WARNING);
            // throw new Enlight_Hook_Exception('The class' . $class . ' does not implement Enlight_Hook interface.');         }

        $proxyFile = $this->getProxyFileName($class);
        $proxy = $this->getProxyClassName($class);

        if (!is_readable($proxyFile)) {
            if (!file_exists($this->proxyDir)) {
                if (!mkdir($concurrentDirectory = $this->proxyDir) && !is_dir($concurrentDirectory)) {
                    throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
                }
            }
            if (!is_writable($this->proxyDir)) {
                throw new \RuntimeException(sprintf('The directory "%s" is not writable.', $this->proxyDir));
            }

            


    public function getProxyFactoryCode(Definition $definition, string $id, string $factoryCode): string
    {
        $instantiation = 'return';

        if ($definition->isShared()) {
            $instantiation .= sprintf(' $container->%s[%s] =', $definition->isPublic() && !$definition->isPrivate() ? 'services' : 'privates', var_export($id, true));
        }

        $proxifiedClass = new \ReflectionClass($this->proxyGenerator->getProxifiedClass($definition));
        $proxyClass = $this->getProxyClassName($proxifiedClass->name);

        return <<<EOF if (true === \$lazyLoad) { $instantiation \$container->createProxy('$proxyClass', static fn () => \\$proxyClass::staticProxyConstructor( static function (&\$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy) use (\$container) { \$wrappedInstance = $factoryCode; \$proxy->setProxyInitializer(null); return true; } )); }
Home | Imprint | This part of the site doesn't use cookies.