mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
commit
2311c13f12
2 changed files with 45 additions and 1 deletions
|
@ -572,13 +572,18 @@ class AuthComponent extends Component {
|
||||||
* @return void
|
* @return void
|
||||||
* @see BaseAuthorize::mapActions()
|
* @see BaseAuthorize::mapActions()
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#mapping-actions-when-using-crudauthorize
|
* @link http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#mapping-actions-when-using-crudauthorize
|
||||||
|
* @deprecated 3.0.0 Map actions using `actionMap` config key on authorize objects instead
|
||||||
*/
|
*/
|
||||||
public function mapActions($map = array()) {
|
public function mapActions($map = array()) {
|
||||||
if (empty($this->_authorizeObjects)) {
|
if (empty($this->_authorizeObjects)) {
|
||||||
$this->constructAuthorize();
|
$this->constructAuthorize();
|
||||||
}
|
}
|
||||||
|
$mappedActions = array();
|
||||||
foreach ($this->_authorizeObjects as $auth) {
|
foreach ($this->_authorizeObjects as $auth) {
|
||||||
$auth->mapActions($map);
|
$mappedActions = Hash::merge($mappedActions, $auth->mapActions($map));
|
||||||
|
}
|
||||||
|
if (empty($map)) {
|
||||||
|
return $mappedActions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1305,6 +1305,45 @@ class AuthComponentTest extends CakeTestCase {
|
||||||
$this->Auth->logout();
|
$this->Auth->logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test mapActions as a getter
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testMapActions() {
|
||||||
|
$MapActionMockAuthorize = $this->getMock(
|
||||||
|
'BaseAuthorize',
|
||||||
|
array('authorize'),
|
||||||
|
array(),
|
||||||
|
'',
|
||||||
|
false
|
||||||
|
);
|
||||||
|
$this->Auth->authorize = array('MapActionAuthorize');
|
||||||
|
$this->Auth->setAuthorizeObject(0, $MapActionMockAuthorize);
|
||||||
|
|
||||||
|
$actions = array('my_action' => 'create');
|
||||||
|
$this->Auth->mapActions($actions);
|
||||||
|
$actions = array(
|
||||||
|
'create' => array('my_other_action'),
|
||||||
|
'update' => array('updater')
|
||||||
|
);
|
||||||
|
$this->Auth->mapActions($actions);
|
||||||
|
|
||||||
|
$actions = $this->Auth->mapActions();
|
||||||
|
|
||||||
|
$result = $actions['my_action'];
|
||||||
|
$expected = 'create';
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
|
$result = $actions['my_other_action'];
|
||||||
|
$expected = 'create';
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
|
$result = $actions['updater'];
|
||||||
|
$expected = 'update';
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test mapActions loading and delegating to authorize objects.
|
* test mapActions loading and delegating to authorize objects.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue