MoneyType
¶
Contributed by
syastrebov
in #26767.
In Symfony 4.1, the MoneyType form field defines a new option called
rounding_mode
to control how the values are rounded. Before, all values were
rounded towards "the nearest neighbor" (ROUND_HALF_UP
) so 15.999
was
rounded as 15.10
. Now you can set it for example to ROUND_DOWN
to display
it as 15.99
:
1 2 3 4 5 6 7 | use Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer;
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
// ...
$builder->add('price', MoneyType::class, array(
'rounding_mode' => NumberToLocalizedStringTransformer::ROUND_DOWN,
));
|
Contributed by
Jean-Guilhem Rouel
in #21856.
Updating LDAP entries with the update()
is slow in some scenarios. That's
why in Symfony 4.1 there are two new methods called addAttributeValues()
and
removeAttributeValues()
that add/remove values to a multi-valued attribute:
1 2 3 4 5 6 7 8 9 | use Symfony\Component\Ldap\Ldap;
use Symfony\Component\Ldap\Entry;
// ...
$entry = $ldap->query('...', '...')->execute()[0];
$entityManager = $ldap->getEntryManager();
$entityManager->addAttributeValues($entry, 'telephoneNumber', ['+1.111.222.3333', '+1.222.333.4444']);
$entityManager->removeAttributeValues($entry, 'telephoneNumber', ['+1.111.222.3333', '+1.222.333.4444']);
|
Contributed by
Hamza Amrouche
in #26281.
In Symfony 4.1, routes can define (in YAML, XML or PHP) a new option called
keepQueryParams
. By default it's false
, but if you set it to true
,
the query parameters (if any) are added to the redirected URL:
1 2 3 4 5 6 7 | legacy_search:
path: /search-engine
controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction
defaults:
route: search
permanent: true
keepQueryParams: true
|
In this example, if the original URL is /search-engine?q=symfony
, the app
redirects to /search?q=symfony
Contributed by
Sébastien Decrême
in #23617.
The PropertyInfo component introspects information about class properties by
using different sources of metadata. In Symfony 4.1, one of those sources (the
ReflectionExtractor
class) added support for hasser methods.
This will allow for example to make a property readable by defining methods like
hasChildren()
instead of just getChildren()
.
What a Symfony developer should know about the framework: News, Jobs, Tweets, Events, Videos,...