Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multibyte to be configured (fixes #605) #685

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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