Refactoring authorization objects to also use settings, it makes them consistent with authenticate objects.

Making actionPath automatically pass into authentication objects.
Adding tests.
This commit is contained in:
mark_story 2011-01-05 00:01:40 -05:00
parent e34fdde918
commit 0c7f9149ca
3 changed files with 48 additions and 20 deletions

View file

@ -91,6 +91,16 @@ class AuthComponent extends Component {
*/
protected $_authorizeObjects = array();
/**
* A hash mapping legacy properties => to settings passed into Authorize objects.
*
* @var string
* @deprecated Will be removed in 2.1+
*/
protected $_authorizeLegacyMap = array(
'actionPath' => 'actionPath',
);
/**
* The name of an optional view element to render when an Ajax request is made
* with an invalid or expired session
@ -499,6 +509,11 @@ class AuthComponent extends Component {
if (!method_exists($className, 'authorize')) {
throw new CakeException(__('Authorization objects must implement an authorize method.'));
}
foreach ($this->_authorizeLegacyMap as $old => $new) {
if (empty($settings[$new]) && !empty($this->{$old})) {
$settings[$new] = $this->{$old};
}
}
$this->_authorizeObjects[] = new $className($this->_Collection->getController(), $settings);
}
return $this->_authorizeObjects;