Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix for issue with dashed routes and vendored plugins
  • Loading branch information
dakota committed Dec 9, 2015
1 parent 50967f6 commit 1f5c9e7
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/Routing/Route/DashedRoute.php
Expand Up @@ -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
Expand All @@ -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(
Expand Down

0 comments on commit 1f5c9e7

Please sign in to comment.