Browse Source

Fix most coding standard issues in Controller.

mark_story 14 years ago
parent
commit
61aba0f0f8

+ 1 - 0
lib/Cake/Controller/CakeErrorController.php

@@ -75,4 +75,5 @@ class CakeErrorController extends AppController {
 			}
 		}
 	}
+
 }

+ 10 - 5
lib/Cake/Controller/Component.php

@@ -106,7 +106,8 @@ class Component extends Object {
  * @return void
  * @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::initialize
  */
-	public function initialize(Controller $controller) { }
+	public function initialize(Controller $controller) {
+	}
 
 /**
  * Called after the Controller::beforeFilter() and before the controller action
@@ -115,7 +116,8 @@ class Component extends Object {
  * @return void
  * @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::startup
  */
-	public function startup(Controller $controller) { }
+	public function startup(Controller $controller) {
+	}
 
 /**
  * Called after the Controller::beforeRender(), after the view class is loaded, and before the
@@ -125,7 +127,8 @@ class Component extends Object {
  * @return void
  * @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::beforeRender
  */
-	public function beforeRender(Controller $controller) { }
+	public function beforeRender(Controller $controller) {
+	}
 
 /**
  * Called after Controller::render() and before the output is printed to the browser.
@@ -134,7 +137,8 @@ class Component extends Object {
  * @return void
  * @link @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::shutdown
  */
-	public function shutdown(Controller $controller) { }
+	public function shutdown(Controller $controller) {
+	}
 
 /**
  * Called before Controller::redirect().  Allows you to replace the url that will
@@ -155,6 +159,7 @@ class Component extends Object {
  * @return array|null Either an array or null.
  * @link @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::beforeRedirect
  */
-	public function beforeRedirect(Controller $controller, $url, $status = null, $exit = true) {}
+	public function beforeRedirect(Controller $controller, $url, $status = null, $exit = true) {
+	}
 
 }

+ 1 - 0
lib/Cake/Controller/Component/Acl/AclInterface.php

@@ -66,4 +66,5 @@ interface AclInterface {
  * @param AclComponent $component
  */
 	public function initialize(Component $component);
+
 }

+ 2 - 2
lib/Cake/Controller/Component/Acl/DbAcl.php

