From cf45f5163ff46d900ff1be04dbc54d5a57023bd5 Mon Sep 17 00:00:00 2001 From: Damien ALEXANDRE Date: Sun, 14 May 2017 18:47:45 +0200 Subject: [PATCH 1/4] Add Meta Informations to the common Message object --- Changelog.md | 14 +++++++----- Model/SfProfilerMessage.php | 43 +++++++++++++++++++++++++------------ 2 files changed, 38 insertions(+), 19 deletions(-) diff --git a/Changelog.md b/Changelog.md index a6028d1b..c49b9799 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,9 +1,13 @@ # Change Log -The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release. +The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release. ## UNRELEASED +### Changed + +- Add meta informations from the profiler to `Translation\Common\Model\Message` + ## 0.3.2 ### Changed @@ -58,19 +62,19 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee ### Changed - `Translation\Bundle\Service\CatalogueFetcher` moved to `Translation\Bundle\Catalogue\CatalogueFetcher` -- Made most (if not all) classes final. +- Made most (if not all) classes final. - `CatalogueFetcher` requires a `Configuration` object. ### Removed - Dead code in the `SymfonyProfilerController` -- `FileStorage` was moved to `php-translation/symfony-storage` +- `FileStorage` was moved to `php-translation/symfony-storage` ### Fixed -- The bundle works without any configuration. +- The bundle works without any configuration. - You may have an config named "default". ## 0.1.0 -First release. +First release. diff --git a/Model/SfProfilerMessage.php b/Model/SfProfilerMessage.php index 86df4f5c..a42b11e8 100644 --- a/Model/SfProfilerMessage.php +++ b/Model/SfProfilerMessage.php @@ -116,20 +116,35 @@ public static function create(array $data) return $message; } - /** - * Convert to a Common\Message. - * - * @return Message - */ - public function convertToMessage() - { - return new Message( - $this->key, - $this->domain, - $this->locale, - $this->translation - ); - } + /** + * Convert to a Common\Message. + * + * @return Message + */ + public function convertToMessage() + { + $meta = []; + + if (!empty($this->getParameters())) { + $meta['parameters'] = $this->getParameters(); + } + + if (!empty($this->getCount())) { + $meta['count'] = $this->getCount(); + } + + if (!empty($this->getTransChoiceNumber())) { + $meta['transChoiceNumber'] = $this->getTransChoiceNumber(); + } + + return new Message( + $this->key, + $this->domain, + $this->locale, + $this->translation, + $meta + ); + } /** * @return int From 28247db613b696c6fc46bfa281e329c843dd5ab5 Mon Sep 17 00:00:00 2001 From: Damien ALEXANDRE Date: Wed, 31 May 2017 12:00:29 +0200 Subject: [PATCH 2/4] Clean up the parameters to only have one occurence of each key --- Model/SfProfilerMessage.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Model/SfProfilerMessage.php b/Model/SfProfilerMessage.php index a42b11e8..0f422b5e 100644 --- a/Model/SfProfilerMessage.php +++ b/Model/SfProfilerMessage.php @@ -126,7 +126,8 @@ public function convertToMessage() $meta = []; if (!empty($this->getParameters())) { - $meta['parameters'] = $this->getParameters(); + // Reduce to only get one value of each parameter, not all the usages. + $meta['parameters'] = array_reduce($this->getParameters(), 'array_merge', array()); } if (!empty($this->getCount())) { From d9b16a12a4fd7ecc2a4c3af3eccb107c2d4ce4d1 Mon Sep 17 00:00:00 2001 From: Damien Alexandre Date: Wed, 31 May 2017 12:07:40 +0200 Subject: [PATCH 3/4] Fix coding style --- Model/SfProfilerMessage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/SfProfilerMessage.php b/Model/SfProfilerMessage.php index 0f422b5e..1835702b 100644 --- a/Model/SfProfilerMessage.php +++ b/Model/SfProfilerMessage.php @@ -127,7 +127,7 @@ public function convertToMessage() if (!empty($this->getParameters())) { // Reduce to only get one value of each parameter, not all the usages. - $meta['parameters'] = array_reduce($this->getParameters(), 'array_merge', array()); + $meta['parameters'] = array_reduce($this->getParameters(), 'array_merge', []); } if (!empty($this->getCount())) { From dd8b5630585c86ca2fe1a73fdd2807ccddd824a0 Mon Sep 17 00:00:00 2001 From: Damien ALEXANDRE Date: Wed, 31 May 2017 20:04:03 +0200 Subject: [PATCH 4/4] Drop HHVM support \o/ --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3253fb57..c19a0fb0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,6 @@ php: - 5.6 - 7.0 - 7.1 - - hhvm env: global: