Add constructor to inject collator
Adding the possibility for instantiating \OC\NaturalSort with an injected collator. This makes the use of a specific collator enforcable.
This commit is contained in:
parent
097d455213
commit
bc668600cd
|
@ -14,6 +14,19 @@ class NaturalSort {
|
|||
private $collator;
|
||||
private $cache = array();
|
||||
|
||||
/**
|
||||
* Instantiate a new \OC\NaturalSort instance.
|
||||
* @param object $injectedCollator
|
||||
*/
|
||||
public function __construct($injectedCollator = null) {
|
||||
// inject an instance of \Collator('en_US') to force using the php5-intl Collator
|
||||
// or inject an instance of \OC\NaturalSort_DefaultCollator to force using Owncloud's default collator
|
||||
if (isset($injectedCollator)) {
|
||||
$this->collator = $injectedCollator;
|
||||
\OC_Log::write('core', 'forced use of '.get_class($injectedCollator), \OC_Log::DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Split the given string in chunks of numbers and strings
|
||||
* @param string $t string
|
||||
|
|
Loading…
Reference in New Issue