File tree Expand file tree Collapse file tree 3 files changed +6
-5
lines changed
tests/Fixtures/Controllers Expand file tree Collapse file tree 3 files changed +6
-5
lines changed Original file line number Diff line number Diff line change 77use Attribute ;
88use UnitEnum ;
99
10- #[Attribute(Attribute::TARGET_METHOD )]
10+ #[Attribute(Attribute::TARGET_CLASS | Attribute:: TARGET_METHOD )]
1111final readonly class Allow
1212{
1313 public function __construct (
Original file line number Diff line number Diff line change @@ -24,10 +24,11 @@ public function __construct(
2424
2525 public function __invoke (Request $ request , HttpMiddlewareCallable $ next ): Response
2626 {
27- $ attribute = $ this ->matchedRoute
27+ $ handler = $ this ->matchedRoute
2828 ->route
29- ->handler
30- ->getAttribute (Allow::class);
29+ ->handler ;
30+
31+ $ attribute = $ handler ->getAttribute (Allow::class) ?? $ handler ->getDeclaringClass ()->getAttribute (Allow::class);
3132
3233 if ($ attribute === null ) {
3334 return $ next ($ request );
Original file line number Diff line number Diff line change 1111use Tests \Tempest \Integration \Auth \Fixtures \CustomAuthorizer ;
1212use Tests \Tempest \Integration \Auth \Fixtures \UserPermissionUnitEnum ;
1313
14+ #[Allow(UserPermissionUnitEnum::ADMIN )]
1415final readonly class AdminController
1516{
16- #[Allow(UserPermissionUnitEnum::ADMIN )]
1717 #[Get('/admin ' )]
1818 public function admin (): Response
1919 {
You can’t perform that action at this time.
0 commit comments