-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from jcroll/development
[RFC] HWI Oauth Bundle Support
- Loading branch information
Showing
8 changed files
with
3,548 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
language: php | ||
php: | ||
- 5.3 | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
- 7.0 | ||
- hhvm | ||
|
||
matrix: | ||
include: | ||
- php: 5.3 | ||
env: COMPOSER_FLAGS="--prefer-lowest" | ||
|
||
before_script: composer install --dev | ||
before_script: | ||
- composer self-update | ||
- composer update --prefer-dist --no-interaction $COMPOSER_FLAGS | ||
|
||
script: | ||
- ./vendor/bin/phpunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Jcroll\FoursquareApiBundle\EventListener; | ||
|
||
use HWI\Bundle\OAuthBundle\Security\Core\Authentication\Token\OAuthToken; | ||
use Jcroll\FoursquareApiClient\Client\FoursquareClient; | ||
use Symfony\Component\HttpKernel\Event\GetResponseEvent; | ||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; | ||
|
||
class OauthListener | ||
{ | ||
/** @var TokenStorageInterface */ | ||
private $tokenStorage; | ||
|
||
/** @var FoursquareClient */ | ||
private $client; | ||
|
||
/** | ||
* @param TokenStorageInterface $tokenStorage | ||
* @param FoursquareClient $client | ||
*/ | ||
public function __construct(TokenStorageInterface $tokenStorage, FoursquareClient $client) | ||
{ | ||
$this->tokenStorage = $tokenStorage; | ||
$this->client = $client; | ||
} | ||
|
||
/** | ||
* @param GetResponseEvent $event | ||
*/ | ||
public function onKernelRequest(GetResponseEvent $event) | ||
{ | ||
$token = $this->tokenStorage->getToken(); | ||
|
||
if (!$token instanceof OAuthToken) { | ||
return; | ||
} | ||
|
||
if ('foursquare' !== $token->getResourceOwnerName()) { | ||
return; | ||
} | ||
|
||
$this->client->addToken($token->getAccessToken()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
|
||
<services> | ||
|
||
<service id="jcroll_foursquare_api.oauth_listener" class="Jcroll\FoursquareApiBundle\EventListener\OauthListener"> | ||
<argument type="service" id="security.token_storage" /> | ||
<argument type="service" id="jcroll_foursquare_api.foursquare_client" /> | ||
<tag name="kernel.event_listener" event="kernel.request" method="onKernelRequest" /> | ||
</service> | ||
|
||
</services> | ||
</container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.