Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions DependencyInjection/TranslationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ public function load(array $configs, ContainerBuilder $container): void
$configuration = new Configuration($container);
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$legacyLoader = new Loader\PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config/legacy'));

$loader->load('services.yaml');
$legacyLoader->load('services.php');
$loader->load('extractors.yaml');
$legacyLoader->load('extractors.php');

// Add major version to extractor
$container->getDefinition(FormTypeChoices::class)
Expand All @@ -74,6 +77,7 @@ public function load(array $configs, ContainerBuilder $container): void

if ($config['edit_in_place']['enabled']) {
$loader->load('edit_in_place.yaml');
$legacyLoader->load('edit_in_place.php');
$this->enableEditInPlace($container, $config);
}

Expand All @@ -89,6 +93,7 @@ public function load(array $configs, ContainerBuilder $container): void
}

$loader->load('console.yaml');
$legacyLoader->load('console.php');
}

/**
Expand Down
28 changes: 28 additions & 0 deletions Legacy/LegacyHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

namespace Translation\Bundle\Legacy;

use Symfony\Component\DependencyInjection\Loader\Configurator\ServicesConfigurator;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Kernel;

/**
* A legacy helper to suppress deprecations on RequestStack.
Expand All @@ -28,4 +30,30 @@ public static function getMainRequest(RequestStack $requestStack)

return $requestStack->getMasterRequest();
}

/**
* @param array[string $id, string $parent, ?bool $isPublic] $legacyServices
*/
public static function deprecateServices(ServicesConfigurator $servicesConfigurator, array $legacyServices)
{
foreach ($legacyServices as $legacyService) {
$id = $legacyService[0];
$parent = $legacyService[1];
$isPublic = $legacyService[2] ?? false;

// Declare legacy services to remove in next major release
$service = $servicesConfigurator->set($id)
->parent($parent);

if (Kernel::VERSION_ID < 50100) {
$service->deprecate('Since php-translation/symfony-bundle 0.10.0: The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.');
} else {
$service->deprecate('php-translation/symfony-bundle', '0.10.0', 'The "%service_id%" service is deprecated. You should stop using it, as it will soon be removed.');
}

if ($isPublic) {
$service->public();
}
}
}
}
17 changes: 0 additions & 17 deletions Resources/config/console.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,3 @@ services:
- '@Translation\Bundle\Service\StorageManager'
tags:
- { name: console.command, command: translation:sync }

# To remove in next major release
php_translator.console.delete_obsolete:
parent: Translation\Bundle\Command\DeleteObsoleteCommand
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
php_translator.console.download:
parent: Translation\Bundle\Command\DownloadCommand
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
php_translator.console.extract:
parent: Translation\Bundle\Command\ExtractCommand
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
php_translator.console.status:
parent: Translation\Bundle\Command\StatusCommand
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
php_translator.console.sync:
parent: Translation\Bundle\Command\SyncCommand
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
14 changes: 0 additions & 14 deletions Resources/config/edit_in_place.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,3 @@ services:
- ~
tags:
- { name: 'twig.extension' }

# To remove in next major release
php_translation.edit_in_place.response_listener:
parent: Translation\Bundle\EventListener\EditInPlaceResponseListener
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
php_translation.edit_in_place.activator:
parent: Translation\Bundle\EditInPlace\Activator
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
php_translator.edit_in_place.xtrans_html_translator:
parent: Translation\Bundle\Translator\EditInPlaceTranslator
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
php_translation.edit_in_place.extension.trans:
parent: Translation\Bundle\Twig\EditInPlaceExtension
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
47 changes: 0 additions & 47 deletions Resources/config/extractors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,52 +24,5 @@ services:
tags:
- { name: 'php_translation.visitor', type: 'twig' }

