Skip to content

Commit f68db3e

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: (33 commits) do not pass a boolean to the constructor of the Dotenv class [Notifier] Fix low-deps tests Deprecate Composer 1 [Filesystem] Add third argument `$lockFile` to `Filesystem::appendToFile()` [TwigBundle] fix auto-enabling assets/expression/routing/yaml/workflow extensions [PhpUnitBridge] fix symlink to bridge in docker by making its path relative [Dotenv] Duplicate $_SERVER values in $_ENV if they don't exist Fix markup [Notifier] Add Expo bridge Add polish translations (#43725) Rename translation:update to translation:extract [String] Add PLURAL_MAP "zombies" -- fix #43789 Added support for `statusCode` default parameter when loading a template directly from route using the `Symfony\Bundle\FrameworkBundle\Controller\TemplateController` controller. [Validator] Update validators.bs.xlf Cache voters that will always abstain [Messenger] Fix `TraceableMessageBus` implementation so it can compute caller even when used within a callback [Validator] Add the missing translations for Russian (ru) [Validator] Added missing translations for Latvian (lv) [Validator] Added missing translations [Validator] Add missing translations for Vietnamese (VI) ...
2 parents 989b337 + 290f5ea commit f68db3e

File tree

9 files changed

+103
-57
lines changed

9 files changed

+103
-57
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ CHANGELOG
3838
* Add `configureContainer()`, `configureRoutes()`, `getConfigDir()` and `getBundlesPath()` to `MicroKernelTrait`
3939
* Add support for configuring log level, and status code by exception class
4040
* Bind the `default_context` parameter onto serializer's encoders and normalizers
41+
* Add support for `statusCode` default parameter when loading a template directly from route using the `Symfony\Bundle\FrameworkBundle\Controller\TemplateController` controller
42+
* Deprecate `translation:update` command, use `translation:extract` instead
4143

4244
5.3
4345
---

Command/TranslationUpdateCommand.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Console\Input\InputArgument;
1818
use Symfony\Component\Console\Input\InputInterface;
1919
use Symfony\Component\Console\Input\InputOption;
20+
use Symfony\Component\Console\Output\ConsoleOutputInterface;
2021
use Symfony\Component\Console\Output\OutputInterface;
2122
use Symfony\Component\Console\Style\SymfonyStyle;
2223
use Symfony\Component\HttpKernel\KernelInterface;
@@ -36,7 +37,7 @@
3637
*
3738
* @final
3839
*/
39-
#[AsCommand(name: 'translation:update', description: 'Update the translation file')]
40+
#[AsCommand(name: 'translation:extract', description: 'Extract missing translations keys from code to translation files.')]
4041
class TranslationUpdateCommand extends Command
4142
{
4243
private const ASC = 'asc';
@@ -78,9 +79,9 @@ protected function configure()
7879
new InputOption('prefix', null, InputOption::VALUE_OPTIONAL, 'Override the default prefix', '__'),
7980
new InputOption('format', null, InputOption::VALUE_OPTIONAL, 'Override the default output format', 'xlf12'),
8081
new InputOption('dump-messages', null, InputOption::VALUE_NONE, 'Should the messages be dumped in the console'),
81-
new InputOption('force', null, InputOption::VALUE_NONE, 'Should the update be done'),
82+
new InputOption('force', null, InputOption::VALUE_NONE, 'Should the extract be done'),
8283
new InputOption('clean', null, InputOption::VALUE_NONE, 'Should clean not found messages'),
83-
new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'Specify the domain to update'),
84+
new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'Specify the domain to extract'),
8485
new InputOption('sort', null, InputOption::VALUE_OPTIONAL, 'Return list of messages sorted alphabetically', 'asc'),
8586
new InputOption('as-tree', null, InputOption::VALUE_OPTIONAL, 'Dump the messages as a tree-like structure: The given value defines the level where to switch to inline YAML'),
8687
])
@@ -122,6 +123,13 @@ protected function configure()
122123
*/
123124
protected function execute(InputInterface $input, OutputInterface $output): int
124125
{
126+
$io = new SymfonyStyle($input, $output);
127+
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
128+
129+
if ('translation:update' === $input->getFirstArgument()) {
130+
$errorIo->caution('Command "translation:update" is deprecated since version 5.4 and will be removed in Symfony 6.0. Use "translation:extract" instead.');
131+
}
132+
125133
$io = new SymfonyStyle($input, $output);
126134
$errorIo = $io->getErrorStyle();
127135

Controller/TemplateController.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,20 @@ public function __construct(Environment $twig = null)
3333
/**
3434
* Renders a template.
3535
*
36-
* @param string $template The template name
37-
* @param int|null $maxAge Max age for client caching
38-
* @param int|null $sharedAge Max age for shared (proxy) caching
39-
* @param bool|null $private Whether or not caching should apply for client caches only
40-
* @param array $context The context (arguments) of the template
36+
* @param string $template The template name
37+
* @param int|null $maxAge Max age for client caching
38+
* @param int|null $sharedAge Max age for shared (proxy) caching
39+
* @param bool|null $private Whether or not caching should apply for client caches only
40+
* @param array $context The context (arguments) of the template
41+
* @param int $statusCode The HTTP status code to return with the response. Defaults to 200
4142
*/
42-
public function templateAction(string $template, int $maxAge = null, int $sharedAge = null, bool $private = null, array $context = []): Response
43+
public function templateAction(string $template, int $maxAge = null, int $sharedAge = null, bool $private = null, array $context = [], int $statusCode = 200): Response
4344
{
4445
if (null === $this->twig) {
4546
throw new \LogicException('You cannot use the TemplateController if the Twig Bundle is not available.');
4647
}
4748

48-
$response = new Response($this->twig->render($template, $context));
49+
$response = new Response($this->twig->render($template, $context), $statusCode);
4950

5051
if ($maxAge) {
5152
$response->setMaxAge($maxAge);
@@ -64,8 +65,8 @@ public function templateAction(string $template, int $maxAge = null, int $shared
6465
return $response;
6566
}
6667

67-
public function __invoke(string $template, int $maxAge = null, int $sharedAge = null, bool $private = null, array $context = []): Response
68+
public function __invoke(string $template, int $maxAge = null, int $sharedAge = null, bool $private = null, array $context = [], int $statusCode = 200): Response
6869
{
69-
return $this->templateAction($template, $maxAge, $sharedAge, $private, $context);
70+
return $this->templateAction($template, $maxAge, $sharedAge, $private, $context, $statusCode);
7071
}
7172
}

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function getConfigTreeBuilder(): TreeBuilder
122122
$parentPackages = (array) $parentPackage;
123123
$parentPackages[] = 'symfony/framework-bundle';
124124

125-
return ContainerBuilder::willBeAvailable($package, $class, $parentPackages);
125+
return ContainerBuilder::willBeAvailable($package, $class, $parentPackages, true);
126126
};
127127

128128
$enableIfStandalone = static function (string $package, string $class) use ($willBeAvailable) {

0 commit comments

Comments
 (0)