Permalink
Browse files

Changed protected callbacks of scaffold to public in Controller.

  • Loading branch information...
jrbasso committed Aug 22, 2011
1 parent f7f3515 commit dbb87a01960da8f371695622873f07c046a2a915
@@ -1079,32 +1079,68 @@ public function afterFilter() {
* @return boolean Success
* @link http://book.cakephp.org/view/984/Callbacks
*/
- public function _beforeScaffold($method) {
+ public function beforeScaffold($method) {
return true;
}
+/**
+ * Alias to beforeScaffold()
+ *
+ * @param string $method
+ * @return boolean
+ * @see Controller::beforeScaffold()
+ * @deprecated
+ */
+ protected function _beforeScaffold($method) {
+ return $this->beforeScaffold($method);
+ }
+
/**
* This method should be overridden in child classes.
*
* @param string $method name of method called either edit or update.
* @return boolean Success
* @link http://book.cakephp.org/view/984/Callbacks
*/
- public function _afterScaffoldSave($method) {
+ public function afterScaffoldSave($method) {
return true;
}
+/**
+ * Alias to afterScaffoldSave()
+ *
+ * @param string $method
+ * @return boolean
+ * @see Controller::afterScaffoldSave()
+ * @deprecated
+ */
+ protected function _afterScaffoldSave($method) {
+ return $this->afterScaffoldSave($method);
+ }
+
/**
* This method should be overridden in child classes.
*
* @param string $method name of method called either edit or update.
* @return boolean Success
* @link http://book.cakephp.org/view/984/Callbacks
*/
- public function _afterScaffoldSaveError($method) {
+ public function afterScaffoldSaveError($method) {
return true;
}
+/**
+ * Alias to afterScaffoldSaveError()
+ *
+ * @param string $method
+ * @return boolean
+ * @see Controller::afterScaffoldSaveError()
+ * @deprecated
+ */
+ protected function _afterScaffoldSaveError($method) {
+ return $this->afterScaffoldSaveError($method);
+ }
+
/**
* This method should be overridden in child classes.
* If not it will render a scaffold error.
@@ -1114,7 +1150,20 @@ public function _afterScaffoldSaveError($method) {
* @return boolean Success
* @link http://book.cakephp.org/view/984/Callbacks
*/
- public function _scaffoldError($method) {
+ public function scaffoldError($method) {
return false;
}
+
+/**
+ * Alias to scaffoldError()
+ *
+ * @param string $method
+ * @return boolean
+ * @see Controller::scaffoldError()
+ * @deprecated
+ */
+ protected function _scaffoldError($method) {
+ return $this->scaffoldError($method);
+ }
+
}
@@ -158,7 +158,7 @@ public function __construct(Controller $controller, CakeRequest $request) {
* @throws NotFoundException
*/
protected function _scaffoldView(CakeRequest $request) {
- if ($this->controller->_beforeScaffold('view')) {
+ if ($this->controller->beforeScaffold('view')) {
if (isset($request->params['pass'][0])) {
$this->ScaffoldModel->id = $request->params['pass'][0];
}
@@ -171,7 +171,7 @@ protected function _scaffoldView(CakeRequest $request) {
Inflector::variable($this->controller->modelClass), $this->request->data
);
$this->controller->render($this->request['action'], $this->layout);
- } elseif ($this->controller->_scaffoldError('view') === false) {
+ } elseif ($this->controller->scaffoldError('view') === false) {
return $this->_scaffoldError();
}
}
@@ -183,13 +183,13 @@ protected function _scaffoldView(CakeRequest $request) {
* @return mixed A rendered view listing rows from Models database table
*/
protected function _scaffoldIndex($params) {
- if ($this->controller->_beforeScaffold('index')) {
+ if ($this->controller->beforeScaffold('index')) {
$this->ScaffoldModel->recursive = 0;
$this->controller->set(
Inflector::variable($this->controller->name), $this->controller->paginate()
);
$this->controller->render($this->request['action'], $this->layout);
- } elseif ($this->controller->_scaffoldError('index') === false) {
+ } elseif ($this->controller->scaffoldError('index') === false) {
return $this->_scaffoldError();
}
}
@@ -224,7 +224,7 @@ protected function _scaffoldSave(CakeRequest $request, $action = 'edit') {
$success = __d('cake', 'saved');
}
- if ($this->controller->_beforeScaffold($action)) {
+ if ($this->controller->beforeScaffold($action)) {
if ($action == 'edit') {
if (isset($request->params['pass'][0])) {
$this->ScaffoldModel->id = $request['pass'][0];
@@ -240,15 +240,15 @@ protected function _scaffoldSave(CakeRequest $request, $action = 'edit') {
}
if ($this->ScaffoldModel->save($request->data)) {
- if ($this->controller->_afterScaffoldSave($action)) {
+ if ($this->controller->afterScaffoldSave($action)) {
$message = __d('cake',
'The %1$s has been %2$s',
Inflector::humanize($this->modelKey),
$success
);
return $this->_sendMessage($message);
} else {
- return $this->controller->_afterScaffoldSaveError($action);
+ return $this->controller->afterScaffoldSaveError($action);
}
} else {
if ($this->_validSession) {
@@ -277,8 +277,8 @@ protected function _scaffoldSave(CakeRequest $request, $action = 'edit') {
}
return $this->_scaffoldForm($formAction);
- } elseif ($this->controller->_scaffoldError($action) === false) {
- return $this->_scaffoldError();
+ } elseif ($this->controller->scaffoldError($action) === false) {
+ return $this->scaffoldError();
}
}
@@ -290,7 +290,7 @@ protected function _scaffoldSave(CakeRequest $request, $action = 'edit') {
* @throws MethodNotAllowedException, NotFoundException
*/
protected function _scaffoldDelete(CakeRequest $request) {
- if ($this->controller->_beforeScaffold('delete')) {
+ if ($this->controller->beforeScaffold('delete')) {
if (!$request->is('post')) {
throw new MethodNotAllowedException();
}
@@ -313,7 +313,7 @@ protected function _scaffoldDelete(CakeRequest $request) {
);
return $this->_sendMessage($message);
}
- } elseif ($this->controller->_scaffoldError('delete') === false) {
+ } elseif ($this->controller->scaffoldError('delete') === false) {
return $this->_scaffoldError();
}
}
@@ -666,10 +666,10 @@ public function testToBeInheritedGuardmethods() {
$request = new CakeRequest('controller_posts/index');
$Controller = new Controller($request, $this->getMock('CakeResponse'));
- $this->assertTrue($Controller->_beforeScaffold(''));
- $this->assertTrue($Controller->_afterScaffoldSave(''));
- $this->assertTrue($Controller->_afterScaffoldSaveError(''));
- $this->assertFalse($Controller->_scaffoldError(''));
+ $this->assertTrue($Controller->beforeScaffold(''));
+ $this->assertTrue($Controller->afterScaffoldSave(''));
+ $this->assertTrue($Controller->afterScaffoldSaveError(''));
+ $this->assertFalse($Controller->scaffoldError(''));
}
/**

0 comments on commit dbb87a0

Please sign in to comment.