-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
1,367 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,33 @@ | ||
UPGRADE 3.x | ||
=========== | ||
|
||
UPGRADE FROM 3.x to 3.x | ||
======================= | ||
|
||
## Formatters for writers | ||
|
||
- Added `Sonata\Exporter\Formatter\BoolFormatter`, `Sonata\Exporter\Formatter\DateIntervalFormatter`, `Sonata\Exporter\Formatter\DateTimeFormatter`, | ||
`Sonata\Exporter\Formatter\EnumFormatter`, `Sonata\Exporter\Formatter\IterableFormatter`, `Sonata\Exporter\Formatter\StringableFormatter` and | ||
`Sonata\Exporter\Formatter\SymfonyTranslationFormatter` | ||
classes to be used within implementations of `Sonata\Exporter\Formatter\Writer\FormatAwareInterface`. | ||
- Deprecated `Sonata\Exporter\Writer\FormattedBoolWriter`, use `Sonata\Exporter\Formatter\BoolFormatter` instead. | ||
- Deprecated arguments `dateTimeFormat` and `useBackedEnumValue` in `Sonata\Exporter\Source\AbstractPropertySourceIterator::__construct()` and | ||
their children classes. To disable the source formatting you MUST pass `true` in argument `disableSourceFormatters` and use | ||
`Sonata\Exporter\Formatter\Writer\FormatAwareInterface::addFormatter()` in your writers instead. | ||
|
||
## Symfony Bridge | ||
|
||
- Added `sonata_exporter.writers.{writer}.formatters` configuration in order to determine which formatters will be used by each writer. | ||
|
||
```yaml | ||
sonata_exporter: | ||
writers: | ||
csv: | ||
formatters: | ||
- datetime | ||
- enum | ||
# - ... | ||
``` | ||
|
||
By default, "bool", "dateinterval", "datetime", "enum", "iterable" and "stringable" formatters are configured. | ||
If "symfony/translations-contracts" is installed, "symfony_translator" formatter is also enabled. |
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
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
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,39 @@ | ||
<?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\Exporter\Formatter; | ||
|
||
final class BoolFormatter implements FormatterInterface | ||
{ | ||
private const LABEL_TRUE = 'yes'; | ||
private const LABEL_FALSE = 'no'; | ||
|
||
public function __construct( | ||
private string $trueLabel = self::LABEL_TRUE, | ||
private string $falseLabel = self::LABEL_FALSE | ||
) { | ||
} | ||
|
||
public function format(array $data): array | ||
{ | ||
foreach ($data as $key => $value) { | ||
if (!\is_bool($value)) { | ||
continue; | ||
} | ||
|
||
$data[$key] = $value ? $this->trueLabel : $this->falseLabel; | ||
} | ||
|
||
return $data; | ||
} | ||
} |
Oops, something went wrong.