How to access database from Authorizator?

+
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)

Šaman
Member | 2632
+
+1
-

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

MajklNajt
Member | 470
+
+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

+
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.

Honza Kuchař
Member | 1662
+
0
-

Stacktrace is your friend. ;-)