init
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
class AddDebugLogProcessorPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
if (!$container->hasDefinition('profiler')) {
|
||||
return;
|
||||
}
|
||||
if (!$container->hasDefinition('monolog.logger_prototype')) {
|
||||
return;
|
||||
}
|
||||
if (!$container->hasDefinition('debug.log_processor')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$container->getDefinition('monolog.logger_prototype')
|
||||
->setConfigurator([new Reference('debug.debug_logger_configurator'), 'pushDebugLogger']);
|
||||
}
|
||||
}
|
||||
44
backend/vendor/symfony/framework-bundle/DependencyInjection/Compiler/AssetsContextPass.php
vendored
Normal file
44
backend/vendor/symfony/framework-bundle/DependencyInjection/Compiler/AssetsContextPass.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
class AssetsContextPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
if (!$container->hasDefinition('assets.context')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$container->hasDefinition('router.request_context')) {
|
||||
$container->setParameter('asset.request_context.base_path', $container->getParameter('asset.request_context.base_path') ?? '');
|
||||
$container->setParameter('asset.request_context.secure', $container->getParameter('asset.request_context.secure') ?? false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$context = $container->getDefinition('assets.context');
|
||||
|
||||
if (null === $container->getParameter('asset.request_context.base_path')) {
|
||||
$context->replaceArgument(1, (new Definition('string'))->setFactory([new Reference('router.request_context'), 'getBaseUrl']));
|
||||
}
|
||||
|
||||
if (null === $container->getParameter('asset.request_context.secure')) {
|
||||
$context->replaceArgument(2, (new Definition('bool'))->setFactory([new Reference('router.request_context'), 'isSecure']));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\Config\ConfigCache;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\Compiler\ResolveEnvPlaceholdersPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Dumper\XmlDumper;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\EnvPlaceholderParameterBag;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
/**
|
||||
* Dumps the ContainerBuilder to a cache file so that it can be used by
|
||||
* debugging tools such as the debug:container console command.
|
||||
*
|
||||
* @author Ryan Weaver <ryan@thatsquality.com>
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class ContainerBuilderDebugDumpPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
if (!$container->getParameter('debug.container.dump')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$file = $container->getParameter('debug.container.dump');
|
||||
$cache = new ConfigCache($file, true);
|
||||
if ($cache->isFresh()) {
|
||||
return;
|
||||
}
|
||||
$cache->write((new XmlDumper($container))->dump(), $container->getResources());
|
||||
|
||||
if (!str_ends_with($file, '.xml')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$file = substr_replace($file, '.ser', -4);
|
||||
|
||||
try {
|
||||
$dump = new ContainerBuilder(clone $container->getParameterBag());
|
||||
$dump->setDefinitions(unserialize(serialize($container->getDefinitions())));
|
||||
$dump->setAliases($container->getAliases());
|
||||
|
||||
if (($bag = $container->getParameterBag()) instanceof EnvPlaceholderParameterBag) {
|
||||
(new ResolveEnvPlaceholdersPass(null))->process($dump);
|
||||
$dump->__construct(new EnvPlaceholderParameterBag($container->resolveEnvPlaceholders($this->escapeParameters($bag->all()))));
|
||||
}
|
||||
|
||||
$fs = new Filesystem();
|
||||
$fs->dumpFile($file, serialize($dump));
|
||||
$fs->chmod($file, 0o666, umask());
|
||||
} catch (\Throwable $e) {
|
||||
$container->getCompiler()->log($this, $e->getMessage());
|
||||
// ignore serialization and file-system errors
|
||||
if (file_exists($file)) {
|
||||
@unlink($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function escapeParameters(array $parameters): array
|
||||
{
|
||||
$params = [];
|
||||
foreach ($parameters as $k => $v) {
|
||||
$params[$k] = match (true) {
|
||||
\is_array($v) => $this->escapeParameters($v),
|
||||
\is_string($v) => str_replace('%', '%%', $v),
|
||||
default => $v,
|
||||
};
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
37
backend/vendor/symfony/framework-bundle/DependencyInjection/Compiler/ErrorLoggerCompilerPass.php
vendored
Normal file
37
backend/vendor/symfony/framework-bundle/DependencyInjection/Compiler/ErrorLoggerCompilerPass.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class ErrorLoggerCompilerPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
if (!$container->hasDefinition('debug.error_handler_configurator')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$definition = $container->getDefinition('debug.error_handler_configurator');
|
||||
if ($container->hasDefinition('monolog.logger.php')) {
|
||||
$definition->replaceArgument(0, new Reference('monolog.logger.php'));
|
||||
}
|
||||
if ($container->hasDefinition('monolog.logger.deprecation')) {
|
||||
$definition->replaceArgument(5, new Reference('monolog.logger.deprecation'));
|
||||
}
|
||||
}
|
||||
}
|
||||
240
backend/vendor/symfony/framework-bundle/DependencyInjection/Compiler/PhpConfigReferenceDumpPass.php
vendored
Normal file
240
backend/vendor/symfony/framework-bundle/DependencyInjection/Compiler/PhpConfigReferenceDumpPass.php
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\Config\Definition\ArrayNode;
|
||||
use Symfony\Component\Config\Definition\ArrayShapeGenerator;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
use Symfony\Component\Config\Definition\PrototypedArrayNode;
|
||||
use Symfony\Component\Config\Loader\ParamConfigurator;
|
||||
use Symfony\Component\Config\Resource\FileResource;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface;
|
||||
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\AppReference;
|
||||
use Symfony\Component\ExpressionLanguage\Expression;
|
||||
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
||||
use Symfony\Component\Routing\Loader\Configurator\RoutesReference;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class PhpConfigReferenceDumpPass implements CompilerPassInterface
|
||||
{
|
||||
private const REFERENCE_TEMPLATE = <<<'PHP'
|
||||
<?php
|
||||
|
||||
// This file is auto-generated and is for apps only. Bundles SHOULD NOT rely on its content.
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
|
||||
|
||||
use Symfony\Component\Config\Loader\ParamConfigurator as Param;
|
||||
|
||||
{APP_TYPES}
|
||||
final class App
|
||||
{
|
||||
{APP_PARAM}
|
||||
public static function config(array $config): array
|
||||
{
|
||||
/** @var ConfigType $config */
|
||||
$config = AppReference::config($config);
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Symfony\Component\Routing\Loader\Configurator;
|
||||
|
||||
{ROUTES_TYPES}
|
||||
final class Routes
|
||||
{
|
||||
{ROUTES_PARAM}
|
||||
public static function config(array $config): array
|
||||
{
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
|
||||
PHP;
|
||||
|
||||
private const WHEN_ENV_APP_TEMPLATE = <<<'PHPDOC'
|
||||
|
||||
* "when@{ENV}"?: array{
|
||||
* imports?: ImportsConfig,
|
||||
* parameters?: ParametersConfig,
|
||||
* services?: ServicesConfig,{SHAPE}
|
||||
* },
|
||||
PHPDOC;
|
||||
|
||||
private const ROUTES_TYPES_TEMPLATE = <<<'PHPDOC'
|
||||
|
||||
* @psalm-type RoutesConfig = array{{SHAPE}
|
||||
* ...<string, RouteConfig|ImportConfig|AliasConfig>
|
||||
* }
|
||||
*/
|
||||
PHPDOC;
|
||||
|
||||
private const WHEN_ENV_ROUTES_TEMPLATE = <<<'PHPDOC'
|
||||
|
||||
* "when@{ENV}"?: array<string, RouteConfig|ImportConfig|AliasConfig>,
|
||||
PHPDOC;
|
||||
|
||||
public function __construct(
|
||||
private string $referenceFile,
|
||||
private array $bundlesDefinition,
|
||||
) {
|
||||
}
|
||||
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
$knownEnvs = $container->hasParameter('.container.known_envs') ? $container->getParameter('.container.known_envs') : [$container->getParameter('kernel.environment')];
|
||||
$knownEnvs = array_unique($knownEnvs);
|
||||
sort($knownEnvs);
|
||||
$extensionsPerEnv = [];
|
||||
$appTypes = '';
|
||||
|
||||
$anyEnvExtensions = [];
|
||||
$registeredExtensions = $container->getExtensions();
|
||||
foreach ($this->bundlesDefinition as $bundle => $envs) {
|
||||
if (!is_subclass_of($bundle, BundleInterface::class)) {
|
||||
continue;
|
||||
}
|
||||
if (!$extension = (new $bundle())->getContainerExtension()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$extensionAlias = $extension->getAlias();
|
||||
if (isset($registeredExtensions[$extensionAlias])) {
|
||||
$extension = $registeredExtensions[$extensionAlias];
|
||||
unset($registeredExtensions[$extensionAlias]);
|
||||
}
|
||||
|
||||
if (!$configuration = $this->getConfiguration($extension, $container)) {
|
||||
continue;
|
||||
}
|
||||
$tree = $configuration->getConfigTreeBuilder()->buildTree();
|
||||
if ($tree instanceof ArrayNode && !$tree instanceof PrototypedArrayNode && !$tree->getChildren()) {
|
||||
continue;
|
||||
}
|
||||
$anyEnvExtensions[$extensionAlias] = $extension;
|
||||
$type = $this->camelCase($extensionAlias).'Config';
|
||||
$appTypes .= \sprintf("\n * @psalm-type %s = %s", $type, ArrayShapeGenerator::generate($tree));
|
||||
|
||||
foreach ($knownEnvs as $env) {
|
||||
if ($envs[$env] ?? $envs['all'] ?? false) {
|
||||
$extensionsPerEnv[$env][] = $extension;
|
||||
} else {
|
||||
unset($anyEnvExtensions[$extensionAlias]);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($registeredExtensions as $alias => $extension) {
|
||||
if (!$configuration = $this->getConfiguration($extension, $container)) {
|
||||
continue;
|
||||
}
|
||||
$tree = $configuration->getConfigTreeBuilder()->buildTree();
|
||||
if ($tree instanceof ArrayNode && !$tree instanceof PrototypedArrayNode && !$tree->getChildren()) {
|
||||
continue;
|
||||
}
|
||||
$anyEnvExtensions[$alias] = $extension;
|
||||
$type = $this->camelCase($alias).'Config';
|
||||
$appTypes .= \sprintf("\n * @psalm-type %s = %s", $type, ArrayShapeGenerator::generate($tree));
|
||||
}
|
||||
krsort($extensionsPerEnv);
|
||||
|
||||
$r = new \ReflectionClass(AppReference::class);
|
||||
|
||||
if (false === $i = strpos($phpdoc = $r->getDocComment(), "\n * @psalm-type ConfigType = ")) {
|
||||
throw new \LogicException(\sprintf('Cannot insert config shape in "%s".', AppReference::class));
|
||||
}
|
||||
$appTypes = substr_replace($phpdoc, $appTypes, $i, 0);
|
||||
|
||||
if (false === $i = strrpos($phpdoc = $appTypes, "\n * ...<string, ExtensionType|array{")) {
|
||||
throw new \LogicException(\sprintf('Cannot insert config shape in "%s".', AppReference::class));
|
||||
}
|
||||
$appTypes = substr_replace($phpdoc, $this->getShapeForExtensions($anyEnvExtensions, $container), $i, 0);
|
||||
$i += \strlen($appTypes) - \strlen($phpdoc);
|
||||
|
||||
foreach ($extensionsPerEnv as $env => $extensions) {
|
||||
$appTypes = substr_replace($appTypes, strtr(self::WHEN_ENV_APP_TEMPLATE, [
|
||||
'{ENV}' => $env,
|
||||
'{SHAPE}' => $this->getShapeForExtensions($extensions, $container, ' '),
|
||||
]), $i, 0);
|
||||
}
|
||||
$appParam = $r->getMethod('config')->getDocComment();
|
||||
|
||||
$r = new \ReflectionClass(RoutesReference::class);
|
||||
|
||||
if (false === $i = strpos($phpdoc = $r->getDocComment(), "\n * @psalm-type RoutesConfig = ")) {
|
||||
throw new \LogicException(\sprintf('Cannot insert config shape in "%s".', RoutesReference::class));
|
||||
}
|
||||
$routesTypes = '';
|
||||
foreach ($knownEnvs as $env) {
|
||||
$routesTypes .= strtr(self::WHEN_ENV_ROUTES_TEMPLATE, ['{ENV}' => $env]);
|
||||
}
|
||||
if ('' !== $routesTypes) {
|
||||
$routesTypes = strtr(self::ROUTES_TYPES_TEMPLATE, ['{SHAPE}' => $routesTypes]);
|
||||
$routesTypes = substr_replace($phpdoc, $routesTypes, $i);
|
||||
}
|
||||
|
||||
$appTypes = str_replace('\\'.ParamConfigurator::class, 'Param', $appTypes);
|
||||
|
||||
if (!class_exists(Expression::class)) {
|
||||
$appTypes = str_replace('|ExpressionConfigurator', '', $appTypes);
|
||||
}
|
||||
|
||||
$configReference = strtr(self::REFERENCE_TEMPLATE, [
|
||||
'{APP_TYPES}' => $appTypes,
|
||||
'{APP_PARAM}' => $appParam,
|
||||
'{ROUTES_TYPES}' => $routesTypes,
|
||||
'{ROUTES_PARAM}' => $r->getMethod('config')->getDocComment(),
|
||||
]);
|
||||
|
||||
$dir = \dirname($this->referenceFile);
|
||||
if (is_dir($dir) && is_writable($dir)) {
|
||||
if (!is_file($this->referenceFile) || file_get_contents($this->referenceFile) !== $configReference) {
|
||||
file_put_contents($this->referenceFile, $configReference);
|
||||
}
|
||||
$container->addResource(new FileResource($this->referenceFile));
|
||||
}
|
||||
}
|
||||
|
||||
private function camelCase(string $input): string
|
||||
{
|
||||
$output = ucfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $input))));
|
||||
|
||||
return preg_replace('#\W#', '', $output);
|
||||
}
|
||||
|
||||
private function getConfiguration(ExtensionInterface $extension, ContainerBuilder $container): ?ConfigurationInterface
|
||||
{
|
||||
return match (true) {
|
||||
$extension instanceof ConfigurationInterface => $extension,
|
||||
$extension instanceof ConfigurationExtensionInterface => $extension->getConfiguration([], $container),
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
private function getShapeForExtensions(array $extensions, ContainerBuilder $container, string $indent = ''): string
|
||||
{
|
||||
$shape = '';
|
||||
foreach ($extensions as $extension) {
|
||||
if ($this->getConfiguration($extension, $container)) {
|
||||
$type = $this->camelCase($extension->getAlias()).'Config';
|
||||
$shape .= \sprintf("\n * %s%s?: %s,", $indent, $extension->getAlias(), $type);
|
||||
}
|
||||
}
|
||||
|
||||
return $shape;
|
||||
}
|
||||
}
|
||||
61
backend/vendor/symfony/framework-bundle/DependencyInjection/Compiler/ProfilerPass.php
vendored
Normal file
61
backend/vendor/symfony/framework-bundle/DependencyInjection/Compiler/ProfilerPass.php
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\DataCollector\TemplateAwareDataCollectorInterface;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* Adds tagged data_collector services to profiler service.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class ProfilerPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
if (false === $container->hasDefinition('profiler')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$definition = $container->getDefinition('profiler');
|
||||
|
||||
$collectors = new \SplPriorityQueue();
|
||||
$order = \PHP_INT_MAX;
|
||||
foreach ($container->findTaggedServiceIds('data_collector', true) as $id => $attributes) {
|
||||
$priority = $attributes[0]['priority'] ?? 0;
|
||||
$template = null;
|
||||
|
||||
$collectorClass = $container->findDefinition($id)->getClass();
|
||||
if (isset($attributes[0]['template']) || is_subclass_of($collectorClass, TemplateAwareDataCollectorInterface::class)) {
|
||||
$idForTemplate = $attributes[0]['id'] ?? $collectorClass;
|
||||
if (!$idForTemplate) {
|
||||
throw new InvalidArgumentException(\sprintf('Data collector service "%s" must have an id attribute in order to specify a template.', $id));
|
||||
}
|
||||
$template = [$idForTemplate, $attributes[0]['template'] ?? $collectorClass::getTemplate()];
|
||||
}
|
||||
|
||||
$collectors->insert([$id, $template], [$priority, --$order]);
|
||||
}
|
||||
|
||||
$templates = [];
|
||||
foreach ($collectors as $collector) {
|
||||
$definition->addMethodCall('add', [new Reference($collector[0])]);
|
||||
$templates[$collector[0]] = $collector[1];
|
||||
}
|
||||
|
||||
$container->setParameter('data_collector.templates', $templates);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
/**
|
||||
* @author Ahmed TAILOULOUTE <ahmed.tailouloute@gmail.com>
|
||||
*/
|
||||
class RemoveUnusedSessionMarshallingHandlerPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
if (!$container->hasDefinition('session.marshalling_handler')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$isMarshallerDecorated = false;
|
||||
|
||||
foreach ($container->getDefinitions() as $definition) {
|
||||
$decorated = $definition->getDecoratedService();
|
||||
if (null !== $decorated && 'session.marshaller' === $decorated[0]) {
|
||||
$isMarshallerDecorated = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$isMarshallerDecorated) {
|
||||
$container->removeDefinition('session.marshalling_handler');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class TestServiceContainerRealRefPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
if (!$container->hasDefinition('test.private_services_locator')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$privateContainer = $container->getDefinition('test.private_services_locator');
|
||||
$definitions = $container->getDefinitions();
|
||||
$privateServices = $privateContainer->getArgument(0);
|
||||
$renamedIds = [];
|
||||
|
||||
foreach ($privateServices as $id => $argument) {
|
||||
if (isset($definitions[$target = (string) $argument->getValues()[0]])) {
|
||||
$argument->setValues([new Reference($target)]);
|
||||
if ($id !== $target) {
|
||||
$renamedIds[$id] = $target;
|
||||
}
|
||||
if ($inner = $definitions[$target]->getTag('container.decorator')[0]['inner'] ?? null) {
|
||||
$renamedIds[$id] = $inner;
|
||||
}
|
||||
} else {
|
||||
unset($privateServices[$id]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($container->getAliases() as $id => $target) {
|
||||
while ($container->hasAlias($target = (string) $target)) {
|
||||
$target = $container->getAlias($target);
|
||||
}
|
||||
|
||||
if ($definitions[$target]->hasTag('container.private')) {
|
||||
$privateServices[$id] = new ServiceClosureArgument(new Reference($target));
|
||||
}
|
||||
|
||||
$renamedIds[$id] = $target;
|
||||
}
|
||||
|
||||
$privateContainer->replaceArgument(0, $privateServices);
|
||||
|
||||
if ($container->hasDefinition('test.service_container') && $renamedIds) {
|
||||
$container->getDefinition('test.service_container')->setArgument(2, $renamedIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* @author Nicolas Grekas <p@tchwork.com>
|
||||
*/
|
||||
class TestServiceContainerWeakRefPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
if (!$container->hasDefinition('test.private_services_locator')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$privateServices = [];
|
||||
$definitions = $container->getDefinitions();
|
||||
|
||||
foreach ($definitions as $id => $definition) {
|
||||
if ($inner = $definition->getTag('container.decorator')[0]['inner'] ?? null) {
|
||||
$privateServices[$inner] = new Reference($inner, ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE);
|
||||
}
|
||||
if ($id && '.' !== $id[0] && ($definition->isPrivate() || $definition->hasTag('container.private')) && !$definition->hasErrors() && !$definition->isAbstract()) {
|
||||
$privateServices[$id] = new Reference($id, ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE);
|
||||
}
|
||||
}
|
||||
|
||||
$aliases = $container->getAliases();
|
||||
|
||||
foreach ($aliases as $id => $alias) {
|
||||
if ($id && '.' !== $id[0] && $alias->isPrivate()) {
|
||||
while (isset($aliases[$target = (string) $alias])) {
|
||||
$alias = $aliases[$target];
|
||||
}
|
||||
if (isset($definitions[$target]) && !$definitions[$target]->hasErrors() && !$definitions[$target]->isAbstract()) {
|
||||
$privateServices[$id] = new Reference($target, ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($privateServices) {
|
||||
$id = (string) ServiceLocatorTagPass::register($container, $privateServices);
|
||||
$container->setDefinition('test.private_services_locator', $container->getDefinition($id))->setPublic(true);
|
||||
$container->removeDefinition($id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\Translation\TranslatorBagInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
final class TranslationLintCommandPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
if (!$container->hasDefinition('console.command.translation_lint') || !$container->has('translator')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$translatorClass = $container->getParameterBag()->resolveValue($container->findDefinition('translator')->getClass());
|
||||
|
||||
if (!is_subclass_of($translatorClass, TranslatorInterface::class) || !is_subclass_of($translatorClass, TranslatorBagInterface::class)) {
|
||||
$container->removeDefinition('console.command.translation_lint');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
class TranslationUpdateCommandPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
if (!$container->hasDefinition('console.command.translation_extract')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$translationWriterClass = $container->getParameterBag()->resolveValue($container->findDefinition('translation.writer')->getClass());
|
||||
|
||||
if (!method_exists($translationWriterClass, 'getFormats')) {
|
||||
$container->removeDefinition('console.command.translation_extract');
|
||||
}
|
||||
}
|
||||
}
|
||||
146
backend/vendor/symfony/framework-bundle/DependencyInjection/Compiler/UnusedTagsPass.php
vendored
Normal file
146
backend/vendor/symfony/framework-bundle/DependencyInjection/Compiler/UnusedTagsPass.php
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
/**
|
||||
* Find all service tags which are defined, but not used and yield a warning log message.
|
||||
*
|
||||
* @author Florian Pfitzer <pfitzer@wurzel3.de>
|
||||
*/
|
||||
class UnusedTagsPass implements CompilerPassInterface
|
||||
{
|
||||
private const KNOWN_TAGS = [
|
||||
'asset_mapper.compiler',
|
||||
'assets.package',
|
||||
'auto_alias',
|
||||
'cache.pool',
|
||||
'cache.pool.clearer',
|
||||
'cache.taggable',
|
||||
'chatter.transport_factory',
|
||||
'config_cache.resource_checker',
|
||||
'console.command',
|
||||
'container.env_var_loader',
|
||||
'container.env_var_processor',
|
||||
'container.excluded',
|
||||
'container.hot_path',
|
||||
'container.no_preload',
|
||||
'container.preload',
|
||||
'container.private',
|
||||
'container.reversible',
|
||||
'container.service_locator',
|
||||
'container.service_locator_context',
|
||||
'container.service_subscriber',
|
||||
'container.stack',
|
||||
'controller.argument_value_resolver',
|
||||
'controller.service_arguments',
|
||||
'controller.targeted_value_resolver',
|
||||
'data_collector',
|
||||
'event_dispatcher.dispatcher',
|
||||
'form.type',
|
||||
'form.type_extension',
|
||||
'form.type_guesser',
|
||||
'html_sanitizer',
|
||||
'http_client.client',
|
||||
'json_streamer.value_transformer',
|
||||
'kernel.cache_clearer',
|
||||
'kernel.cache_warmer',
|
||||
'kernel.event_listener',
|
||||
'kernel.event_subscriber',
|
||||
'kernel.fragment_renderer',
|
||||
'kernel.locale_aware',
|
||||
'kernel.reset',
|
||||
'ldap',
|
||||
'mailer.transport_factory',
|
||||
'messenger.bus',
|
||||
'messenger.message_handler',
|
||||
'messenger.receiver',
|
||||
'messenger.transport_factory',
|
||||
'mime.mime_type_guesser',
|
||||
'monolog.logger',
|
||||
'notifier.channel',
|
||||
'object_mapper.condition_callable',
|
||||
'object_mapper.transform_callable',
|
||||
'property_info.access_extractor',
|
||||
'property_info.constructor_extractor',
|
||||
'property_info.initializable_extractor',
|
||||
'property_info.list_extractor',
|
||||
'property_info.type_extractor',
|
||||
'proxy',
|
||||
'remote_event.consumer',
|
||||
'routing.condition_service',
|
||||
'routing.controller',
|
||||
'routing.expression_language_function',
|
||||
'routing.expression_language_provider',
|
||||
'routing.loader',
|
||||
'routing.route_loader',
|
||||
'scheduler.schedule_provider',
|
||||
'scheduler.task',
|
||||
'security.access_token_handler.oidc.encryption_algorithm',
|
||||
'security.access_token_handler.oidc.signature_algorithm',
|
||||
'security.authenticator.login_linker',
|
||||
'security.expression_language_provider',
|
||||
'security.remember_me_handler',
|
||||
'security.voter',
|
||||
'serializer.encoder',
|
||||
'serializer.normalizer',
|
||||
'texter.transport_factory',
|
||||
'translation.dumper',
|
||||
'translation.extractor',
|
||||
'translation.extractor.visitor',
|
||||
'translation.loader',
|
||||
'translation.provider_factory',
|
||||
'twig.extension',
|
||||
'twig.loader',
|
||||
'twig.runtime',
|
||||
'validator.attribute_metadata',
|
||||
'validator.auto_mapper',
|
||||
'validator.constraint_validator',
|
||||
'validator.group_provider',
|
||||
'validator.initializer',
|
||||
'workflow',
|
||||
];
|
||||
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
$tags = array_unique(array_merge($container->findTags(), self::KNOWN_TAGS));
|
||||
|
||||
foreach ($container->findUnusedTags() as $tag) {
|
||||
// skip known tags
|
||||
if (\in_array($tag, self::KNOWN_TAGS, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// check for typos
|
||||
$candidates = [];
|
||||
foreach ($tags as $definedTag) {
|
||||
if ($definedTag === $tag) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (str_contains($definedTag, $tag) || levenshtein($tag, $definedTag) <= \strlen($tag) / 3) {
|
||||
$candidates[] = $definedTag;
|
||||
}
|
||||
}
|
||||
|
||||
$services = array_keys($container->findTaggedServiceIds($tag));
|
||||
$message = \sprintf('Tag "%s" was defined on service(s) "%s", but was never used.', $tag, implode('", "', $services));
|
||||
if ($candidates) {
|
||||
$message .= \sprintf(' Did you mean "%s"?', implode('", "', $candidates));
|
||||
}
|
||||
|
||||
$container->log($this, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user