I'm implementing the CakePHP ACL. I want my Model to both be a requester and controlled, so I've set it up like this:
public $actsAs = array(
'Acl' => array(
'type' => 'both'
)
);
The problem I'm having, is that my Model has a different parent depending on the type of node (ACO or ARO) it is.
I would like to solve it by doing something like this with the parentNode() function:
public function parentNode() {
if('ARO' == $this->type) {
return 'ARO parent';
} else {
return 'ACO parent';
}
}
So basically let it return the appropriate parent for each of the cases.
Is this possible, and if so, how?
===== UPDATE - 2013-10-04 =====
I've submitted an official ticket which is being looked at :-)
I've been doing some digging in the Cake logic. I think I came up with a very simple and useful solution for this issue.
Using CakePHP 2.4.1, I've edited the file /lib/Cake/Model/Behavior/AclBehavior.php
On line 109 it reads:
$parent = $model->parentNode();
I've simply added the type as argument:
$parent = $model->parentNode($type);
That way, my parentNode() function can look like this:
public function parentNode($sType) {
if('ARO' == $sType) {
return 'ARO parent';
} else {
return 'ACO parent';
}
}
Me happy :-)