I am trying to create ACO's manually in CakePHP and am not having success thus far.
My AppController.php has the folling code for initialization -
public $components = array(
'Acl',
'Session',
'Auth' => array(
'loginRedirect' => array(
'controller' => 'jobs',
'action' => 'search'
),
'logoutRedirect' => array(
'controller' => 'users',
'action' => 'login',
'home'
),
'authenticate' => array(
'Form' => array(
'passwordHasher' => 'Blowfish'
)
),
'authorize' => array(
'Actions' => array('actionPath' => 'controllers')
)
),
'DebugKit.Toolbar'
);
My UsersController has an install
method that looks like this
public function install() {
$this->Acl->Aco->create(array('parent_id' => null, 'alias' => 'controllers'));
$this->Acl->Aco->save();
}
When I call the install method - the system throws an error saying trying to invoke method create on a non-object
- but i thought this is exactly what the CakePHP documentation asks us to do - what am I missing?
Update: I hacked through the previous problem and basically went straight to my Model and created a method there to create ACOs - basically in my Group Model I put the following code and then invoked it via a controller action. This helped create the ACOs
public function install() {
$aco = new Aco();
$aco->create(array('parent_id' => NULL, 'alias' => 'controllers'));
$aco->create(array('parent_id' => 1, 'alias' => 'users'));
$aco->create(array('parent_id' => 1, 'alias' => 'jobs'));
$aco->save();
}
However now I have the next problem of creating associations between ACOs and AROs - I tried downloading the AclExtras utility as well and that also gives an error while trying to run from the shell - the error I get is below
Fatal error: Call to a member function node() on a non-object in /Applications/XAMPP/xamppfiles/htdocs/cakephp/app/Plugin/AclExtras/Lib/AclExtras.php on line 217 Fatal Error Error: Call to a member function node() on a non-object in [/Applications/XAMPP/xamppfiles/htdocs/cakephp/app/Plugin/AclExtras/Lib/AclExtras.php, line 217]
Fundamentally, for some reason it is unable to get the Aco or Acl object - can anyoen help?
debug($this->Acl);
show ? TheAclComponent
or anything else ? – nIcO