Compiles scoped proxy types and saves them on the filesystem.

@param ContainerBuilder $builder
@param string $proxyCachePath
@param array<stribg> $additionalProxies
@return string
772076
protected function compileScopedProxies(ContainerBuilder $builder, $proxyCachePath, array $additionalProxies = [])
	{			
		$code = "\t\tpublic function loadScopedProxy(\$typeName) {\n";
		$code .= "\t\tswitch(\$typeName) {\n";
		
		$proxyTypes = [];
		
		foreach($builder->getProxyBindings() as $binding)
		{
			$ref = new \ReflectionClass($binding->getTypeName());
			$proxyTypes[$ref->name] = $ref;
		}
		
		foreach($additionalProxies as $add)
		{
			$ref = new \ReflectionClass($add);
			$proxyTypes[$ref->name] = $ref;
		}
		
		foreach($proxyTypes as $ref)
		{	
			$parent = $ref;
			$mtime = filemtime($ref->getFileName());
			
			while($parent = $ref->getParentClass())
			{
				$mtime = max($mtime, filemtime($parent->getFileName()));
			}
				
			$file = $proxyCachePath . '/' . md5(strtolower($ref->name)) . '.php';
			$create = !is_file($file) || filemtime($file) < $mtime;
				
			if($create)
			{
				$proxyCode = '<?php' . "\n\n" . $this->proxyGenerator->generateProxyCode($ref);
				
				Filesystem::writeFile($file, $proxyCode);
			}
			
			$code .= "\t\t\tcase " . var_export($ref->name, true) . ":\n";
			$code .= "\t\t\t\trequire_once " . var_export($file, true) . ";\n";
			$code .= "\t\t\t\treturn \$typeName . '__scoped';\n";
			$code .= "\t\t\t\tbreak;\n";
		}
		
		$code .= "\t\t}\n";
		$code .= "\t\treturn parent::loadScopedProxy(\$typeName);\n";
		$code .= "\t\t}\n\n";
		
		return $code;
	}
927537
public function writeProxyClassCache()
    {
        $parameters = array(
            'proxyNameSpace' => $this->getProxyNameSpace(),
            'proxyClassName' => $this->proxyClass,
            'shortClassName' => $this->getShortClassName(),
            'originalClassName' => $this->class,
        );
        $proxyClassDefinition = $this->render($this->template, $parameters);
        $this->fs->dumpFile($this->proxyClassCacheFilename, $proxyClassDefinition);

        return $this;
    }
665152
public static function createConfiguration($isDevMode = false, $proxyDir = null, ?Cache $cache = null)
    {
        $proxyDir = $proxyDir ?: sys_get_temp_dir();

        $cache = self::createCacheConfiguration($isDevMode, $proxyDir, $cache);

        $config = new Configuration();
        $config->setMetadataCacheImpl($cache);
        $config->setQueryCacheImpl($cache);
        $config->setResultCacheImpl($cache);
        $config->setProxyDir($proxyDir);
        $config->setProxyNamespace('DoctrineProxies');
        $config->setAutoGenerateProxyClasses($isDevMode);

        return $config;
    }
1011983
private function compileTemplate($templatePath, $destinationPath, $data = null)
    {
        if ($data == null) {
            $data = $destinationPath;
            $destinationPath = null;
        }
        
        if (! isset($this->templates[$templatePath])) {
            $this->templates[$templatePath] = file_get_contents($templatePath);
        }
        
        $compiled = preg_replace_callback('/{{\s*([A-z0-9_-]+)\s*}}/', function ($matches) use ($data) {
            if (isset($data[$matches[1]])) {
                return $data[$matches[1]];
            }
            
            return $matches[0];
        }, $this->templates[$templatePath]);
        
        if ($destinationPath) {
            file_put_contents($destinationPath, $compiled);
        }
        
        return $compiled;
    }
996283
protected function loadBuilders(array $builders, ContainerBuilder $container)
    {
        foreach ($builders as $builderName => $builder) {
            $definition = $container
                ->register(
                    'elcodi.sitemap_builder.' . $builderName,
                    'Elcodi\Component\Sitemap\Builder\SitemapBuilder'
                )
                ->addArgument(new Reference($builder['renderer']))
                ->addArgument($builder['path'])
                ->setPublic(true);

            $this
                ->addBuilderElements(
                    $definition,
                    $builder['statics'],
                    'static'
                )
                ->addBuilderElements(
                    $definition,
                    $builder['blocks'],
                    'entity'
                );
        }

        return $this;
    }
599200
private function buildSelectorForExcerpt($locale, &$additionalFields)
    {
        $excerptStructure = $this->structureManager->getStructure('excerpt');
        $extension = $this->extensionManager->getExtension('', 'excerpt');

        foreach ($excerptStructure->getProperties(true) as $property) {
            $additionalFields[$locale][] = [
                'extension' => $extension,
                'target' => 'excerpt',
                'property' => $property->getName(),
                'name' => $property->getName(),
            ];
        }
    }
