Skip to content

Commit

Permalink
minor #27712 [Serializer] CsvEncoder::AS_COLLECTION_KEY constant (ogi…
Browse files Browse the repository at this point in the history
…zanagi)

This PR was merged into the 4.1 branch.

Discussion
----------

[Serializer] CsvEncoder::AS_COLLECTION_KEY constant

| Q             | A
| ------------- | ---
| Branch?       | 4.1 <!-- see below -->
| Bug fix?      | no
| New feature?  | not really <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets | N/A   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | N/A

We use public constants for context options. For 4.1 IMHO as a consistency fix.

Commits
-------

660a456 [Serializer] CsvEncoder::AS_COLLECTION_KEY constant
  • Loading branch information
fabpot committed Jun 25, 2018
2 parents e32b965 + 660a456 commit 6f47d0c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Symfony/Component/Serializer/Encoder/CsvEncoder.php
Expand Up @@ -28,6 +28,7 @@ class CsvEncoder implements EncoderInterface, DecoderInterface
const KEY_SEPARATOR_KEY = 'csv_key_separator';
const HEADERS_KEY = 'csv_headers';
const ESCAPE_FORMULAS_KEY = 'csv_escape_formulas';
const AS_COLLECTION_KEY = 'as_collection';

private $delimiter;
private $enclosure;
Expand Down Expand Up @@ -157,7 +158,7 @@ public function decode($data, $format, array $context = array())
}
fclose($handle);

if ($context['as_collection'] ?? false) {
if ($context[self::AS_COLLECTION_KEY] ?? false) {
return $result;
}

Expand Down
Expand Up @@ -324,7 +324,7 @@ public function testDecodeOnlyOneAsCollection()
a
CSV
, 'csv', array('as_collection' => true)));
, 'csv', array(CsvEncoder::AS_COLLECTION_KEY => true)));
}

public function testDecodeToManyRelation()
Expand Down

0 comments on commit 6f47d0c

Please sign in to comment.