Skip to content

Commit 5b5fb76

Browse files
damienalexandreNyholm
authored andcommitted
Add Meta Informations to the common Message object (#98)
* Add Meta Informations to the common Message object * Clean up the parameters to only have one occurence of each key * Fix coding style * Drop HHVM support \o/
1 parent 1ca7b05 commit 5b5fb76

File tree

3 files changed

+39
-20
lines changed

3 files changed

+39
-20
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ php:
1414
- 5.6
1515
- 7.0
1616
- 7.1
17-
- hhvm
1817

1918
env:
2019
global:

Changelog.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
# Change Log
22

3-
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.
3+
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.
44

55
## UNRELEASED
66

7+
### Changed
8+
9+
- Add meta informations from the profiler to `Translation\Common\Model\Message`
10+
711
## 0.3.2
812

913
### Changed
@@ -58,19 +62,19 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
5862
### Changed
5963

6064
- `Translation\Bundle\Service\CatalogueFetcher` moved to `Translation\Bundle\Catalogue\CatalogueFetcher`
61-
- Made most (if not all) classes final.
65+
- Made most (if not all) classes final.
6266
- `CatalogueFetcher` requires a `Configuration` object.
6367

6468
### Removed
6569

6670
- Dead code in the `SymfonyProfilerController`
67-
- `FileStorage` was moved to `php-translation/symfony-storage`
71+
- `FileStorage` was moved to `php-translation/symfony-storage`
6872

6973
### Fixed
7074

71-
- The bundle works without any configuration.
75+
- The bundle works without any configuration.
7276
- You may have an config named "default".
7377

7478
## 0.1.0
7579

76-
First release.
80+
First release.

Model/SfProfilerMessage.php

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -116,20 +116,36 @@ public static function create(array $data)
116116
return $message;
117117
}
118118

119-
/**
120-
* Convert to a Common\Message.
121-
*
122-
* @return Message
123-
*/
124-
public function convertToMessage()
125-
{
126-
return new Message(
127-
$this->key,
128-
$this->domain,
129-
$this->locale,
130-
$this->translation
131-
);
132-
}
119+
/**
120+
* Convert to a Common\Message.
121+
*
122+
* @return Message
123+
*/
124+
public function convertToMessage()
125+
{
126+
$meta = [];
127+
128+
if (!empty($this->getParameters())) {
129+
// Reduce to only get one value of each parameter, not all the usages.
130+
$meta['parameters'] = array_reduce($this->getParameters(), 'array_merge', []);
131+
}
132+
133+
if (!empty($this->getCount())) {
134+
$meta['count'] = $this->getCount();
135+
}
136+
137+
if (!empty($this->getTransChoiceNumber())) {
138+
$meta['transChoiceNumber'] = $this->getTransChoiceNumber();
139+
}
140+
141+
return new Message(
142+
$this->key,
143+
$this->domain,
144+
$this->locale,
145+
$this->translation,
146+
$meta
147+
);
148+
}
133149

134150
/**
135151
* @return int

0 commit comments

Comments
 (0)