Skip to content

Commit

Permalink
feat: Inject dependencies of UserProvider and UserAccessChecker (#19)
Browse files Browse the repository at this point in the history
Closes #18

They can have Service dependencies
  • Loading branch information
Gashmob authored Jun 7, 2024
2 parents dcc23a4 + 6e1579c commit f0dc143
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 159 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ interface UserProvider
}
```

The class you pass in the config must implement this interface.
The class you pass in the config must implement this interface. It can have dependencies like a Service, they will be
injected during instantiation.

`User` is an interface also provided by this Brick:

Expand Down Expand Up @@ -97,7 +98,8 @@ interface UserAccessChecker
```

This method returns `true` if user is authorized to see resource. It can throw an exception the same way as defined
in [`Archict\router`](https://github.com/Archict/router).
in [`Archict\router`](https://github.com/Archict/router). Implementation of this interface can have some dependencies in
its constructor, they will be injected during instantiation.

Then you can provide the class name to your rule with the tag `checker`:

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"phpunit/phpunit": "^10",
"squizlabs/php_codesniffer": "^3.9",
"slevomat/coding-standard": "^8.15",
"archict/core": "^0",
"archict/core": "^0.3",
"guzzlehttp/psr7": "^2.6"
},
"scripts": {
Expand Down
Loading

0 comments on commit f0dc143

Please sign in to comment.