diff options
author | AW-UC <git@a-wesemann.de> | 2015-02-20 14:03:34 +0100 |
---|---|---|
committer | AW-UC <git@a-wesemann.de> | 2015-02-20 14:03:34 +0100 |
commit | bc668600cd9c44c9b1efe0d520005ad10e577a02 (patch) | |
tree | 6d5a6af306b882c81c181889aabb8ab667bf7b9a /lib | |
parent | 097d455213ff3134fbbf9689a4c1e739719b4c1e (diff) | |
download | nextcloud-server-bc668600cd9c44c9b1efe0d520005ad10e577a02.tar.gz nextcloud-server-bc668600cd9c44c9b1efe0d520005ad10e577a02.zip |
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/naturalsort.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/private/naturalsort.php b/lib/private/naturalsort.php index d511bfa3f66..57947f56afa 100644 --- a/lib/private/naturalsort.php +++ b/lib/private/naturalsort.php @@ -15,6 +15,19 @@ class NaturalSort { 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 * @return array of strings and number chunks |