Created
December 6, 2012 08:35
-
-
Save tigrang/4222765 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
App::uses('CakeRoute', 'Routing/Route'); | |
class HyphenRoute extends CakeRoute { | |
public function parse($url) { | |
if ($route = parent::parse($url)) { | |
if (strtolower($route['action'] !== $route['action'])) { | |
throw new NotFoundException(); | |
} | |
if (strpos($route['action'], '-') !== false) { | |
$route['action'] = Inflector::variable(str_replace('-', ' ', $route['action'])); | |
} | |
} | |
return $route; | |
} | |
protected function _writeUrl($params) { | |
$params['action'] = str_replace('_', '-', Inflector::underscore($params['action'])); | |
return parent::_writeUrl($params); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment