Allow to set the rounding strategy for MoneyType
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 16.00
. 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,
));
Adding and removing LDAP attributes more efficiently
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']);
Keep query string after redirecting
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
Added support for hasser accessors in PropertyInfo
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()
.
"so 15.999 was rounded as 15.10" i would hope not
@Bart that would be a really bad rounding! It's fixed now. Thanks.
Nice improvements !
I hope the final 4.1 version will be released soon !
Great ! I hope I will be able to use 4.1 on my projects :)
@Javier
"that would be a really bad rounding" --- any money rounding is bad rounding.
I do like the redirection with queryParams !
Good job
@Ivan sure! And in the Symfony Docs (e.g. https://symfony.com/doc/current/doctrine.html) we mention this:
cool