From 99d1063361018e924662fd9392209df28710873e Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Mon, 22 Aug 2022 15:37:28 +1200 Subject: [PATCH] FIX: Allow multibyte to be configured (#605) --- src/Model/BlogCategory.php | 3 ++- src/Model/BlogObject.php | 7 +------ src/Model/BlogTag.php | 2 ++ 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Model/BlogCategory.php b/src/Model/BlogCategory.php index ae69c7d..5734b1d 100644 --- a/src/Model/BlogCategory.php +++ b/src/Model/BlogCategory.php @@ -7,7 +7,6 @@ use SilverStripe\ORM\DataObject; /** * A blog category for generalising blog posts. * -* * @method Blog Blog() * * @property string $Title @@ -33,6 +32,8 @@ class BlogCategory extends DataObject implements CategorisationObject */ private static $table_name = 'BlogCategory'; + private static bool $allow_urlsegment_multibyte = true; + /** * @var array */ diff --git a/src/Model/BlogObject.php b/src/Model/BlogObject.php index d067fb3..af53dc8 100644 --- a/src/Model/BlogObject.php +++ b/src/Model/BlogObject.php @@ -181,12 +181,7 @@ trait BlogObject { $increment = (int) $increment; $filter = URLSegmentFilter::create(); - - // Setting this to on. Because of the UI flow, it would be quite a lot of work - // to support turning this off. (ie. the add by title flow would not work). - // If this becomes a problem we can approach it then. - // @see https://github.com/silverstripe/silverstripe-blog/issues/376 - $filter->setAllowMultibyte(true); + $filter->setAllowMultibyte($this->config()->get('allow_urlsegment_multibyte') ?? true); $this->URLSegment = $filter->filter($this->Title); diff --git a/src/Model/BlogTag.php b/src/Model/BlogTag.php index 4180f67..9735493 100644 --- a/src/Model/BlogTag.php +++ b/src/Model/BlogTag.php @@ -18,6 +18,8 @@ class BlogTag extends DataObject implements CategorisationObject { use BlogObject; + private static bool $allow_urlsegment_multibyte = true; + /** * Use an exception code so that attempted writes can continue on * duplicate errors.