We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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.



4.8k
Accepted
answer
edited Nov '17

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')
        ]);