From 4d5d7a34a15d638ba51d42b0d3ef756106d4f424 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Fri, 14 Jun 2019 15:31:01 +1200 Subject: [PATCH] NEW Add FilterInterface and retrofit into URLSegmentFilter There are other filters in the core SilverStripe product, e.g. FileNameFilter in silverstripe/assets which would benefit from having a common filter interface. This retrofits one for URLSegmentFilter in framework. I have not added any PHP 7 syntax in method signatures to avoid breaking backwards compatibility. --- src/View/Parsers/FilterInterface.php | 22 +++++++++++++ src/View/Parsers/URLSegmentFilter.php | 47 +++++++++++++++------------ 2 files changed, 48 insertions(+), 21 deletions(-) create mode 100644 src/View/Parsers/FilterInterface.php diff --git a/src/View/Parsers/FilterInterface.php b/src/View/Parsers/FilterInterface.php new file mode 100644 index 000000000..90b86386c --- /dev/null +++ b/src/View/Parsers/FilterInterface.php @@ -0,0 +1,22 @@ +replacements = $r; + $this->replacements = $replacements; + return $this; } /** - * @return array + * @return string[] */ public function getReplacements() { - return ($this->replacements) ? $this->replacements : (array)$this->config()->default_replacements; + return $this->replacements ?: (array)$this->config()->get('default_replacements'); } /** - * @var Transliterator - */ - protected $transliterator; - - /** - * @return Transliterator + * @return Transliterator|null */ public function getTransliterator() { - if ($this->transliterator === null && $this->config()->default_use_transliterator) { + if ($this->transliterator === null && $this->config()->get('default_use_transliterator')) { $this->transliterator = Transliterator::create(); } return $this->transliterator; } /** - * @param Transliterator $t + * @param Transliterator $transliterator + * @return $this */ - public function setTransliterator($t) + public function setTransliterator($transliterator) { - $this->transliterator = $t; + $this->transliterator = $transliterator; + return $this; } - /** - * @var boolean - */ - protected $allowMultibyte; - /** * @param boolean */