forked from sonata-project/SonataAdminBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Data Transformers in list fields editable fix sonata-project#5693
allow use data_transformer in SetObjectFieldValueAction create BooleanToStringTransformer for allows to use non-strings update SetObjectFieldValueActionTest use yoda conditions fix errors in HelperControllerTest test BooleanToStringTransformer allow override transformers for 'date', 'boolean' and 'choice' field types mark BooleanToStringTransformer and BooleanToStringTransformer classes as final add example of using the data_transformer option in docs add full docs about Symfony Data Transformers optimize resolve Data Transformer fix docs create DataTransformerResolver service add type hint for BooleanToStringTransformer::$trueValue allow add a custom global transformers field type should be a string correct default value for $globalCustomTransformers correct test DataTransformerResolverTest::testAddCustomGlobalTransformer() add BC support usage of DataTransformerResolver Update tests/Action/SetObjectFieldValueActionTest.php Update tests/Action/SetObjectFieldValueActionTest.php Update tests/Form/DataTransformer/BooleanToStringTransformerTest.php Update tests/Form/DataTransformer/BooleanToStringTransformerTest.php Update tests/Form/DataTransformerResolverTest.php Update tests/Form/DataTransformerResolverTest.php Update src/Action/SetObjectFieldValueAction.php change "entity" word to "model" in documentations change deprecated error message add datetime in editable date form types correct test transform datetime and date form types test DateTime object in assertSame() fix typo restore getTemplate() return value in SetObjectFieldValueActionTest use Yoda conditions lazy-load predefined data transformers add DataTransformerResolverInterface use constants for determinate a field type test laze-load data transformers test usage DataTransformerResolver::addCustomGlobalTransformer() create simple function in DataTransformerResolverTest Process deprecation of FieldDescriptionInterface::getTargetEntity() Use FieldDescriptionInterface::getTargetModel if exists sonata-project#6208 change usage getTargetEntity() -> getTargetModel() in DataTransformerResolverTest merge changes from PR sonata-project#6167 register BooleanToStringTransformer as a service
- Loading branch information
1 parent
17083d3
commit 2227502
Showing
16 changed files
with
893 additions
and
49 deletions.
There are no files selected for viewing
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
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
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
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,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sonata\AdminBundle\Form\DataTransformer; | ||
|
||
use Symfony\Component\Form\DataTransformerInterface; | ||
|
||
/** | ||
* This is analog of Symfony\Component\Form\Extension\Core\DataTransformer\BooleanToStringTransformer | ||
* which allows you to use non-strings in reverseTransform() method. | ||
* | ||
* @author Peter Gribanov <[email protected]> | ||
*/ | ||
final class BooleanToStringTransformer implements DataTransformerInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $trueValue; | ||
|
||
public function __construct(string $trueValue) | ||
{ | ||
$this->trueValue = $trueValue; | ||
} | ||
|
||
public function transform($value): ?string | ||
{ | ||
return $value ? $this->trueValue : null; | ||
} | ||
|
||
public function reverseTransform($value): bool | ||
{ | ||
return filter_var($value, FILTER_VALIDATE_BOOLEAN); | ||
} | ||
} |
Oops, something went wrong.