Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Missing docks when using Database adapter with ACL

So, I cannot find any docs how to use the database adabter. I have tried few different approach without any success. So I'm trying to use \Phalcon\ACL\Adapters\Database;

   self::$acl = new AclList(
        (array)self::getAcl()->di->get('config')->database
    );

This last what I did try. However that returns

  Parameter "db" is required and it must be an instance of Phalcon\Acl\AdapterInterface

Turth to be told, I'm stuck. I don't know how to initialize Database adabter for ACL and I cannot find any docs how to do it.



3.5k
Accepted
answer
edited 28d ago

Phalcon\Acl\Adapter\Database is incubator.

You can find a README on how to use it here:
https://github.com/phalcon/incubator/tree/master/Library/Phalcon/Acl/Adapter

The doc there uses use Phalcon\Acl\Adapter\Database as AclDb; so you're using a different alias name, but the same class.

The error you're seeing is right here:
https://github.com/phalcon/incubator/blob/master/Library/Phalcon/Acl/Adapter/Database.php#L89

While your config service probably has a db on it, you're supposed to be tossing in a database service, not the config for connecting to the database.

I beleive you're looking for:

       self::$acl = new AclList([
           'db' => self::getAcl()->di->get('db')
        ]);