0
votes

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?

1
I also tried creating ACOs from the shell and this is the error I get - Fatal error: Call to a member function create() on a non-object in /Applications/XAMPP/xamppfiles/htdocs/cakephp/lib/Cake/Console/Command/AclShell.php on line 137ChicagoSky
What does debug($this->Acl); show ? The AclComponent or anything else ?nIcO
it times out - basically i think the object is too big to display so it gives a feed exceeded kind of error - trying to debug($this->Acl->Aco) gives nothing - exact error i get is rror: Allowed memory size of 134217728 bytes exhausted (tried to allocate 25235053 bytes)ChicagoSky

1 Answers

0
votes

Ok - I finally gave up trying to fix this error and made a fresh installation on another computer. I followed the tutorial outlined at CakePhp.org word for word and got it to work. Now I am going to have to retro-fit all my existing work on top of this.

In short - I dont know what broke or what I should do to fix the original problem but creating a fresh installation and then proceeding helped