From a3c848e4e2d14930c70713e3625d2f89b3cefcbb Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 2 Feb 2015 13:08:56 -0700 Subject: [PATCH] Moved to camels for plugins+themes as optional class naming type --- system/src/Grav/Common/Plugins.php | 2 +- system/src/Grav/Common/Themes.php | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/system/src/Grav/Common/Plugins.php b/system/src/Grav/Common/Plugins.php index 7397c8bb1..dd495963e 100644 --- a/system/src/Grav/Common/Plugins.php +++ b/system/src/Grav/Common/Plugins.php @@ -54,7 +54,7 @@ class Plugins extends Iterator $pluginClassFormat = [ 'Grav\\Plugin\\'.ucfirst($plugin).'Plugin', - 'Grav\\Plugin\\'.str_replace(['_','-'], '', $plugin).'Plugin' + 'Grav\\Plugin\\'.Inflector::camelize($plugin).'Plugin' ]; $pluginClassName = false; diff --git a/system/src/Grav/Common/Themes.php b/system/src/Grav/Common/Themes.php index e7620cede..e44472835 100644 --- a/system/src/Grav/Common/Themes.php +++ b/system/src/Grav/Common/Themes.php @@ -145,10 +145,19 @@ class Themes extends Iterator $class = include $file; if (!is_object($class)) { - $className = '\\Grav\\Theme\\' . ucfirst($name); - if (class_exists($className)) { - $class = new $className($grav, $config, $name); + $themeClassFormat = [ + 'Grav\\Theme\\'.ucfirst($name), + 'Grav\\Theme\\'.Inflector::camelize($name) + ]; + $themeClassName = false; + + foreach ($themeClassFormat as $themeClass) { + if (class_exists($themeClass)) { + $themeClassName = $themeClass; + $class = new $themeClassName($grav, $config, $name); + break; + } } } } elseif (!$locator('theme://') && !defined('GRAV_CLI')) {