From f57e3a4bf7dc1e299e80b00f8c27112db99fcc32 Mon Sep 17 00:00:00 2001 From: Josh Crawford Date: Thu, 9 Feb 2023 12:54:19 +1100 Subject: [PATCH] Use `ElementHelper::generateSlug` instead of `StringHelper::slugify` --- src/SlugEqualsTitle.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/SlugEqualsTitle.php b/src/SlugEqualsTitle.php index 12543ce..d9eed39 100644 --- a/src/SlugEqualsTitle.php +++ b/src/SlugEqualsTitle.php @@ -9,7 +9,7 @@ use craft\commerce\services\ProductTypes; use craft\elements\Category; use craft\elements\Entry; -use craft\helpers\StringHelper; +use craft\helpers\ElementHelper; use craft\web\View; use internetztube\slugEqualsTitle\assetBundles\ExcludeFromRewriteAssetBundle; use internetztube\slugEqualsTitle\services\ElementStatusService; @@ -41,13 +41,7 @@ public function init() } if (!$toOverwrite) return; - $slug = $element->title; - if (Craft::$app->getConfig()->getGeneral()->limitAutoSlugsToAscii) { - $slug = StringHelper::toAscii($slug, $element->site->language); - } - $slug = StringHelper::slugify($slug, '-', $element->site->language); - - $element->slug = $slug; + $element->slug = ElementHelper::generateSlug($element->title, null, $element->site->language); }; $afterSafeCallback = function(Event $event) {