@@ -94,7 +94,7 @@ class DbAcl extends Object implements AclInterface {
 		$acoIDs = Set::extract($acoPath, '{n}.' . $this->Aco->alias . '.id');
 
 		$count = count($aroPath);
-		for ($i = 0 ; $i < $count; $i++) {
+		for ($i = 0; $i < $count; $i++) {
 			$permAlias = $this->Aro->Permission->alias;
 
 			$perms = $this->Aro->Permission->find('all', array(
@@ -289,5 +289,5 @@ class DbAcl extends Object implements AclInterface {
 		}
 		return $newKeys;
 	}
-}
 
+}

+ 5 - 7
lib/Cake/Controller/Component/Acl/IniAcl.php

@@ -45,7 +45,6 @@ class IniAcl extends Object implements AclInterface {
  * @return void
  */
 	public function initialize(Component $component) {
-
 	}
 
 /**
@@ -57,7 +56,6 @@ class IniAcl extends Object implements AclInterface {
  * @return boolean Success
  */
 	public function allow($aro, $aco, $action = "*") {
-
 	}
 
 /**
@@ -69,7 +67,6 @@ class IniAcl extends Object implements AclInterface {
  * @return boolean Success
  */
 	public function deny($aro, $aco, $action = "*") {
-
 	}
 
 /**
@@ -81,7 +78,6 @@ class IniAcl extends Object implements AclInterface {
  * @return boolean Success
  */
 	public function inherit($aro, $aco, $action = "*") {
-
 	}
 
 /**
@@ -91,10 +87,10 @@ class IniAcl extends Object implements AclInterface {
  *
  * @param string $aro ARO
  * @param string $aco ACO
- * @param string $aco_action Action
+ * @param string $action Action
  * @return boolean Success
  */
-	public function check($aro, $aco, $aco_action = null) {
+	public function check($aro, $aco, $action = null) {
 		if ($this->config == null) {
 			$this->config = $this->readConfigFile(APP . 'Config' . DS . 'acl.ini.php');
 		}
@@ -147,7 +143,8 @@ class IniAcl extends Object implements AclInterface {
 	}
 
 /**
- * Parses an INI file and returns an array that reflects the INI file's section structure. Double-quote friendly.
+ * Parses an INI file and returns an array that reflects the 
+ * INI file's section structure. Double-quote friendly.
  *
  * @param string $filename File
  * @return array INI section structure
@@ -171,4 +168,5 @@ class IniAcl extends Object implements AclInterface {
 		array_unshift($array, "");
 		return $array;
 	}
+
 }

+ 46 - 47
lib/Cake/Controller/Component/Acl/PhpAcl.php

@@ -37,7 +37,6 @@ class PhpAcl extends Object implements AclInterface {
  */
 	public $options = array();
 
-
 /**
  * Aro Object
  *
@@ -52,13 +51,18 @@ class PhpAcl extends Object implements AclInterface {
  */
 	public $Aco = null;
 
-
+/**
+ * Constructor
+ *
+ * Sets a few default settings up.
+ */
 	public function __construct() {
 		$this->options = array(
 			'policy' => self::DENY,
 			'config' => APP . 'Config' . DS . 'acl.php',
 		);
 	}
+
 /**
  * Initialize method
  * 
@@ -69,7 +73,7 @@ class PhpAcl extends Object implements AclInterface {
 		if (!empty($Component->settings['adapter'])) {
 			$this->options = array_merge($this->options, $Component->settings['adapter']);
 		}
-		
+
 		App::uses('PhpReader', 'Configure');
 		$Reader = new PhpReader(dirname($this->options['config']) . DS);
 		$config = $Reader->read(basename($this->options['config']));
@@ -83,6 +87,7 @@ class PhpAcl extends Object implements AclInterface {
  *
  * @param array $config configuration array, see docs
  * @return void
+ * @throws AclException When required keys are missing.
  */
 	public function build(array $config) {
 		if (empty($config['roles'])) {
@@ -145,19 +150,19 @@ class PhpAcl extends Object implements AclInterface {
  *
  * @param string $aro ARO
  * @param string $aco ACO
- * @param string $aco_action Action
+ * @param string $action Action
  * @return boolean true if access is granted, false otherwise
  */
-	public function check($aro, $aco, $aco_action = "*") {
+	public function check($aro, $aco, $action = "*") {
 		$allow = $this->options['policy'];
 		$prioritizedAros = $this->Aro->roles($aro);
 
-		if ($aco_action && $aco_action != "*") {
-			$aco .= '/' . $aco_action;
+		if ($action && $action != "*") {
+			$aco .= '/' . $action;
 		}
 
-		$path = $this->Aco->path($aco);	
-		
+		$path = $this->Aco->path($aco);
+
 		if (empty($path)) {
 			return $allow;
 		}
@@ -176,6 +181,7 @@ class PhpAcl extends Object implements AclInterface {
 
 		return $allow;
 	}
+
 }
 
 /**
@@ -189,7 +195,7 @@ class PhpAco {
  *
  * @var array
  */
-	protected $tree = array();
+	protected $_tree = array();
 
 /**
  * map modifiers for ACO paths to their respective PCRE pattern
@@ -219,9 +225,9 @@ class PhpAco {
 		$aco = $this->resolve($aco);
 		$path = array();
 		$level = 0;
-		$root = $this->tree;	
+		$root = $this->_tree;
 		$stack = array(array($root, 0));
-		
+
 		while (!empty($stack)) {
 			list($root, $level) = array_pop($stack);
 
@@ -230,8 +236,8 @@ class PhpAco {
 			}
 
 			foreach ($root as $node => $elements) {
-				$pattern = '/^'.str_replace(array_keys(self::$modifiers), array_values(self::$modifiers), $node).'$/';
-				
+				$pattern = '/^' . str_replace(array_keys(self::$modifiers), array_values(self::$modifiers), $node) . '$/';
+
 				if ($node == $aco[$level] || preg_match($pattern, $aco[$level])) {
 					// merge allow/denies with $path of current level
 					foreach (array('allow', 'deny') as $policy) {
@@ -239,7 +245,6 @@ class PhpAco {
 							if (empty($path[$level][$policy])) {
 								$path[$level][$policy] = array();
 							}
-
 							$path[$level][$policy] = array_merge($path[$level][$policy], $elements[$policy]);
 						}
 					}
@@ -248,14 +253,13 @@ class PhpAco {
 					if (!empty($elements['children']) && isset($aco[$level + 1])) {
 						array_push($stack, array($elements['children'], $level + 1));
 					}
-				}	
+				}
 			}
 		}
 
 		return $path;
 	}
 
-
 /**
  * allow/deny ARO access to ARO
  *
@@ -264,7 +268,7 @@ class PhpAco {
 	public function access($aro, $aco, $action, $type = 'deny') {
 		$aco = $this->resolve($aco);
 		$depth = count($aco);
-		$root = $this->tree;
+		$root = $this->_tree;
 		$tree = &$root;
 
 		foreach ($aco as $i => $node) {
@@ -280,12 +284,12 @@ class PhpAco {
 				if (empty($tree[$node][$type])) {
 					$tree[$node][$type] = array();
 				}
-				
+
 				$tree[$node][$type] = array_merge(is_array($aro) ? $aro : array($aro), $tree[$node][$type]);
 			}
 		}
 
-		$this->tree = &$root;
+		$this->_tree = &$root;
 	}
 
 /**
@@ -315,7 +319,7 @@ class PhpAco {
  */
 	public function build(array $allow, array $deny = array()) {
 		$stack = array();
-		$this->tree = array();
+		$this->_tree = array();
 		$tree = array();
 		$root = &$tree;
 
@@ -326,7 +330,7 @@ class PhpAco {
 
 			$this->access($aros, $dotPath, null, 'allow');
 		}
-	
+
 		foreach ($deny as $dotPath => $aros) {
 			if (is_string($aros)) {
 				$aros = array_map('trim', explode(',', $aros));
@@ -336,7 +340,6 @@ class PhpAco {
 		}
 	}
 
-
 }
 
 /**
@@ -382,7 +385,7 @@ class PhpAro {
  *
  * @var array
  */
-	protected $tree = array();
+	protected $_tree = array();
 
 	public function __construct(array $aro = array(), array $map = array(), array $aliases = array()) {
 		if (!empty($map)) {
@@ -393,7 +396,6 @@ class PhpAro {
 		$this->build($aro);
 	}
 
-
 /**
  * From the perspective of the given ARO, walk down the tree and
  * collect all inherited AROs levelwise such that AROs from different
@@ -413,7 +415,7 @@ class PhpAro {
 			list($element, $depth) = array_pop($stack);
 			$aros[$depth][] = $element;
 
-			foreach ($this->tree as $node => $children) {
+			foreach ($this->_tree as $node => $children) {
 				if (in_array($element, $children)) {
 					array_push($stack, array($node, $depth + 1));
 				}
@@ -423,7 +425,6 @@ class PhpAro {
 		return array_reverse($aros);
 	}
 
-
 /**
  * resolve an ARO identifier to an internal ARO string using
  * the internal mapping information. 
@@ -438,7 +439,7 @@ class PhpAro {
 
 			if (is_array($aro)) {
 				if (isset($aro['model']) && isset($aro['foreign_key']) && $aro['model'] == $aroGroup) {
-					$mapped = $aroGroup .  '/' . $aro['foreign_key'];
+					$mapped = $aroGroup . '/' . $aro['foreign_key'];
 				} elseif (isset($aro[$model][$field])) {
 					$mapped = $aroGroup . '/' . $aro[$model][$field];
 				} elseif (isset($aro[$field])) {
@@ -450,7 +451,7 @@ class PhpAro {
 				if (strpos($aro, '/') === false) {
 					$mapped = $aroGroup . '/' . $aro;
 				} else {
-					list($aroModel, $aroValue) =  explode('/', $aro, 2);
+					list($aroModel, $aroValue) = explode('/', $aro, 2);
 
 					$aroModel = Inflector::camelize($aroModel);
 
@@ -459,22 +460,19 @@ class PhpAro {
 					}
 				}
 			}
-			
-			if (isset($this->tree[$mapped])) {
+
+			if (isset($this->_tree[$mapped])) {
 				return $mapped;
 			}
-			
+
 			// is there a matching alias defined (e.g. Role/1 => Role/admin)?
 			if (!empty($this->aliases[$mapped])) {
 				return $this->aliases[$mapped];
 			}
-
 		}
-
 		return self::DEFAULT_ROLE;
 	}
 
-
 /**
  * adds a new ARO to the tree
  *
@@ -483,19 +481,19 @@ class PhpAro {
  */
 	public function addRole(array $aro) {
 		foreach ($aro as $role => $inheritedRoles) {
-			if (!isset($this->tree[$role])) {
-				$this->tree[$role] = array();
+			if (!isset($this->_tree[$role])) {
+				$this->_tree[$role] = array();
 			}
 
 			if (!empty($inheritedRoles)) {
 				if (is_string($inheritedRoles)) {
 					$inheritedRoles = array_map('trim', explode(',', $inheritedRoles));
-				} 
-				
+				}
+
 				foreach ($inheritedRoles as $dependency) {
 					// detect cycles
 					$roles = $this->roles($dependency);
-				
+
 					if (in_array($role, Set::flatten($roles))) {
 						$path = '';
 
@@ -503,15 +501,15 @@ class PhpAro {
 							$path .= implode('|', (array)$roleDependencies) . ' -> ';
 						}
 
-						trigger_error(__d('cake_dev', 'cycle detected when inheriting %s from %s. Path: %s', $role, $dependency, $path.$role));
+						trigger_error(__d('cake_dev', 'cycle detected when inheriting %s from %s. Path: %s', $role, $dependency, $path . $role));
 						continue;
 					}
-					
-					if (!isset($this->tree[$dependency])) {
-						$this->tree[$dependency] = array();
+
+					if (!isset($this->_tree[$dependency])) {
+						$this->_tree[$dependency] = array();
 					}
-					
-					$this->tree[$dependency][] = $role;
+
+					$this->_tree[$dependency][] = $role;
 				}
 			}
 		}
@@ -534,7 +532,8 @@ class PhpAro {
  * @return void 
  */
 	public function build(array $aros) {
-		$this->tree = array();
+		$this->_tree = array();
 		$this->addRole($aros);
 	}
+
 }

+ 1 - 2
lib/Cake/Controller/Component/AclComponent.php

@@ -177,6 +177,5 @@ class AclComponent extends Component {
 		trigger_error(__d('cake_dev', 'AclComponent::revoke() is deprecated, use deny() instead'), E_USER_WARNING);
 		return $this->_Instance->deny($aro, $aco, $action);
 	}
-}
-
 
+}

+ 1 - 0
lib/Cake/Controller/Component/Auth/ActionsAuthorize.php

@@ -38,4 +38,5 @@ class ActionsAuthorize extends BaseAuthorize {
 		$user = array($this->settings['userModel'] => $user);
 		return $Acl->check($user, $this->action($request));
 	}
+
 }

+ 3 - 1
lib/Cake/Controller/Component/Auth/BaseAuthenticate.php

@@ -121,7 +121,8 @@ abstract class BaseAuthenticate {
  * @param array $user The user about to be logged out.
  * @return void
  */
-	public function logout($user) { }
+	public function logout($user) {
+	}
 
 /**
  * Get a user based on information in the request.  Primarily used by stateless authentication
@@ -133,4 +134,5 @@ abstract class BaseAuthenticate {
 	public function getUser($request) {
 		return false;
 	}
+
 }

+ 2 - 0
lib/Cake/Controller/Component/Auth/BaseAuthorize.php

@@ -21,6 +21,7 @@
  * @see AuthComponent::$authenticate
  */
 abstract class BaseAuthorize {
+
 /**
  * Controller for the request.
  *
@@ -156,4 +157,5 @@ abstract class BaseAuthorize {
 			}
 		}
 	}
+
 }

+ 3 - 1
lib/Cake/Controller/Component/Auth/BasicAuthenticate.php

@@ -41,6 +41,7 @@ App::uses('BaseAuthenticate', 'Controller/Component/Auth');
  * @since 2.0
  */
 class BasicAuthenticate extends BaseAuthenticate {
+
 /**
  * Settings for this object.
  *
@@ -121,4 +122,5 @@ class BasicAuthenticate extends BaseAuthenticate {
 	public function loginHeaders() {
 		return sprintf('WWW-Authenticate: Basic realm="%s"', $this->settings['realm']);
 	}
-}
+
+}

+ 2 - 2
lib/Cake/Controller/Component/Auth/ControllerAuthorize.php

@@ -61,7 +61,7 @@ class ControllerAuthorize extends BaseAuthorize {
  * @return boolean
  */
 	public function authorize($user, CakeRequest $request) {
-		return (bool) $this->_Controller->isAuthorized($user);
+		return (bool)$this->_Controller->isAuthorized($user);
 	}
 
-}
+}

+ 1 - 0
lib/Cake/Controller/Component/Auth/CrudAuthorize.php

@@ -98,4 +98,5 @@ class CrudAuthorize extends BaseAuthorize {
 			$this->settings['actionMap'][$request->params['action']]
 		);
 	}
+
 }

+ 5 - 2
lib/Cake/Controller/Component/Auth/DigestAuthenticate.php

@@ -55,6 +55,7 @@ App::uses('BaseAuthenticate', 'Controller/Component/Auth');
  * @since 2.0
  */
 class DigestAuthenticate extends BaseAuthenticate {
+
 /**
  * Settings for this object.
  *
@@ -65,7 +66,8 @@ class DigestAuthenticate extends BaseAuthenticate {
  * - `realm` The realm authentication is for, Defaults to the servername.
  * - `nonce` A nonce used for authentication.  Defaults to `uniqid()`.
  * - `qop` Defaults to auth, no other values are supported at this time.
- * - `opaque` A string that must be returned unchanged by clients. Defaults to `md5($settings['realm'])`
+ * - `opaque` A string that must be returned unchanged by clients. 
+ *    Defaults to `md5($settings['realm'])`
  *
  * @var array
  */
@@ -261,4 +263,5 @@ class DigestAuthenticate extends BaseAuthenticate {
 		}
 		return 'WWW-Authenticate: Digest ' . implode(',', $opts);
 	}
-}
+
+}

+ 1 - 0
lib/Cake/Controller/Component/AuthComponent.php

@@ -718,4 +718,5 @@ class AuthComponent extends Component {
 	public function flash($message) {
 		$this->Session->setFlash($message, $this->flash['element'], $this->flash['params'], $this->flash['key']);
 	}
+
 }

+ 2 - 1
lib/Cake/Controller/Component/CookieComponent.php

@@ -431,7 +431,7 @@ class CookieComponent extends Component {
 
 		if ($this->_encrypted === true) {
 			$type = $this->_type;
-			$value = "Q2FrZQ==." .base64_encode(Security::$type($value, $this->key));
+			$value = "Q2FrZQ==." . base64_encode(Security::$type($value, $this->key));
 		}
 		return $value;
 	}
@@ -503,4 +503,5 @@ class CookieComponent extends Component {
 		}
 		return $array;
 	}
+
 }

+ 3 - 2
lib/Cake/Controller/Component/PaginatorComponent.php

@@ -223,7 +223,7 @@ class PaginatorComponent extends Component {
 	protected function _getObject($object) {
 		if (is_string($object)) {
 			$assoc = null;
-			if (strpos($object, '.')  !== false) {
+			if (strpos($object, '.') !== false) {
 				list($object, $assoc) = pluginSplit($object);
 			}
 
@@ -370,11 +370,12 @@ class PaginatorComponent extends Component {
  * @return array An array of options for pagination
  */
 	public function checkLimit($options) {
-		$options['limit'] = (int) $options['limit'];
+		$options['limit'] = (int)$options['limit'];
 		if (empty($options['limit']) || $options['limit'] < 1) {
 			$options['limit'] = 1;
 		}
 		$options['limit'] = min((int)$options['limit'], $options['maxLimit']);
 		return $options;
 	}
+
 }

+ 2 - 2
lib/Cake/Controller/Component/RequestHandlerComponent.php

@@ -210,9 +210,9 @@ class RequestHandlerComponent extends Component {
 				return Xml::toArray($xml->data);
 			}
 			return Xml::toArray($xml);
-		 } catch (XmlException $e) {
+		} catch (XmlException $e) {
 			return array();
-		 }
+		}
 	}
 
 /**

+ 4 - 3
lib/Cake/Controller/Component/SecurityComponent.php

@@ -394,9 +394,9 @@ class SecurityComponent extends Component {
 					$tData = $this->Session->read('_Token');
 
 					if (
-						!empty($tData['allowedControllers']) && 
-						!in_array($this->request->params['controller'], $tData['allowedControllers']) || 
-						!empty($tData['allowedActions']) && 
+						!empty($tData['allowedControllers']) &&
+						!in_array($this->request->params['controller'], $tData['allowedControllers']) ||
+						!empty($tData['allowedActions']) &&
 						!in_array($this->request->params['action'], $tData['allowedActions'])
 					) {
 						if (!$this->blackHole($controller, 'auth')) {
@@ -592,4 +592,5 @@ class SecurityComponent extends Component {
 			return null;
 		}
 	}
+
 }

+ 2 - 1
lib/Cake/Controller/ComponentCollection.php

@@ -124,4 +124,5 @@ class ComponentCollection extends ObjectCollection implements CakeEventListener
 			'Controller.shutdown' => array('callable' => 'trigger'),
 		);
 	}
-}
+
+}

+ 7 - 10
lib/Cake/Controller/Controller.php

@@ -1,9 +1,5 @@
 <?php
 /**
- * Base controller class.
- *
- * PHP 5
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
  *
@@ -145,7 +141,6 @@ class Controller extends Object implements CakeEventListener {
  */
 	public $viewVars = array();
 
-
 /**
  * The name of the view file to render. The name specified
  * is the filename in /app/View/<SubFolder> without the .ctp extension.
@@ -321,7 +316,7 @@ class Controller extends Object implements CakeEventListener {
  */
 	public function __construct($request = null, $response = null) {
 		if ($this->name === null) {
-			$this->name = substr(get_class($this), 0, strlen(get_class($this)) -10);
+			$this->name = substr(get_class($this), 0, strlen(get_class($this)) - 10);
 		}
 
 		if ($this->viewPath == null) {
@@ -476,7 +471,9 @@ class Controller extends Object implements CakeEventListener {
  *
  * @param CakeRequest $request
  * @return mixed The resulting response.
- * @throws PrivateActionException, MissingActionException
+ * @throws PrivateActionException When actions are not public or prefixed by _
+ * @throws MissingActionException When actions are not defined and scaffolding is
+ *    not enabled.
  */
 	public function invokeAction(CakeRequest $request) {
 		try {
@@ -640,7 +637,7 @@ class Controller extends Object implements CakeEventListener {
 		$this->_mergeControllerVars();
 		$this->Components->init($this);
 		if ($this->uses) {
-			$this->uses = (array) $this->uses;
+			$this->uses = (array)$this->uses;
 			list(, $this->modelClass) = pluginSplit(current($this->uses));
 		}
 		return true;
@@ -1062,10 +1059,10 @@ class Controller extends Object implements CakeEventListener {
 				}
 				$fieldOp = strtoupper(trim($fieldOp));
 				if ($fieldOp === 'LIKE') {
-					$key = $key.' LIKE';
+					$key = $key . ' LIKE';
 					$value = '%' . $value . '%';
 				} elseif ($fieldOp && $fieldOp != '=') {
-					$key = $key.' ' . $fieldOp;
+					$key = $key . ' ' . $fieldOp;
 				}
 				$cond[$key] = $value;
 			}

+ 7 - 3
lib/Cake/Controller/Scaffold.php

@@ -125,7 +125,7 @@ class Scaffold {
 		$this->ScaffoldModel = $this->controller->{$this->modelClass};
 		$this->scaffoldTitle = Inflector::humanize(Inflector::underscore($this->viewPath));
 		$this->scaffoldActions = $controller->scaffold;
-		$title_for_layout = __d('cake', 'Scaffold :: ') . Inflector::humanize($request->action) . ' :: ' . $this->scaffoldTitle;
+		$title = __d('cake', 'Scaffold :: ') . Inflector::humanize($request->action) . ' :: ' . $this->scaffoldTitle;
 		$modelClass = $this->controller->modelClass;
 		$primaryKey = $this->ScaffoldModel->primaryKey;
 		$displayField = $this->ScaffoldModel->displayField;
@@ -140,6 +140,7 @@ class Scaffold {
 			'title_for_layout', 'modelClass', 'primaryKey', 'displayField', 'singularVar', 'pluralVar',
 			'singularHumanName', 'pluralHumanName', 'scaffoldFields', 'associations'
 		));
+		$this->set('title_for_layout', $title);
 
 		if ($this->controller->viewClass) {
 			$this->controller->viewClass = 'Scaffold';
@@ -287,7 +288,8 @@ class Scaffold {
  *
  * @param CakeRequest $request Request for scaffolding
  * @return mixed Success on delete, error if delete fails
- * @throws MethodNotAllowedException, NotFoundException
+ * @throws MethodNotAllowedException When HTTP method is not a DELETE
+ * @throws NotFoundException When id being deleted does not exist.
  */
 	protected function _scaffoldDelete(CakeRequest $request) {
 		if ($this->controller->beforeScaffold('delete')) {
@@ -350,7 +352,8 @@ class Scaffold {
  *
  * @param CakeRequest $request Request object for scaffolding
  * @return mixed A rendered view of scaffold action, or showing the error
- * @throws MissingActionException, MissingDatabaseException
+ * @throws MissingActionException When methods are not scaffolded.
+ * @throws MissingDatabaseException When the database connection is undefined.
  */
 	protected function _scaffold(CakeRequest $request) {
 		$db = ConnectionManager::getDataSource($this->ScaffoldModel->useDbConfig);
@@ -440,4 +443,5 @@ class Scaffold {
 		}
 		return $associations;
 	}
+
 }