Skip to content

Commit

Permalink
Merge pull request #685 from wilr/wilr-patch-1
Browse files Browse the repository at this point in the history
Allow multibyte to be configured (fixes #605)
  • Loading branch information
GuySartorelli authored Oct 9, 2023
2 parents ff9b019 + 99d1063 commit 08e2bd3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/Model/BlogCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
/**
* A blog category for generalising blog posts.
*
*
* @method Blog Blog()
*
* @property string $Title
Expand All @@ -33,6 +32,8 @@ class BlogCategory extends DataObject implements CategorisationObject
*/
private static $table_name = 'BlogCategory';

private static bool $allow_urlsegment_multibyte = true;

/**
* @var array
*/
Expand Down
7 changes: 1 addition & 6 deletions src/Model/BlogObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,7 @@ public function generateURLSegment($increment = 0)
{
$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);

Expand Down
2 changes: 2 additions & 0 deletions src/Model/BlogTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 08e2bd3

Please sign in to comment.