|
|
@@ -17,17 +17,36 @@ namespace Cake\I18n;
|
|
|
use Aura\Intl\Package;
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
+ * Wraps multiple messages loaders calling them one after another until
|
|
|
+ * one of them returns an non-empty package
|
|
|
*
|
|
|
*/
|
|
|
class ChainMessagesLoader {
|
|
|
|
|
|
+/**
|
|
|
+ * The list of callables to execute one after another for loading messages
|
|
|
+ *
|
|
|
+ * @var array
|
|
|
+ */
|
|
|
protected $_loaders = [];
|
|
|
|
|
|
+/**
|
|
|
+ * Receives a list of callable functions or objects that will be executed
|
|
|
+ * one after another until one of them returns a non-empty translations package
|
|
|
+ *
|
|
|
+ * @param array $loaders List of callables to execute
|
|
|
+ */
|
|
|
public function __construct(array $loaders) {
|
|
|
$this->_loaders = $loaders;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Executes this object for returning the translations package as configured in
|
|
|
+ * the chain.
|
|
|
+ *
|
|
|
+ * @return \Aura\Intl\Package
|
|
|
+ */
|
|
|
+
|
|
|
public function __invoke() {
|
|
|
foreach ($this->_loaders as $k => $loader) {
|
|
|
if (!is_callable($loader)) {
|