ivanamat / cakephp3-aclmanager

CakePHP 3.x - Acl Manager
MIT License
27 stars 27 forks source link

Error: Cake\ORM\Entity::parentNode() #31

Closed boyteenphonui closed 4 years ago

boyteenphonui commented 6 years ago

Error in: ROOT/vendor/ivanamat/cakephp3-aclmanager/src/Template/Acl/permissions.ctp, line 85

screen shot 2018-08-21 at 6 56 28 pm

screen shot 2018-08-21 at 7 06 23 pm

screen shot 2018-08-24 at 12 16 07 pm

I have done all these steps https://github.com/ivanamat/cakephp3-aclmanager#implement-parentnode-function-in-group-entity

Can't call $ parentNode = $ aro-> parentNode ();

boyteenphonui commented 6 years ago

It does not work with the plugin screen shot 2018-08-24 at 1 01 38 pm screen shot 2018-08-24 at 1 02 59 pm

ivanamat commented 4 years ago

Hi @boyteenphonui

It should be:

Configure::write('AclManager.aros', array('Groups', 'Roles', 'Users'));

and not:

Configure::write('AclManager.aros', array('Group.Groups', 'Role.Roles', 'User.Users'));

Best regards Iván Amat

MathRat commented 4 years ago

Same problem here:

i added this in AclController.php

   $this->loadModel('Db.DbUsers');
    $this->loadModel('Db.Laender');
    debug($this->DbUsers);
    debug($this->Laender);
    $user = $this->DbUsers->get(1);
    debug($user->parentNode());

This is the result:

object(Cake\ORM\Table) {

'registryAlias' => 'DbUsers',
'table' => 'db_users',
'alias' => 'DbUsers',
'entityClass' => 'Cake\ORM\Entity',
'associations' => [],
'behaviors' => [],
'defaultConnection' => 'default',
'connectionName' => 'default'

}

object(Db\Model\Table\LaenderTable) {

'registryAlias' => 'Db.Laender',
'table' => 'laender',
'alias' => 'Laender',
'entityClass' => 'Db\Model\Entity\Laender',
'associations' => [
    (int) 0 => 'regionen'
],
'behaviors' => [],
'defaultConnection' => 'default',
'connectionName' => 'default'

}

Both Models are defined in plugin "Db"

My config:

Configure::write('AclManager.aros', array('DbGroups', 'DbRoles', 'DbUsers'));

You see a difference in entityClass. My users table seems not to get used. that's the reason the function parentNode() is not found. Debugging same code in i.e. Db/BenutzerController.php shows both entitiyClass Db\Model\Entity\ ...

ivanamat commented 4 years ago

Hi, @MathRat

Have you tried this?

Configure::write('AclManager.aros', array('dbGroups', 'dbRoles', 'dbUsers'));

Do you have the parentNode() function implemented in your entities? It should be implemented. https://github.com/ivanamat/cakephp3-aclmanager#implement-parentnode-function-in-group-entity

MathRat commented 4 years ago

Hi @ivanamat,

i tried it, same issue. Objecttype is still Cake\ORM\Entity, not Db...

the parentNode() is implemented. In debug code above, it returns group_id. I'm sure, i configured erverything. Is it possible, that your plugin is not working with plugin models?

image

image

ivanamat commented 4 years ago

How are you loading db plugin? PSR-4, in the bootstap.php, extending ApplicationBase?

MathRat commented 4 years ago

Hi,

because of your question i tried multiple combinations. Autoloaded PSR-4, loaded by bootstrap.php or Application.php Because of i don't need auth in application, i implemented auth in Db and extends Db\AppController in AclManager AppController. i tried to implement auth in application and extend ApplicationBase. All of this did not helped. Entity is still missing parentNode() because it's Cake\ORM\Entity not Db\Model\Entity\DbUsers

ivanamat commented 4 years ago

Can you provide me the URL of the Db plugin please? Do you load the AclManager or Db plugin first?