New in Symfony 4.1: Misc. improvements (part 2)
![Avatar of Javier Eguiluz](https://connect.symfony.com/api/images/17170f22-52c0-4adf-a75d-29cb01d53176.png?format=80x80)
Warning: This post is about an unsupported Symfony version. Some of this information may be out of date. Read the most recent Symfony Docs.
New choice_translation_locale
option
Contributed by
Yonel Ceruto
in #26825.
In Symfony 4.1, the CountryType, CurrencyType, LanguageType and
LocaleType form fields define a new choice_translation_locale
option to
change the locale used to translate their lists of elements. In previous Symfony
versions, elements were always translated to the current locale:
1 2 3 4
$formBuilder->add('country', CountryType::class, [
// translate elements into Spanish, regardless of the current locale
'choice_translation_locale' => 'es',
]);
Added a command to delete cache pool items
Contributed by
Pierre du Plessis
in #26223.
In Symfony 4.1, there is a new cache:pool:delete
command that allows you to
delete specific items from the cache pool. This is mostly useful while developing
the application, to not delete the entire cache pool when you only need to clear
one element:
1
$ php bin/console cache:pool:delete <cache-pool-name> <cache-key-name>
Use custom functions in allow_if
expressions
Contributed by
David Maicher
in #26660.
In complex applications, the access_control
security config can include
security expressions defined with the ExpressionLanguage component:
1 2 3 4 5 6 7
# config/packages/security.yaml
security:
# ...
access_control:
-
path: ^/_internal/secure
allow_if: "'127.0.0.1' == request.getClientIp() or has_role('ROLE_ADMIN')"
In Symfony 4.1, allow_if
expressions can also include any
custom ExpressionLanguage functions defined in your application.
Added a dd()
debug helper
Contributed by
Nicolas Grekas
in #26970.
Using a debugger connected to your code editor is the best way to debug your
applications. However, sometimes a call to the dump() function can be as
effective as the debugger and much faster to execute. In Symfony 4.1 we
introduced a helper called dd()
that dumps the given information and stops
the application immediately, which is a common workflow when debugging apps:
1 2 3
dd($user, $request);
// equivalent to:
// dump($user, $request); exit(1);
Help the Symfony project!
As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.
Comments
![Avatar of Reynier Perez Mira](https://connect.symfony.com/api/images/1415ee12-187c-4a2c-8344-01a376f52019.png?format=40x40)
![Avatar of Marcel Stratu](https://connect.symfony.com/api/images/84c8cdd5-dab9-42db-b1cf-ddde0d24fcdf.png?format=40x40)
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.