Skip to content

Commit c7ba846

Browse files
committed
[Translation][Cache] Removed the options from the arguments of Translator
Fixed phpdoc Aligned variables and description Removed enableCache and added cache setup in constructor Added tests for locales with . and @ with caching
1 parent f46b3f1 commit c7ba846

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Translation/Translator.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ class Translator extends BaseTranslator
2525
protected $container;
2626
protected $loaderIds;
2727

28+
protected $options = array(
29+
'cache_dir' => null,
30+
'debug' => false,
31+
);
32+
2833
/**
2934
* Constructor.
3035
*
@@ -45,7 +50,14 @@ public function __construct(ContainerInterface $container, MessageSelector $sele
4550
$this->container = $container;
4651
$this->loaderIds = $loaderIds;
4752

48-
parent::__construct(null, $selector, $options);
53+
// check option names
54+
if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
55+
throw new \InvalidArgumentException(sprintf('The Translator does not support the following options: \'%s\'.', implode('\', \'', $diff)));
56+
}
57+
58+
$this->options = array_merge($this->options, $options);
59+
60+
parent::__construct(null, $selector, $this->options['cache_dir'], $this->options['debug']);
4961
}
5062

5163
/**

0 commit comments

Comments
 (0)