Skip to content

Commit

Permalink
Revert "Use EventDispatcher from SymfonyContracts"
Browse files Browse the repository at this point in the history
  • Loading branch information
X-Coder264 authored Dec 6, 2019
1 parent 80b9e41 commit 673b4c2
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 96 deletions.
6 changes: 3 additions & 3 deletions Controller/AuthorizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Trikoder\Bundle\OAuth2Bundle\Converter\UserConverterInterface;
use Trikoder\Bundle\OAuth2Bundle\Event\AuthorizationRequestResolveEvent;
use Trikoder\Bundle\OAuth2Bundle\Event\AuthorizationRequestResolveEventFactory;
Expand Down Expand Up @@ -58,8 +58,8 @@ public function indexAction(ServerRequestInterface $serverRequest, ResponseFacto

/** @var AuthorizationRequestResolveEvent $event */
$event = $this->eventDispatcher->dispatch(
$this->eventFactory->fromAuthorizationRequest($authRequest),
OAuth2Events::AUTHORIZATION_REQUEST_RESOLVE
OAuth2Events::AUTHORIZATION_REQUEST_RESOLVE,
$this->eventFactory->fromAuthorizationRequest($authRequest)
);

$authRequest->setUser($this->userConverter->toLeague($event->getUser()));
Expand Down
38 changes: 0 additions & 38 deletions DependencyInjection/CompilerPass/EventDispatcherCompilerPass.php

This file was deleted.

11 changes: 8 additions & 3 deletions League/Repository/ScopeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use League\OAuth2\Server\Entities\ClientEntityInterface;
use League\OAuth2\Server\Exception\OAuthServerException;
use League\OAuth2\Server\Repositories\ScopeRepositoryInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Trikoder\Bundle\OAuth2Bundle\Converter\ScopeConverterInterface;
use Trikoder\Bundle\OAuth2Bundle\Event\ScopeResolveEvent;
use Trikoder\Bundle\OAuth2Bundle\Manager\ClientManagerInterface;
Expand Down Expand Up @@ -79,8 +79,13 @@ public function finalizeScopes(
$scopes = $this->setupScopes($client, $this->scopeConverter->toDomainArray($scopes));

$event = $this->eventDispatcher->dispatch(
new ScopeResolveEvent($scopes, new GrantModel($grantType), $client, $userIdentifier),
OAuth2Events::SCOPE_RESOLVE
OAuth2Events::SCOPE_RESOLVE,
new ScopeResolveEvent(
$scopes,
new GrantModel($grantType),
$client,
$userIdentifier
)
);

return $this->scopeConverter->toLeagueArray($event->getScopes());
Expand Down
11 changes: 8 additions & 3 deletions League/Repository/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use League\OAuth2\Server\Entities\ClientEntityInterface;
use League\OAuth2\Server\Repositories\UserRepositoryInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Trikoder\Bundle\OAuth2Bundle\Converter\UserConverterInterface;
use Trikoder\Bundle\OAuth2Bundle\Event\UserResolveEvent;
use Trikoder\Bundle\OAuth2Bundle\Manager\ClientManagerInterface;
Expand Down Expand Up @@ -52,8 +52,13 @@ public function getUserEntityByUserCredentials(
$client = $this->clientManager->find($clientEntity->getIdentifier());

$event = $this->eventDispatcher->dispatch(
new UserResolveEvent($username, $password, new GrantModel($grantType), $client),
OAuth2Events::USER_RESOLVE
OAuth2Events::USER_RESOLVE,
new UserResolveEvent(
$username,
$password,
new GrantModel($grantType),
$client
)
);

$user = $event->getUser();
Expand Down
6 changes: 3 additions & 3 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
<argument type="service" id="Trikoder\Bundle\OAuth2Bundle\Manager\ScopeManagerInterface" />
<argument type="service" id="Trikoder\Bundle\OAuth2Bundle\Manager\ClientManagerInterface" />
<argument type="service" id="Trikoder\Bundle\OAuth2Bundle\Converter\ScopeConverter" />
<argument type="service" id="Symfony\Contracts\EventDispatcher\EventDispatcherInterface" />
<argument type="service" id="Symfony\Component\EventDispatcher\EventDispatcherInterface" />
</service>
<service id="trikoder.oauth2.league.repository.scope_repository" alias="Trikoder\Bundle\OAuth2Bundle\League\Repository\ScopeRepository" />
<service id="League\OAuth2\Server\Repositories\ScopeRepositoryInterface" alias="Trikoder\Bundle\OAuth2Bundle\League\Repository\ScopeRepository" />

<service id="Trikoder\Bundle\OAuth2Bundle\League\Repository\UserRepository">
<argument type="service" id="Trikoder\Bundle\OAuth2Bundle\Manager\ClientManagerInterface" />
<argument type="service" id="Symfony\Contracts\EventDispatcher\EventDispatcherInterface" />
<argument type="service" id="Symfony\Component\EventDispatcher\EventDispatcherInterface" />
<argument type="service" id="Trikoder\Bundle\OAuth2Bundle\Converter\UserConverter" />
</service>
<service id="trikoder.oauth2.league.repository.user_repository" alias="Trikoder\Bundle\OAuth2Bundle\League\Repository\UserRepository" />
Expand Down Expand Up @@ -115,7 +115,7 @@
<!-- Authorization controller -->
<service id="Trikoder\Bundle\OAuth2Bundle\Controller\AuthorizationController">
<argument type="service" id="League\OAuth2\Server\AuthorizationServer" />
<argument type="service" id="Symfony\Contracts\EventDispatcher\EventDispatcherInterface" />
<argument type="service" id="Symfony\Component\EventDispatcher\EventDispatcherInterface" />
<argument type="service" id="Trikoder\Bundle\OAuth2Bundle\Event\AuthorizationRequestResolveEventFactory" />
<argument type="service" id="Trikoder\Bundle\OAuth2Bundle\Converter\UserConverter" />
<tag name="controller.service_arguments" />
Expand Down
39 changes: 0 additions & 39 deletions Service/BCEventDispatcher.php

This file was deleted.

5 changes: 2 additions & 3 deletions Tests/Integration/AbstractIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Trikoder\Bundle\OAuth2Bundle\Converter\ScopeConverter;
use Trikoder\Bundle\OAuth2Bundle\Converter\UserConverter;
use Trikoder\Bundle\OAuth2Bundle\League\Entity\User;
Expand All @@ -49,7 +49,6 @@
use Trikoder\Bundle\OAuth2Bundle\Manager\ScopeManagerInterface;
use Trikoder\Bundle\OAuth2Bundle\Model\AccessToken;
use Trikoder\Bundle\OAuth2Bundle\Model\RefreshToken;
use Trikoder\Bundle\OAuth2Bundle\Service\BCEventDispatcher;
use Trikoder\Bundle\OAuth2Bundle\Tests\TestHelper;

abstract class AbstractIntegrationTest extends TestCase
Expand Down Expand Up @@ -109,7 +108,7 @@ protected function setUp(): void
$this->accessTokenManager = new AccessTokenManager();
$this->refreshTokenManager = new RefreshTokenManager();
$this->authCodeManager = new AuthorizationCodeManager();
$this->eventDispatcher = new BCEventDispatcher(new EventDispatcher());
$this->eventDispatcher = new EventDispatcher();

$scopeConverter = new ScopeConverter();
$scopeRepository = new ScopeRepository($this->scopeManager, $this->clientManager, $scopeConverter, $this->eventDispatcher);
Expand Down
2 changes: 0 additions & 2 deletions TrikoderOAuth2Bundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Trikoder\Bundle\OAuth2Bundle\DependencyInjection\CompilerPass\EventDispatcherCompilerPass;
use Trikoder\Bundle\OAuth2Bundle\DependencyInjection\Security\OAuth2Factory;
use Trikoder\Bundle\OAuth2Bundle\DependencyInjection\TrikoderOAuth2Extension;

Expand Down Expand Up @@ -42,7 +41,6 @@ private function configureSecurityExtension(ContainerBuilder $container): void

private function configureDoctrineExtension(ContainerBuilder $container): void
{
$container->addCompilerPass(new EventDispatcherCompilerPass());
$container->addCompilerPass(
DoctrineOrmMappingsPass::createXmlMappingDriver(
[
Expand Down
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
"doctrine/doctrine-bundle": "^1.8|^2.0",
"doctrine/orm": "^2.6",
"league/oauth2-server": "^7.2",
"psr/event-dispatcher": "^1.0",
"psr/http-factory": "^1.0",
"sensio/framework-extra-bundle": "^5.3",
"symfony/event-dispatcher-contracts": "^1.1",
"symfony/framework-bundle": "^3.4|^4.2",
"symfony/psr-http-message-bridge": "^1.2",
"symfony/security-bundle": "^3.4|^4.2"
Expand Down

0 comments on commit 673b4c2

Please sign in to comment.