File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -40,24 +40,25 @@ namespace AppBundle\EventSubscriber;
40
40
use ApiPlatform\Core\EventListener\EventPriorities;
41
41
use AppBundle\Entity\User;
42
42
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
43
- use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent ;
43
+ use Symfony\Component\HttpKernel\Event\GetResponseEvent ;
44
44
use Symfony\Component\HttpKernel\KernelEvents;
45
45
46
46
final class UserResourcesSubscriber implements EventSubscriberInterface
47
47
{
48
48
public static function getSubscribedEvents()
49
49
{
50
50
return [
51
- KernelEvents::VIEW => ['extendResources', EventPriorities::PRE_READ],
51
+ KernelEvents::REQUEST => ['extendResources', EventPriorities::PRE_READ],
52
+ KernelEvents::REQUEST => ['extendResources', EventPriorities::POST_READ]
52
53
];
53
54
}
54
55
55
- public function extendResources(GetResponseForControllerResultEvent $event)
56
+ public function extendResources(GetResponseEvent $event)
56
57
{
57
- $user = $event->getControllerResult( );
58
+ $class = $event->getRequest()->attributes->get('_api_resource_class' );
58
59
$request = $event->getRequest();
59
60
60
- if ($user instanceof User) {
61
+ if ($class === User::class ) {
61
62
$resources = [
62
63
'/me'
63
64
];
You can’t perform that action at this time.
0 commit comments