Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 5 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Commits on Oct 30, 2011
Tom Frost Controller: Silly typo in Router docs. 9db71d8
Commits on Nov 05, 2011
Tom Frost Controller: More documentation typos. 3dafacd
Tom Frost Controller: Adding Router arg protection.
This was inadvertently removed during optimization testing,
causing PHP to throw an error when a routing rule with dynamic
variables triggered a controller function with more arguments
than what the URL supplied.  This has been fixed.
266d667
Tom Frost Controller: Changing ucfirst to capfirst in Router
This makes Router a little more consistent with the Hydrogen
templating engine.
8469027
Tom Frost Merge branch 'master' of github.com:TomFrost/Hydrogen cf83d17
Showing with 11 additions and 7 deletions.
  1. +11 −7 controller/Router.php
18 controller/Router.php
View
@@ -14,7 +14,7 @@
/**
* Router is the preferred method of matching URL requests to Controller
- * objects, making agressive use of caching to stay very quick, regardless of
+ * objects, making aggressive use of caching to stay very quick, regardless of
* the number or complexity of rules defined. Many rules can be added to a
* Router instance without incurring any extra processing or lookup time.
*
@@ -66,7 +66,7 @@
* With the above rule, a request to /login would look for a Controller class
* named 'login' and call its 'greeting' function.
*
- * Consider, though, the liklihood that the controller classes are namespaced
+ * Consider, though, the likelihood that the controller classes are namespaced
* and probably start with a capital first letter. To achieve this, overrides
* can be used. Just as variables in URLs take precedence over the 'defaults'
* array, overrides are applied before any controller function is called.
@@ -83,7 +83,7 @@
* Using a second array of overrides, it's easy to transform a value of
* 'welcome' for the controller into '\myapp\controllers\WelcomeController'.
* In the array of overrides, existing variables can be referenced with
- * %variable or %{variable}. Aditionally, it can be appended with a list of
+ * %variable or %{variable}. Additionally, it can be appended with a list of
* pipe-separated filters to affect a change on the variable contents. Legal
* filters:
*
@@ -309,7 +309,7 @@ protected function applyOverrides(&$vars, &$overrides, &$arraysAsParams) {
$varName = $vars[array_shift($elem)];
foreach ($elem as $filter) {
switch ($filter) {
- case 'ucfirst':
+ case 'capfirst':
$varName = ucfirst($varName);
break;
case 'upper':
@@ -467,7 +467,7 @@ public function get($path, $defaults=null, $overrides=null,
* @param string $errfile The filename in which the error occurred.
* @param int $errline The line number on which the error occurred.
*/
- public function missingArgHandler($errno, $errstr, $errfile,
+ public static function missingArgHandler($errno, $errstr, $errfile,
$errline) {
$errCheck = "Missing argument";
if ($errCheck === substr($errstr, 0, strlen($errCheck)))
@@ -511,7 +511,11 @@ protected function passRequest($controller, $function, $args=null,
if (@class_exists($controller)) {
// Call it, Cap'n.
$inst = $controller::getInstance();
-
+ if ($argProtection === true) {
+ set_error_handler(
+ "\hydrogen\controller\Router::missingArgHandler",
+ E_WARNING);
+ }
try {
call_user_func_array(array($inst, $function), $args ?: array());
}
@@ -602,7 +606,7 @@ protected function processOverrides($overrides) {
foreach ($segment as $filter) {
// Only allow legal filters
switch ($filter) {
- case 'ucfirst':
+ case 'capfirst':
case 'upper':
case 'lower':
$varBlock[] = $filter;

No commit comments for this range

Something went wrong with that request. Please try again.