Skip to content

Commit ec9c2b4

Browse files
authored
add support for options (#7)
1 parent 08e93b6 commit ec9c2b4

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/FileStorage.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ final class FileStorage implements Storage, TransferableStorage
4141
*/
4242
private $dir;
4343

44+
/**
45+
* @var array with option to the dumper
46+
*/
47+
private $options;
48+
4449
/**
4550
* @var MessageCatalogue[] Fetched catalogies
4651
*/
@@ -50,8 +55,9 @@ final class FileStorage implements Storage, TransferableStorage
5055
* @param TranslationWriter $writer
5156
* @param SymfonyTranslationLoader|TranslationLoader $loader
5257
* @param array $dir
58+
* @param array $options
5359
*/
54-
public function __construct(TranslationWriter $writer, $loader, array $dir)
60+
public function __construct(TranslationWriter $writer, $loader, array $dir, array $options = [])
5561
{
5662
if (!$loader instanceof SymfonyTranslationLoader && !$loader instanceof TranslationLoader) {
5763
throw new \LogicException('Second parameter of FileStorage must be a Symfony translation loader or implement Translation\SymfonyStorage\TranslationLoader');
@@ -64,6 +70,7 @@ public function __construct(TranslationWriter $writer, $loader, array $dir)
6470
$this->writer = $writer;
6571
$this->loader = $loader;
6672
$this->dir = $dir;
73+
$this->options = $options;
6774
}
6875

6976
/**
@@ -141,10 +148,12 @@ public function import(MessageCatalogueInterface $catalogue)
141148
private function writeCatalogue(MessageCatalogue $catalogue, $locale, $domain)
142149
{
143150
$resources = $catalogue->getResources();
151+
$options = $this->options;
144152
foreach ($resources as $resource) {
145153
$path = (string) $resource;
146154
if (preg_match('|/'.$domain.'\.'.$locale.'\.([a-z]+)$|', $path, $matches)) {
147-
$this->writer->writeTranslations($catalogue, $matches[1], ['path' => str_replace($matches[0], '', $path)]);
155+
$options['path'] = str_replace($matches[0], '', $path);
156+
$this->writer->writeTranslations($catalogue, $matches[1], $options);
148157
}
149158
}
150159
}

0 commit comments

Comments
 (0)