forked from Sylius/Sylius
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug Sylius#9919 Sylius#9858 Fix for promotion of 100 percent with cou…
…pon (laurent35240) This PR was merged into the 1.2 branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | 1.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | fixes Sylius#9858 | License | MIT Commits ------- c46e7b1 Sylius#9858 Fix for promotion of 100 percent with coupon 9280859 Sylius#9858 Another fix for promotion of 100 percent with coupon 4ef4380 PHPDoc added about transformation c2af9ea Sylius#9858 Directly change view transformer to percent float when building the form for promotion
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
Form/DataTransformer/PercentFloatToLocalizedStringTransformer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Bundle\PromotionBundle\Form\DataTransformer; | ||
|
||
use Symfony\Component\Form\Exception\TransformationFailedException; | ||
use Symfony\Component\Form\Extension\Core\DataTransformer\PercentToLocalizedStringTransformer; | ||
|
||
final class PercentFloatToLocalizedStringTransformer extends PercentToLocalizedStringTransformer | ||
{ | ||
/** | ||
* Transforms between a percentage value into a float | ||
* | ||
* @param string $value Percentage value | ||
* | ||
* @return float Normalized value | ||
* | ||
* @throws TransformationFailedException if the given value is not a string or | ||
* if the value could not be transformed | ||
*/ | ||
public function reverseTransform($value) | ||
{ | ||
if ('' === $value) { | ||
return; | ||
} | ||
return (float)parent::reverseTransform($value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters