Skip to content

Conversation

@Kocal
Copy link
Member

@Kocal Kocal commented Dec 19, 2025

Q A
Bug fix? no
New feature? yes
Deprecations? no
Documentation? no
Issues Fix #...
License MIT

This PR simplifies how TranslationsDumper works by moving all configuration options from the constructor/setters into the dump() method itself.

Even if using the TranslationsDumper directly is not a common use case (most users will the default behavior with the cache warmer), this change improves the overall design of the class:

  • no stateful instance
  • only one place to configure settings, instead of __construct() and setters
  • adding new options will be easier in the future

Promise, this is the last BC for Translator 🙏🏻

@Kocal Kocal self-assigned this Dec 19, 2025
@carsonbot carsonbot added Feature New Feature Status: Needs Review Needs to be reviewed labels Dec 19, 2025
@Kocal Kocal force-pushed the translator-refactor-dumper-args branch from a06c07a to 4addfcb Compare December 19, 2025 07:28
@Kocal Kocal changed the title [Translator] Refactor TranslationsDumper options from __constructor to dump method [Translator] Refactor TranslationsDumper options from __constructor and setters, to dump method Dec 19, 2025
@Kocal Kocal requested a review from Copilot December 19, 2025 07:28
@Kocal Kocal force-pushed the translator-refactor-dumper-args branch from 4addfcb to fbd61c7 Compare December 19, 2025 07:32
@Kocal Kocal requested a review from smnandre December 19, 2025 07:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the TranslationsDumper class by moving configuration options (dump directory, TypeScript flag, and domain filters) from constructor parameters and setter methods into parameters of the dump() method itself. This simplifies the API by eliminating hidden state and making the configuration explicit at the point of use.

Key Changes

  • Removed $dumpDir and $dumpTypeScript from TranslationsDumper constructor; now passed to dump() method
  • Removed addIncludedDomain() and addExcludedDomain() setter methods; replaced with array parameters in dump() method
  • Updated TranslationsCacheWarmer to store configuration and pass it to dump() method
  • Updated dependency injection configuration to wire arguments into TranslationsCacheWarmer instead of TranslationsDumper

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Translator/src/TranslationsDumper.php Refactored constructor and dump method to accept configuration as method parameters instead of constructor/setter state
src/Translator/src/CacheWarmer/TranslationsCacheWarmer.php Added configuration parameters to constructor and passes them to dump method
src/Translator/src/DependencyInjection/UxTranslatorExtension.php Updated to wire configuration arguments into cache warmer instead of dumper service
src/Translator/config/services.php Updated service definitions to reflect new constructor signatures
src/Translator/tests/TranslationsDumperTest.php Updated all tests to use new dump method signature with named parameters
src/Translator/tests/CacheWarmer/TranslationsCacheWarmerTest.php Updated mock expectations to match new dump method signature
src/Translator/CHANGELOG.md Added breaking change entry for this refactoring

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +21 to +22
* @internal
*
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was initially missing

@Kocal Kocal force-pushed the translator-refactor-dumper-args branch from fbd61c7 to 787e493 Compare December 19, 2025 19:14
@Kocal Kocal force-pushed the translator-refactor-dumper-args branch from 787e493 to cbed37a Compare December 20, 2025 07:44
@Kocal Kocal merged commit c8a47ec into symfony:2.x Dec 20, 2025
26 of 34 checks passed
@Kocal Kocal deleted the translator-refactor-dumper-args branch December 20, 2025 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature New Feature Status: Needs Review Needs to be reviewed Translator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants