setImplementedInterfaces example

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

    public function getProxifiedClass(Definition $definition): ?string
    {
        if (!$definition->hasTag('proxy')) {
            if (!($class = $definition->getClass()) || !(class_exists($class) || interface_exists($class, false))) {
                return null;
            }

            return (new \ReflectionClass($class))->name;
        }
protected function generateProxyClass($class)
    {
        $reflectionClass = new ReflectionClass($class);

        // Make sure a proxy of the class can be created         CanProxyAssertion::assertClassCanBeProxied($reflectionClass, false);

        // Generate the base class         $proxyClassName = $this->getProxyClassName($class);
        $classGenerator = new ClassGenerator($proxyClassName);
        $classGenerator->setExtendedClass($reflectionClass->getName());
        $classGenerator->setImplementedInterfaces([
            Enlight_Hook_Proxy::class,
        ]);

        // Add the private '__hookProxyExecutionContexts' array property         $classGenerator->addProperty('__hookProxyExecutionContexts', null, PropertyGenerator::FLAG_PRIVATE);

        // Prepare generators for the hooked methods         $hookMethods = $this->getHookedMethods($reflectionClass);
        $hookMethodGenerators = [];
        foreach ($hookMethods as $method) {
            $hookMethodGenerators[$method->getName()] = $this->createMethodGenerator($method);
        }
Home | Imprint | This part of the site doesn't use cookies.