Skip to content

Commit 2c5a4d6

Browse files
authored
Fix(deprecations) Fix deprecations in sfMessageSource_Aggregate (#277)
* Fix(deprecations) Fix deprecations in sfMessageSource_Aggregate, add return types from implemented sfIMessageSource
1 parent 31d2c60 commit 2c5a4d6

File tree

2 files changed

+68
-2
lines changed

2 files changed

+68
-2
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
CHANGELOG
22
=========
33

4+
=======
45
xx/xx/xxxx: Version 1.5.16
56
--------------------------
67

Diff for: lib/i18n/sfMessageSource_Aggregate.class.php

+67-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
*/
1919
class sfMessageSource_Aggregate extends sfMessageSource
2020
{
21-
protected
22-
$messageSources = array();
21+
protected $messageSources = array();
2322

2423
/**
2524
* Constructor.
@@ -46,6 +45,12 @@ public function setCulture($culture)
4645
}
4746
}
4847

48+
/**
49+
* Gets the last modified unix-time for this particular catalogue+variant.
50+
*
51+
* @param string $source catalogue+variant
52+
* @return int last modified in unix-time format.
53+
*/
4954
protected function getLastModified($sources)
5055
{
5156
$lastModified = time();
@@ -60,6 +65,12 @@ protected function getLastModified($sources)
6065
return $lastModified;
6166
}
6267

68+
/**
69+
* Determines if the source is valid.
70+
*
71+
* @param string $source catalogue+variant
72+
* @return boolean true if valid, false otherwise.
73+
*/
6374
public function isValidSource($sources)
6475
{
6576
foreach ($sources as $source)
@@ -75,6 +86,12 @@ public function isValidSource($sources)
7586
return false;
7687
}
7788

89+
/**
90+
* Gets the source, this could be a filename or database ID.
91+
*
92+
* @param string $variant catalogue+variant
93+
* @return string the resource key
94+
*/
7895
public function getSource($variant)
7996
{
8097
$sources = array();
@@ -86,6 +103,12 @@ public function getSource($variant)
86103
return $sources;
87104
}
88105

106+
/**
107+
* Loads the message for a particular catalogue+variant.
108+
* This methods needs to implemented by subclasses.
109+
*
110+
* @return array of translation messages.
111+
*/
89112
public function &loadData($sources)
90113
{
91114
$messages = array();
@@ -106,6 +129,13 @@ public function &loadData($sources)
106129
return $messages;
107130
}
108131

132+
/**
133+
* Gets all the variants of a particular catalogue.
134+
* This method must be implemented by subclasses.
135+
*
136+
* @param string $catalogue catalogue name
137+
* @return array list of all variants for this catalogue.
138+
*/
109139
public function getCatalogueList($catalogue)
110140
{
111141
$variants = array();
@@ -120,6 +150,12 @@ public function getCatalogueList($catalogue)
120150
return $variants;
121151
}
122152

153+
/**
154+
* Adds a untranslated message to the source. Need to call save()
155+
* to save the messages to source.
156+
*
157+
* @param string $message message to add
158+
*/
123159
public function append($message)
124160
{
125161
// Append to the first message source only
@@ -129,6 +165,15 @@ public function append($message)
129165
}
130166
}
131167

168+
/**
169+
* Updates the translation.
170+
*
171+
* @param string $text the source string.
172+
* @param string $target the new translation string.
173+
* @param string $comments comments
174+
* @param string $catalogue the catalogue of the translation.
175+
* @return boolean true if translation was updated, false otherwise.
176+
*/
132177
public function update($text, $target, $comments, $catalogue = 'messages')
133178
{
134179
// Only update one message source
@@ -143,6 +188,13 @@ public function update($text, $target, $comments, $catalogue = 'messages')
143188
return false;
144189
}
145190

191+
/**
192+
* Deletes a particular message from the specified catalogue.
193+
*
194+
* @param string $message the source message to delete.
195+
* @param string $catalogue the catalogue to delete from.
196+
* @return boolean true if deleted, false otherwise.
197+
*/
146198
public function delete($message, $catalogue = 'messages')
147199
{
148200
$retval = false;
@@ -157,6 +209,14 @@ public function delete($message, $catalogue = 'messages')
157209
return $retval;
158210
}
159211

212+
/**
213+
* Saves the list of untranslated blocks to the translation source.
214+
* If the translation was not found, you should add those
215+
* strings to the translation source via the <b>append()</b> method.
216+
*
217+
* @param string $catalogue the catalogue to add to
218+
* @return boolean true if saved successfuly, false otherwise.
219+
*/
160220
public function save($catalogue = 'messages')
161221
{
162222
$retval = false;
@@ -182,6 +242,11 @@ public function getId()
182242
return md5($id);
183243
}
184244

245+
/**
246+
* Returns a list of catalogue as key and all it variants as value.
247+
*
248+
* @return array list of catalogues
249+
*/
185250
public function catalogues()
186251
{
187252
throw new sfException('The "catalogues()" method is not implemented for this message source.');

0 commit comments

Comments
 (0)