# To remove in next major release
php_translation.extractor.php:
alias: Translation\Extractor\FileExtractor\PHPFileExtractor
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
php_translation.extractor.twig:
alias: Translation\Extractor\FileExtractor\TwigFileExtractor
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
php_translation.extractor.php.visitor.ContainerAwareTrans:
alias: Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTrans
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
php_translation.extractor.php.visitor.ContainerAwareTransChoice:
alias: Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTransChoice
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
php_translation.extractor.php.visitor.FlashMessage:
alias: Translation\Extractor\Visitor\Php\Symfony\FlashMessage
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
php_translation.extractor.php.visitor.FormTypeChoices:
alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeChoices
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
php_translation.extractor.php.visitor.FormTypeEmptyValue:
alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeEmptyValue
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
php_translation.extractor.php.visitor.FormTypeHelp:
alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeHelp
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
php_translation.extractor.php.visitor.FormTypeInvalidMessage:
alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeInvalidMessage
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
php_translation.extractor.php.visitor.FormTypeLabelExplicit:
alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelExplicit
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
php_translation.extractor.php.visitor.FormTypeLabelImplicit:
alias: Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelImplicit
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
php_translation.extractor.php.visitor.FormTypePlaceholder:
alias: Translation\Extractor\Visitor\Php\Symfony\FormTypePlaceholder
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
php_translation.extractor.php.visitor.ValidationAnnotation:
alias: Translation\Extractor\Visitor\Php\Symfony\ValidationAnnotation
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
php_translation.extractor.php.visitor.SourceLocationContainerVisitor:
alias: Translation\Extractor\Visitor\Php\SourceLocationContainerVisitor
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'
php_translation.extractor.twig.factory.twig:
alias: Translation\Extractor\Visitor\Twig\TwigVisitor
deprecated: 'The "%service_id%" service is deprecated. You should use "%alias_id%" instead, as it will be removed in the future.'

Translation\Extractor\Visitor\Php\Symfony\ValidationAnnotation:
arguments: ['@validator']
22 changes: 22 additions & 0 deletions Resources/config/legacy/console.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Translation\Bundle\Command\DeleteObsoleteCommand;
use Translation\Bundle\Command\DownloadCommand;
use Translation\Bundle\Command\ExtractCommand;
use Translation\Bundle\Command\StatusCommand;
use Translation\Bundle\Command\SyncCommand;
use Translation\Bundle\Legacy\LegacyHelper;

return function (ContainerConfigurator $configurator) {
$services = $configurator->services();

LegacyHelper::deprecateServices($services, [
['php_translator.console.delete_obsolete', DeleteObsoleteCommand::class],
['php_translator.console.download', DownloadCommand::class],
['php_translator.console.extract', ExtractCommand::class],
['php_translator.console.status', StatusCommand::class],
['php_translator.console.sync', SyncCommand::class],
]);
};
20 changes: 20 additions & 0 deletions Resources/config/legacy/edit_in_place.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Translation\Bundle\EditInPlace\Activator;
use Translation\Bundle\EventListener\EditInPlaceResponseListener;
use Translation\Bundle\Legacy\LegacyHelper;
use Translation\Bundle\Translator\EditInPlaceTranslator;
use Translation\Bundle\Twig\EditInPlaceExtension;

return function (ContainerConfigurator $configurator) {
$services = $configurator->services();

LegacyHelper::deprecateServices($services, [
['php_translation.edit_in_place.response_listener', EditInPlaceResponseListener::class],
['php_translation.edit_in_place.activator', Activator::class],
['php_translator.edit_in_place.xtrans_html_translator', EditInPlaceTranslator::class],
['php_translation.edit_in_place.extension.trans', EditInPlaceExtension::class],
]);
};
42 changes: 42 additions & 0 deletions Resources/config/legacy/extractors.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Translation\Bundle\Legacy\LegacyHelper;
use Translation\Extractor\FileExtractor\PHPFileExtractor;
use Translation\Extractor\FileExtractor\TwigFileExtractor;
use Translation\Extractor\Visitor\Php\SourceLocationContainerVisitor;
use Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTrans;
use Translation\Extractor\Visitor\Php\Symfony\ContainerAwareTransChoice;
use Translation\Extractor\Visitor\Php\Symfony\FlashMessage;
use Translation\Extractor\Visitor\Php\Symfony\FormTypeChoices;
use Translation\Extractor\Visitor\Php\Symfony\FormTypeEmptyValue;
use Translation\Extractor\Visitor\Php\Symfony\FormTypeHelp;
use Translation\Extractor\Visitor\Php\Symfony\FormTypeInvalidMessage;
use Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelExplicit;
use Translation\Extractor\Visitor\Php\Symfony\FormTypeLabelImplicit;
use Translation\Extractor\Visitor\Php\Symfony\FormTypePlaceholder;
use Translation\Extractor\Visitor\Php\Symfony\ValidationAnnotation;
use Translation\Extractor\Visitor\Twig\TwigVisitor;

