-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Translation] added option json_options to JsonFileDumper. #14750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -23,9 +23,23 @@ class JsonFileDumper extends FileDumper | |||
/** | |||
* {@inheritdoc} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong docblock. This method isn't inherited from anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ogizanagi
this code inherit my previous, accepted PR:
https://github.com/symfony/symfony/blob/2.8/src/Symfony/Component/Translation/Dumper/FileDumper.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's 2.8 branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry. Now I understand. Please forget about my next comment.
can we found another name rather than |
@aitboudad I will think about better name, just 'options' are even worse. Other alternative is to add several options - one per JSON_* constants and hide from user, that this class use json_encode internally. But it would be hard to maintain such code. |
|
I prefer "json_encoding" for consistency. see https://github.com/symfony/symfony/blob/2.8/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php#L173 |
@@ -23,9 +23,23 @@ class JsonFileDumper extends FileDumper | |||
/** | |||
* {@inheritdoc} | |||
*/ | |||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array()) | |||
{ | |||
$jsonOptions = isset($options['json_options']) ? (int) $options['json_options'] : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer $flags
instead of $jsonOptions
@dosten 👍 |
@dosten 👍 apply |
@@ -23,9 +23,23 @@ class JsonFileDumper extends FileDumper | |||
/** | |||
* {@inheritdoc} | |||
*/ | |||
protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array()) | |||
{ | |||
$flags = isset($options['flags']) ? (int) $options['flags'] : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong, the variable name must be $flags
but the option name must be "json_encoding"
8a92e11
to
fb11aac
Compare
@dosten done |
You should fix the two failing tests |
sorry, missed your message. Done |
👍 |
ping @symfony/deciders |
$flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0; | ||
|
||
if (defined('JSON_PRETTY_PRINT')) { | ||
$flags |= JSON_PRETTY_PRINT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we really force it all them time, even when encoding options are specified ? this forbids disabling the pretty printing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gepo any change to fix this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rewrite this code, do not force pretty print now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sound good to me thanks ^^
It's passed to json_encode function second argument.
Is there a reason to modify the existing test instead of adding an extra one that uses custom options? If I don't miss anything we wouldn't have a test for the default options anymore. |
@gepo Do you have a little time to fix the latest remark :) ? |
Closing in favor of #15756 |
…per. (gepo) This PR was merged into the 2.8 branch. Discussion ---------- [Translation] added option json_options to JsonFileDumper. | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | no | Fixed tickets | ~ | License | MIT | Doc PR | Replaces #14750 Commits ------- bfdc354 [Translation] added option flags to JsonFileDumper. It's passed to json_encode function second argument.
It's passed to json_encode function second argument.