917192
private function saveProxyToCache(ReflectionClass $class, string $childCode): string
    {
        static $cacheDirSuffix = '/_proxies/';

        $cacheDir          = $this->cachePathManager->getCacheDir() . $cacheDirSuffix;
        $relativePath      = str_replace($this->options['appDir'] . DIRECTORY_SEPARATOR, '', $class->getFileName());
        $proxyRelativePath = str_replace('\\', '/', $relativePath . '/' . $class->getName() . '.php');
        $proxyFileName     = $cacheDir . $proxyRelativePath;
        $dirname           = dirname($proxyFileName);
        if (!file_exists($dirname)) {
            mkdir($dirname, $this->options['cacheFileMode'], true);
        }

        $body = '<?php' . PHP_EOL . $childCode;

        $isVirtualSystem = strpos($proxyFileName, 'vfs') === 0;
        file_put_contents($proxyFileName, $body, $isVirtualSystem ? 0 : LOCK_EX);
        // For cache files we don't want executable bits by default
        chmod($proxyFileName, $this->options['cacheFileMode'] & (~0111));

        return 'include_once AOP_CACHE_DIR . ' . var_export($cacheDirSuffix . $proxyRelativePath, true) . ';';
    }
339188
public function buildLocalFilterRegistries(ContainerBuilder $container)
    {
        $filters = $container->findTaggedServiceIds('spray_persistence.entity_filter');
        foreach ($filters as $filterId => $filterOptions) {
            foreach (array_filter($filterOptions, array($this, 'filterLocalFilterOptions')) as $options) {
                $registryId = $this->determineRegistryIdForRepositoryId($options['repository']);
                $this->attachFilterToRegistry(
                    $this->locateFilterRegistry($container, $registryId),
                    $filterId,
                    $options
                );
                $this->attachRegistryToRepository($container, $registryId, $options['repository']);
            }
        }
    }
885952
private function wrapInstanceWithLazyProxy($className, $instanceConstructor) {
        $proxyParameters = [

        ];
        return $this->getLazyProxyFactory()->createProxy(
            $className,
            function (&$wrappedObject, LazyLoadingInterface $proxy) use ($instanceConstructor) {
                $proxy->setProxyInitializer(null);
                $wrappedObject = $instanceConstructor();
                return true;
            },
            $proxyParameters
        );
    }
364267
public function setProxiesPath(string $proxiesPath)
    {
        if (!\file_exists($proxiesPath) || !\is_dir($proxiesPath) || !\is_writable($proxiesPath)) {
            throw new \RuntimeException(\sprintf('%s directory does not exist or is write protected', $proxiesPath));
        }

        $this->proxiesPath = $proxiesPath;

        return $this;
    }
654197
private static function addCompilerPasses(ContainerBuilder $container, array $passes)
    {
        foreach ($passes as $passClass => $options) {
            if (!class_exists($passClass)) {
                throw new RuntimeException("Symfony DI CompilerPass not found: \"${passClass}\"");
            }

            $pass = new $passClass;
            $type = $options['type'] ?? PassConfig::TYPE_BEFORE_OPTIMIZATION;
            $priority = $options['priority'] ?? 1000;

            $container->addCompilerPass($pass, $type, $priority);
        }
    }
1064844
private static function getProxy(string $name, array $arguments): ProxyInterface
    {
        self::ensurePluginLoad($name);

        $fqcnOrAlias = $arguments[0];
        $alias = $arguments[1] ?? null;

        return ProxyBuilderFactory::get(self::$mockingStrategies[$name])
            ->getProxy($fqcnOrAlias, $alias);
    }
1093227
@SuppressWarnings("deprecation")
	ProxyConfig buildProxyConfig() {
		validateProxy();
		return new ProxyConfig(getProxyHost(), getProxyPort(), getProxyUsername(), getProxyPassword(), getProxyBridgePort());
	}
789435
public static function additionalConfiguration($extensionKey)
    {
        // Get the configuration
        $extConf = self::getSanitizedExtConf($extensionKey);

        if ($extConf['cachingConfigEnable'] == 1) {
            self::handleCachingConfiguration($extConf);
        }
    }
278467
private function createLoader(ContainerBuilder $container, string $basePath): LoaderInterface
    {
        $fileLocator = new FileLocator($basePath);
        $loader = new DelegatingLoader(new LoaderResolver([
            new Loader\XmlFileLoader($container, $fileLocator),
            new Loader\YamlFileLoader($container, $fileLocator),
            new Loader\PhpFileLoader($container, $fileLocator),
            new Loader\GlobFileLoader($container, $fileLocator)
        ]));

        return $loader;
    }
516842
protected function prepareParameters(ReflectionMethod $constructor, $additionalParameters)
    {
        $parameters = array();
        foreach ($constructor->getParameters() as $parameter) {
            $parameterValue = null;
        
            if (isset($additionalParameters[$parameter->name])) {
                $parameterValue = $additionalParameters[$parameter->name];
            } else if ($parameter->getClass() !== null) {
                $parameterValue = $this->getInstance($parameter->getClass());
            }
        
            if ($parameterValue === null) {
                throw new Exception('Cannot find correct value for parameter "' . $parameter->name . '" in class "' . $constructor->class . '".');
            }
        
            $parameters[] = $parameterValue;
        }
        
        return $parameters;
    }
251047
public static function generate(
        $compiledRouterPath,
        callable $routeDefinitionsCallback,
        callable $routeCollectionFactory = null,
        callable $routerCompilerFactory = null,
        $forceCompile = false
    ) {
        if (!$forceCompile) {
            $compiledRouter = @include $compiledRouterPath;

            if ($compiledRouter) {
                return $compiledRouter;
            }
        }

        /** @var RouteCollection $routes */
        $routes = $routeCollectionFactory ? $routeCollectionFactory() : new RouteCollection(new RouteParser());

        /** @var RouterCompiler $routeParser */
        $routerCompiler = $routerCompilerFactory ? $routerCompilerFactory() : new TreeBasedRouterCompiler();

        $routeDefinitionsCallback($routes);

        file_put_contents($compiledRouterPath, $routerCompiler->compileRouter($routes));

        return require $compiledRouterPath;
    }