Skip to content

Commit

Permalink
Refactoring Dispatcher::_isPrivate to directly check for controller m…
Browse files Browse the repository at this point in the history
…ethods, doing in in the controller could be unnecessary
  • Loading branch information
lorenzo committed Dec 7, 2010
1 parent 1d67d16 commit c431ddd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 2 additions & 5 deletions lib/Cake/Controller/Controller.php
Expand Up @@ -308,15 +308,12 @@ public function __construct($request = null) {
}
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);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Routing/Dispatcher.php
Expand Up @@ -143,7 +143,7 @@ protected function _isPrivateAction($request) {
$privateAction = in_array($prefix, $prefixes);
}
}
return $privateAction;
return $privateAction && ! in_array($request->params['action'], get_class_methods('Controller'));
}

/**
Expand All @@ -160,7 +160,7 @@ protected function _invoke(Controller $controller, CakeRequest $request) {
$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) {
Expand Down

0 comments on commit c431ddd

Please sign in to comment.