Browse Source

Refactoring Dispatcher::_isPrivate to directly check for controller methods, doing in in the controller could be unnecessary

José Lorenzo Rodríguez 15 years ago
parent
commit
c431ddd22c
2 changed files with 4 additions and 7 deletions
  1. 2 5
      lib/Cake/Controller/Controller.php
  2. 2 2
      lib/Cake/Routing/Dispatcher.php

+ 2 - 5
lib/Cake/Controller/Controller.php

@@ -308,15 +308,12 @@ class Controller extends Object {
 		}
 		if (empty($this->uses)) {
 			$this->modelClass = Inflector::singularize($this->name);
+		} else {
+			$this->modelClass = current($this->uses);
 		}
 		$this->modelKey = Inflector::underscore($this->modelClass);
 		$this->Components = new ComponentCollection();
 
-		$childMethods = get_class_methods($this);
-		$parentMethods = get_class_methods('Controller');
-
-		$this->methods = array_diff($childMethods, $parentMethods);
-
 		if ($request instanceof CakeRequest) {
 			$this->_setRequest($request);
 		}

+ 2 - 2
lib/Cake/Routing/Dispatcher.php

@@ -143,7 +143,7 @@ class Dispatcher {
 				$privateAction = in_array($prefix, $prefixes);
 			}
 		}
-		return $privateAction;
+		return $privateAction && ! in_array($request->params['action'], get_class_methods('Controller'));
 	}
 
 /**
@@ -160,7 +160,7 @@ class Dispatcher {
 		$controller->constructClasses();
 		$controller->startupProcess();
 
-		$methods = array_flip($controller->methods);
+		$methods = array_flip(get_class_methods($controller));
 
 		if (!isset($methods[$request->params['action']])) {
 			if ($controller->scaffold !== false) {