From 1f5c9e7ceb5754343fb018c4a676e4d6469bf641 Mon Sep 17 00:00:00 2001 From: Walther Lalk Date: Wed, 9 Dec 2015 09:35:03 +0200 Subject: [PATCH] Fix for issue with dashed routes and vendored plugins --- src/Routing/Route/DashedRoute.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/Routing/Route/DashedRoute.php b/src/Routing/Route/DashedRoute.php index 2e15301258a..585d5cd6e19 100644 --- a/src/Routing/Route/DashedRoute.php +++ b/src/Routing/Route/DashedRoute.php @@ -34,6 +34,21 @@ class DashedRoute extends Route */ protected $_inflectedDefaults = false; + /** + * Camelizes the previously dashed plugin route taking into account plugin vendors + * + * @param string $plugin Plugin name + * @return string + */ + protected function _camelizePlugin($plugin) { + $plugin = str_replace('-', '_', $plugin); + if (strpos($plugin, '/') === false) { + return Inflector::camelize($plugin); + } + list($vendor, $plugin) = explode('/', $plugin, 1); + return Inflector::camelize($vendor) . '/' . Inflector::camelize($plugin); + } + /** * Parses a string URL into an array. If it matches, it will convert the * controller and plugin keys to their CamelCased form and action key to @@ -56,11 +71,7 @@ public function parse($url) )); } if (!empty($params['plugin'])) { - $params['plugin'] = Inflector::camelize(str_replace( - '-', - '_', - $params['plugin'] - )); + $params['plugin'] = $this->_camelizePlugin($params['plugin']); } if (!empty($params['action'])) { $params['action'] = Inflector::variable(str_replace(