How to access database from Authorizator?

8 months ago

+
0
-

When using roles/entitlements/resources from a database, how best to access the database?

If I use try to access via the constructor, I get an error

<?php
public function __construct(\Nette\Database\Context $context)
{
    // ......
}
?>

ArgumentCountError
Too few arguments to function App\Model\DrpAuthorization::__construct(), 0 passed

Because no context is passed when instantiated?
Or is there another preferred method of accessing the database?

Last edited by kevin.waterson@gmail.com (2019-12-09 10:16)

8 months ago

Šaman
Member | 2438
+
+1
-

The problem is elsewhere. Probably where you create instance in config or factory.

8 months ago

MajklNajt
Member | 358
+
+2
-

how you get an intance of App\Model\DrpAuthorization?

is registred as service in config.neon?

services:
	- App\Model\DrpAuthorization

then it will work with autowiring… otherwise you must pass arguments to contructor manualy

8 months ago

+
0
-

MajklNajt wrote:

how you get an intance of App\Model\DrpAuthorization?

is registred as service in config.neon?

services:
	- App\Model\DrpAuthorization

then it will work with autowiring… otherwise you must pass arguments to contructor manualy

yes, but it was also being called in the startup() function.
Thanks for the pointer.