Skip to content

Commit

Permalink
Migrate to league/event:^3
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgarlag committed Apr 15, 2024
1 parent 63cf599 commit 7ef178b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/Resources/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
use League\Bundle\OAuth2ServerBundle\Security\Authenticator\OAuth2Authenticator;
use League\Bundle\OAuth2ServerBundle\Security\EventListener\CheckScopeListener;
use League\Bundle\OAuth2ServerBundle\Service\SymfonyLeagueEventListenerProvider;
use League\Event\Emitter;
use League\OAuth2\Server\AuthorizationServer;
use League\OAuth2\Server\EventEmitting\EventEmitter;
use League\OAuth2\Server\Grant\AuthCodeGrant;
use League\OAuth2\Server\Grant\ClientCredentialsGrant;
use League\OAuth2\Server\Grant\ImplicitGrant;
Expand Down Expand Up @@ -128,8 +128,8 @@
])
->alias(SymfonyLeagueEventListenerProvider::class, 'league.oauth2_server.symfony_league_listener_provider')

->set('league.oauth2_server.emitter', Emitter::class)
->call('useListenerProvider', [service('league.oauth2_server.symfony_league_listener_provider')])
->set('league.oauth2_server.emitter', EventEmitter::class)
->call('subscribeListenersFrom', [service('league.oauth2_server.symfony_league_listener_provider')])

->set('league.oauth2_server.authorization_server.grant_configurator', GrantConfigurator::class)
->args([
Expand Down
18 changes: 8 additions & 10 deletions src/Service/SymfonyLeagueEventListenerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace League\Bundle\OAuth2ServerBundle\Service;

use League\Event\EventInterface;
use League\Event\ListenerAcceptorInterface;
use League\Event\ListenerProviderInterface;
use League\Event\ListenerRegistry;
use League\Event\ListenerSubscriber;
use League\OAuth2\Server\RequestEvent;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

final class SymfonyLeagueEventListenerProvider implements ListenerProviderInterface
final class SymfonyLeagueEventListenerProvider implements ListenerSubscriber
{
/**
* @var EventDispatcherInterface
Expand All @@ -21,17 +21,15 @@ public function __construct(EventDispatcherInterface $eventDispatcher)
$this->eventDispatcher = $eventDispatcher;
}

public function provideListeners(ListenerAcceptorInterface $listenerAcceptor)
public function subscribeListeners(ListenerRegistry $acceptor): void
{
$listener = \Closure::fromCallable([$this, 'dispatchLeagueEventWithSymfonyEventDispatcher']);

$listenerAcceptor->addListener('*', $listener);

return $this;
$acceptor->subscribeTo(RequestEvent::class, $listener);
}

private function dispatchLeagueEventWithSymfonyEventDispatcher(EventInterface $event): void
private function dispatchLeagueEventWithSymfonyEventDispatcher(RequestEvent $event): void
{
$this->eventDispatcher->dispatch($event, $event->getName());
$this->eventDispatcher->dispatch($event, $event->eventName());
}
}

0 comments on commit 7ef178b

Please sign in to comment.