return function (ContainerConfigurator $configurator) {
$services = $configurator->services();

LegacyHelper::deprecateServices($services, [
['php_translation.extractor.php', PHPFileExtractor::class],
['php_translation.extractor.twig', TwigFileExtractor::class],
['php_translation.extractor.php.visitor.ContainerAwareTrans', ContainerAwareTrans::class],
['php_translation.extractor.php.visitor.ContainerAwareTransChoice', ContainerAwareTransChoice::class],
['php_translation.extractor.php.visitor.FlashMessage', FlashMessage::class],
['php_translation.extractor.php.visitor.FormTypeChoices', FormTypeChoices::class],
['php_translation.extractor.php.visitor.FormTypeEmptyValue', FormTypeEmptyValue::class],
['php_translation.extractor.php.visitor.FormTypeHelp', FormTypeHelp::class],
['php_translation.extractor.php.visitor.FormTypeInvalidMessage', FormTypeInvalidMessage::class],
['php_translation.extractor.php.visitor.FormTypeLabelExplicit', FormTypeLabelExplicit::class],
['php_translation.extractor.php.visitor.FormTypeLabelImplicit', FormTypeLabelImplicit::class],
['php_translation.extractor.php.visitor.FormTypePlaceholder', FormTypePlaceholder::class],
['php_translation.extractor.php.visitor.ValidationAnnotation', ValidationAnnotation::class],
['php_translation.extractor.php.visitor.SourceLocationContainerVisitor', SourceLocationContainerVisitor::class],
['php_translation.extractor.twig.factory.twig', TwigVisitor::class],
]);
};
32 changes: 32 additions & 0 deletions Resources/config/legacy/services.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Translation\Bundle\Catalogue\CatalogueCounter;
use Translation\Bundle\Catalogue\CatalogueFetcher;
use Translation\Bundle\Catalogue\CatalogueManager;
use Translation\Bundle\Catalogue\CatalogueWriter;
use Translation\Bundle\Legacy\LegacyHelper;
use Translation\Bundle\Service\CacheClearer;
use Translation\Bundle\Service\ConfigurationManager;
use Translation\Bundle\Service\Importer;
use Translation\Bundle\Service\StorageManager;
use Translation\Bundle\Twig\TranslationExtension;
use Translation\Extractor\Extractor;

return function (ContainerConfigurator $configurator) {
$services = $configurator->services();

LegacyHelper::deprecateServices($services, [
['php_translation.catalogue_fetcher', CatalogueFetcher::class, true],
['php_translation.catalogue_writer', CatalogueWriter::class, true],
['php_translation.catalogue_manager', CatalogueManager::class, true],
['php_translation.extractor', Extractor::class],
['php_translation.storage_manager', StorageManager::class, true],
['php_translation.configuration_manager', ConfigurationManager::class, true],
['php_translation.importer', Importer::class, true],
['php_translation.cache_clearer', CacheClearer::class, true],
['php_translation.catalogue_counter', CatalogueCounter::class, true],
['php_translation.twig_extension', TranslationExtension::class],
]);
};
40 changes: 0 additions & 40 deletions Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,43 +43,3 @@ services:
arguments: ['@translator', '%kernel.debug%']
tags:
- { name: twig.extension }

# To remove in next major release
php_translation.catalogue_fetcher:
parent: Translation\Bundle\Catalogue\CatalogueFetcher
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
public: true
php_translation.catalogue_writer:
parent: Translation\Bundle\Catalogue\CatalogueWriter
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
public: true
php_translation.catalogue_manager:
parent: Translation\Bundle\Catalogue\CatalogueManager
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
public: true
php_translation.extractor:
parent: Translation\Extractor\Extractor
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
php_translation.storage_manager:
parent: Translation\Bundle\Service\StorageManager
public: true
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
php_translation.configuration_manager:
parent: Translation\Bundle\Service\ConfigurationManager
public: true
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
php_translation.importer:
parent: Translation\Bundle\Service\Importer
public: true
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
php_translation.cache_clearer:
parent: Translation\Bundle\Service\CacheClearer
public: true
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
php_translation.catalogue_counter:
parent: Translation\Bundle\Catalogue\CatalogueCounter
public: true
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'
php_translation.twig_extension:
parent: Translation\Bundle\Twig\TranslationExtension
deprecated: 'The "%service_id%" service is deprecated. You should stop using it, as it will be removed in the future.'