mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
N°6934 - Symfony 6.4 - upgrade Symfony bundles to 6.4 (#580)
* Update Symfony lib to version ~6.4.0 * Update code missing return type * Add an iTop general configuration entry to store application secret (Symfony mandatory parameter) * Use dependency injection in ExceptionListener & UserProvider classes
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Bundle\TwigBundle\DependencyInjection;
|
||||
|
||||
use Composer\InstalledVersions;
|
||||
use Symfony\Component\AssetMapper\AssetMapper;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Config\Resource\FileExistenceResource;
|
||||
use Symfony\Component\Console\Application;
|
||||
@@ -22,6 +22,7 @@ use Symfony\Component\Form\AbstractRendererEngine;
|
||||
use Symfony\Component\Form\Form;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\Mailer\Mailer;
|
||||
use Symfony\Component\Translation\LocaleSwitcher;
|
||||
use Symfony\Component\Translation\Translator;
|
||||
use Symfony\Contracts\Service\ResetInterface;
|
||||
use Twig\Extension\ExtensionInterface;
|
||||
@@ -36,16 +37,15 @@ use Twig\Loader\LoaderInterface;
|
||||
*/
|
||||
class TwigExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
if (!class_exists(InstalledVersions::class)) {
|
||||
trigger_deprecation('symfony/twig-bundle', '5.4', 'Configuring Symfony without the Composer Runtime API is deprecated. Consider upgrading to Composer 2.1 or later.');
|
||||
}
|
||||
|
||||
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
$loader->load('twig.php');
|
||||
|
||||
if ($container::willBeAvailable('symfony/form', Form::class, ['symfony/twig-bundle'], true)) {
|
||||
if ($container::willBeAvailable('symfony/form', Form::class, ['symfony/twig-bundle'])) {
|
||||
$loader->load('form.php');
|
||||
|
||||
if (is_subclass_of(AbstractRendererEngine::class, ResetInterface::class)) {
|
||||
@@ -55,15 +55,11 @@ class TwigExtension extends Extension
|
||||
}
|
||||
}
|
||||
|
||||
if ($container::willBeAvailable('symfony/console', Application::class, ['symfony/twig-bundle'], true)) {
|
||||
if ($container::willBeAvailable('symfony/console', Application::class, ['symfony/twig-bundle'])) {
|
||||
$loader->load('console.php');
|
||||
}
|
||||
|
||||
if ($container::willBeAvailable('symfony/mailer', Mailer::class, ['symfony/twig-bundle'], true)) {
|
||||
$loader->load('mailer.php');
|
||||
}
|
||||
|
||||
if (!$container::willBeAvailable('symfony/translation', Translator::class, ['symfony/twig-bundle'], true)) {
|
||||
if (!$container::willBeAvailable('symfony/translation', Translator::class, ['symfony/twig-bundle'])) {
|
||||
$container->removeDefinition('twig.translation.extractor');
|
||||
}
|
||||
|
||||
@@ -84,6 +80,22 @@ class TwigExtension extends Extension
|
||||
|
||||
$config = $this->processConfiguration($configuration, $configs);
|
||||
|
||||
if ($container::willBeAvailable('symfony/mailer', Mailer::class, ['symfony/twig-bundle'])) {
|
||||
$loader->load('mailer.php');
|
||||
|
||||
if ($htmlToTextConverter = $config['mailer']['html_to_text_converter'] ?? null) {
|
||||
$container->getDefinition('twig.mime_body_renderer')->setArgument('$converter', new Reference($htmlToTextConverter));
|
||||
}
|
||||
|
||||
if (ContainerBuilder::willBeAvailable('symfony/translation', LocaleSwitcher::class, ['symfony/framework-bundle'])) {
|
||||
$container->getDefinition('twig.mime_body_renderer')->setArgument('$localeSwitcher', new Reference('translation.locale_switcher', ContainerBuilder::IGNORE_ON_INVALID_REFERENCE));
|
||||
}
|
||||
}
|
||||
|
||||
if ($container::willBeAvailable('symfony/asset-mapper', AssetMapper::class, ['symfony/twig-bundle'])) {
|
||||
$loader->load('importmap.php');
|
||||
}
|
||||
|
||||
$container->setParameter('twig.form.resources', $config['form_themes']);
|
||||
$container->setParameter('twig.default_path', $config['default_path']);
|
||||
$defaultTwigPath = $container->getParameterBag()->resolveValue($config['default_path']);
|
||||
@@ -110,6 +122,12 @@ class TwigExtension extends Extension
|
||||
// paths are modified in ExtensionPass if forms are enabled
|
||||
$container->getDefinition('twig.template_iterator')->replaceArgument(1, $config['paths']);
|
||||
|
||||
$container->getDefinition('twig.template_iterator')->replaceArgument(3, $config['file_name_pattern']);
|
||||
|
||||
if ($container->hasDefinition('twig.command.lint')) {
|
||||
$container->getDefinition('twig.command.lint')->replaceArgument(1, $config['file_name_pattern'] ?: ['*.twig']);
|
||||
}
|
||||
|
||||
foreach ($this->getBundleTemplatePaths($container, $config) as $name => $paths) {
|
||||
$namespace = $this->normalizeBundleName($name);
|
||||
foreach ($paths as $path) {
|
||||
@@ -138,8 +156,8 @@ class TwigExtension extends Extension
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($config['autoescape_service']) && isset($config['autoescape_service_method'])) {
|
||||
$config['autoescape'] = [new Reference($config['autoescape_service']), $config['autoescape_service_method']];
|
||||
if (isset($config['autoescape_service'])) {
|
||||
$config['autoescape'] = [new Reference($config['autoescape_service']), $config['autoescape_service_method'] ?? '__invoke'];
|
||||
}
|
||||
|
||||
$container->getDefinition('twig')->replaceArgument(1, array_intersect_key($config, [
|
||||
@@ -193,15 +211,12 @@ class TwigExtension extends Extension
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getXsdValidationBasePath()
|
||||
public function getXsdValidationBasePath(): string|false
|
||||
{
|
||||
return __DIR__.'/../Resources/config/schema';
|
||||
}
|
||||
|
||||
public function getNamespace()
|
||||
public function getNamespace(): string
|
||||
{
|
||||
return 'http://symfony.com/schema/dic/twig';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user