From 360843c7413e726ba66347df3c257e7a36ff3f45 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Fri, 13 Jul 2018 16:59:39 +0200 Subject: [PATCH] Treat CamelCase'd strings as multiple words resolves #3090 --- CHANGELOG-v3.md | 1 + src/helpers/StringHelper.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-v3.md b/CHANGELOG-v3.md index 72c57485017..df6a8e0a83d 100644 --- a/CHANGELOG-v3.md +++ b/CHANGELOG-v3.md @@ -23,6 +23,7 @@ - `Craft.EntryTypeSwitcher` now triggers a `typeChange` event after switching the entry type. ([#3067](https://github.com/craftcms/cms/pull/3067)) - Reduced the left and right padding in the Control Panel for screens less than 768 pixels wide. ([#3073](https://github.com/craftcms/cms/issues/3073)) - Removed the `useXSendFile` config setting as it’s no longer being used. +- `craft\helpers\StringHelper::toKebabCase()`, `toCamelCase()`, `toPascalCase()`, and `toSnakeCase()` now treat camelCase’d and PascalCale’d strings as multiple words. ([#3090](https://github.com/craftcms/cms/issues/3090)) ### Fixed - Fixed a bug where `craft\i18n\I18N::getPrimarySiteLocale()` and `getPrimarySiteLocaleId()` were returning locale info for the _first_ site, rather than the primary one. ([#3063](https://github.com/craftcms/cms/issues/3063)) diff --git a/src/helpers/StringHelper.php b/src/helpers/StringHelper.php index d19b319f803..943696c9ef3 100644 --- a/src/helpers/StringHelper.php +++ b/src/helpers/StringHelper.php @@ -11,6 +11,7 @@ use Stringy\Stringy as BaseStringy; use yii\base\Exception; use yii\base\InvalidConfigException; +use yii\helpers\Inflector; /** * This helper class provides various multi-byte aware string related manipulation and encoding methods. @@ -1040,7 +1041,7 @@ private static function _prepStringForCasing(string $string, bool $lower = true, { if ($lower) { // Make it lowercase - $string = static::toLowerCase($string); + $string = Inflector::camel2words($string, false); } if ($removePunctuation) {