Skip to content

Commit

Permalink
on cake acl delete <> delete all matching records. Makes more sense…
Browse files Browse the repository at this point in the history
… than deleting one of possibly many.
  • Loading branch information
sgpinkus committed Mar 29, 2014
1 parent 77db212 commit a3fe7cd
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/Cake/Console/Command/AclShell.php
Expand Up @@ -143,20 +143,27 @@ public function create() {
}

/**
* Delete an ARO/ACO node.
* Delete an ARO/ACO node. Note there may be (as a result of poor configuration)
* multiple records with the same logical identifier. All are deleted.
*
* @return void
*/
public function delete() {
extract($this->_dataVars());

$identifier = $this->parseIdentifier($this->args[1]);
$nodeId = $this->_getNodeId($class, $identifier);
if(is_string($identifier)) {
$identifier = ['alias' => $identifier];
}

if (!$this->Acl->{$class}->delete($nodeId)) {
$this->error(__d('cake_console', 'Node Not Deleted') . __d('cake_console', 'There was an error deleting the %s. Check that the node exists.', $class) . "\n");
if($this->Acl->{$class}->find('all')) {
if (!$this->Acl->{$class}->deleteAll($identifier)) {
$this->error(__d('cake_console', 'Node Not Deleted. ') . __d('cake_console', 'There was an error deleting the %s.', $class) . "\n");
}
$this->out(__d('cake_console', '<success>%s deleted.</success>', $class), 2);
} else {
$this->error(__d('cake_console', 'Node Not Deleted. ') . __d('cake_console', 'There was an error deleting the %s. Node does not exist.', $class) . "\n");
}
$this->out(__d('cake_console', '<success>%s deleted.</success>', $class), 2);
}

/**
Expand Down

0 comments on commit a3fe7cd

Please sign in to comment.