-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
1,613 additions
and
924 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,2 +1,12 @@ | ||
.git/ | ||
.idea/ | ||
# Composer | ||
/composer.lock | ||
/vendor/ | ||
|
||
# cypress & node | ||
cypress.json | ||
/node_modules/ | ||
|
||
# PhpUnit | ||
/.idea | ||
/.phpunit.result.cache | ||
/phpunit.xml |
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,29 @@ | ||
cache: | ||
paths: | ||
- vendor/ | ||
|
||
before_script: | ||
# - cp ci/php.ini /usr/local/etc/php/conf.d/test.ini | ||
- COMPOSER_MEMORY_LIMIT=-1 composer install -n --prefer-dist --no-progress --ignore-platform-reqs | ||
|
||
php:7.4: | ||
# This docker image comes with composer and ant. | ||
image: jorge07/alpine-php:7.4-dev | ||
script: | ||
- vendor/bin/phpunit --configuration phpunit.xml --coverage-text --log-junit report.xml | ||
- vendor/bin/ecs check src tests | ||
artifacts: | ||
when: always | ||
reports: | ||
junit: report.xml | ||
|
||
php:8.0: | ||
# This docker image comes with composer and ant. | ||
image: jorge07/alpine-php:8.0-dev | ||
script: | ||
- vendor/bin/phpunit --configuration phpunit.xml --coverage-text --log-junit report.xml | ||
- vendor/bin/ecs check src tests | ||
artifacts: | ||
when: always | ||
reports: | ||
junit: report.xml |
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
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,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use PhpCsFixer\Fixer\Comment\HeaderCommentFixer; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
use Symplify\EasyCodingStandard\ValueObject\Option; | ||
|
||
$date = date('Y'); | ||
|
||
$GLOBALS['ecsHeader'] = <<<EOF | ||
social feed bundle for Contao Open Source CMS | ||
Copyright (c) $date pdir / digital agentur // pdir GmbH | ||
@package social-feed-bundle | ||
@link https://github.com/pdir/social-feed-bundle | ||
@license http://www.gnu.org/licences/lgpl-3.0.html LGPL | ||
@author Mathias Arzberger <[email protected]> | ||
@author Philipp Seibt <[email protected]> | ||
@author pdir GmbH <https://pdir.de> | ||
For the full copyright and license information, please view the LICENSE | ||
file that was distributed with this source code. | ||
EOF; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$containerConfigurator->import(__DIR__.'/vendor/contao/easy-coding-standard/config/set/contao.php'); | ||
|
||
$parameters = $containerConfigurator->parameters(); | ||
$parameters->set(Option::LINE_ENDING, "\n"); | ||
|
||
$services = $containerConfigurator->services(); | ||
$services | ||
->set(HeaderCommentFixer::class) | ||
->call('configure', [[ | ||
'header' => $GLOBALS['ecsHeader'], | ||
]]) | ||
; | ||
}; |
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,12 +1,21 @@ | ||
<?php | ||
|
||
/** | ||
* Contao Open Source CMS | ||
declare(strict_types=1); | ||
|
||
/* | ||
* social feed bundle for Contao Open Source CMS | ||
* | ||
* Copyright (c) 2021 pdir / digital agentur // pdir GmbH | ||
* | ||
* Copyright (c) 2017 pdir / digital agentur | ||
* @package social-feed-bundle | ||
* @author Mathias Arzberger <[email protected]> | ||
* @license http://www.gnu.org/licences/lgpl-3.0.html LGPL | ||
* @package social-feed-bundle | ||
* @link https://github.com/pdir/social-feed-bundle | ||
* @license http://www.gnu.org/licences/lgpl-3.0.html LGPL | ||
* @author Mathias Arzberger <[email protected]> | ||
* @author Philipp Seibt <[email protected]> | ||
* @author pdir GmbH <https://pdir.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Pdir\SocialFeedBundle\ContaoManager; | ||
|
@@ -22,17 +31,17 @@ | |
|
||
class Plugin implements BundlePluginInterface, RoutingPluginInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getBundles(ParserInterface $parser) | ||
{ | ||
return [ | ||
BundleConfig::create(PdirSocialFeedBundle::class) | ||
->setLoadAfter([ContaoCoreBundle::class]) | ||
->setReplace(['socialfeedbundle']), | ||
]; | ||
} | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getBundles(ParserInterface $parser) | ||
{ | ||
return [ | ||
BundleConfig::create(PdirSocialFeedBundle::class) | ||
->setLoadAfter([ContaoCoreBundle::class]) | ||
->setReplace(['socialfeedbundle']), | ||
]; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
|
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,31 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* Instagram Bundle for Contao Open Source CMS. | ||
* | ||
* Copyright (C) 2011-2019 Codefog | ||
* social feed bundle for Contao Open Source CMS | ||
* | ||
* @author Codefog <https://codefog.pl> | ||
* @author Kamil Kuzminski <https://github.com/qzminski> | ||
* @license MIT | ||
* Copyright (c) 2021 pdir / digital agentur // pdir GmbH | ||
* | ||
* https://github.com/codefog/contao-instagram | ||
* @package social-feed-bundle | ||
* @link https://github.com/pdir/social-feed-bundle | ||
* @license http://www.gnu.org/licences/lgpl-3.0.html LGPL | ||
* @author Mathias Arzberger <[email protected]> | ||
* @author Philipp Seibt <[email protected]> | ||
* @author pdir GmbH <https://pdir.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Pdir\SocialFeedBundle\Controller; | ||
|
||
use Pdir\SocialFeedBundle\EventListener\SocialFeedListener; | ||
use Doctrine\DBAL\Connection; | ||
use Pdir\SocialFeedBundle\EventListener\SocialFeedListener; | ||
use Symfony\Component\HttpFoundation\RedirectResponse; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpFoundation\Session\SessionInterface; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
use Symfony\Component\Routing\RouterInterface; | ||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; | ||
use Facebook\Facebook; | ||
use Contao\CoreBundle\Exception\RedirectResponseException; | ||
|
||
/** | ||
* @Route("/_facebook", defaults={"_scope" = "backend", "_token_check" = false}) | ||
|
@@ -68,7 +70,7 @@ public function authAction(Request $request): Response | |
'client_id' => $sessionData['clientId'], | ||
'client_secret' => $sessionData['clientSecret'], | ||
'redirect_uri' => $this->router->generate('facebook_auth', [], RouterInterface::ABSOLUTE_URL), | ||
'code' => $request->query->get('code') | ||
'code' => $request->query->get('code'), | ||
]; | ||
|
||
$json = file_get_contents('https://graph.facebook.com/v11.0/oauth/access_token?'.http_build_query($data)); | ||
|
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,24 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* Instagram Bundle for Contao Open Source CMS. | ||
* | ||
* Copyright (C) 2011-2019 Codefog | ||
* social feed bundle for Contao Open Source CMS | ||
* | ||
* @author Codefog <https://codefog.pl> | ||
* @author Kamil Kuzminski <https://github.com/qzminski> | ||
* @license MIT | ||
* Copyright (c) 2021 pdir / digital agentur // pdir GmbH | ||
* | ||
* https://github.com/codefog/contao-instagram | ||
* @package social-feed-bundle | ||
* @link https://github.com/pdir/social-feed-bundle | ||
* @license http://www.gnu.org/licences/lgpl-3.0.html LGPL | ||
* @author Mathias Arzberger <[email protected]> | ||
* @author Philipp Seibt <[email protected]> | ||
* @author pdir GmbH <https://pdir.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Pdir\SocialFeedBundle\Controller; | ||
|
||
use Pdir\SocialFeedBundle\EventListener\SocialFeedListener; | ||
use Pdir\SocialFeedBundle\Importer\InstagramClient; | ||
use Contao\BackendUser; | ||
use Doctrine\DBAL\Connection; | ||
use Pdir\SocialFeedBundle\EventListener\SocialFeedListener; | ||
use Pdir\SocialFeedBundle\Importer\InstagramClient; | ||
use Symfony\Component\HttpFoundation\RedirectResponse; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
@@ -80,7 +85,7 @@ public function authAction(Request $request): Response | |
} | ||
|
||
// User not logged in | ||
if (null === ($user = $this->getBackendUser())) { | ||
if (null === $this->getBackendUser()) { | ||
return new Response(Response::$statusTexts[Response::HTTP_UNAUTHORIZED], Response::HTTP_UNAUTHORIZED); | ||
} | ||
|
||
|
@@ -109,7 +114,7 @@ public function authAction(Request $request): Response | |
|
||
// Get the user and media data | ||
$this->client->getUserData($accessToken, (int) $module['id'], false); | ||
$mediaData = $this->client->getMediaData($accessToken, (int) $module['id'], false); | ||
// $mediaData = $this->client->getMediaData($accessToken, (int) $module['id'], false); | ||
|
||
// Store the access token and remove temporary session key | ||
$this->db->update('tl_social_feed', ['psf_instagramAccessToken' => $accessToken], ['id' => $sessionData['socialFeedId']]); | ||
|
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,17 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* social feed bundle for Contao Open Source CMS | ||
* | ||
* Copyright (C) 2011-2019 Codefog | ||
* | ||
* The code of this class is based on the Instagram Bundle from Codefog | ||
* @author Codefog <https://codefog.pl> | ||
* @author Kamil Kuzminski <https://github.com/qzminski> | ||
* @license MIT | ||
* | ||
* Copyright (c) 2021 pdir / digital agentur // pdir GmbH | ||
* | ||
* @package social-feed-bundle | ||
* @link https://github.com/pdir/social-feed-bundle | ||
* @license http://www.gnu.org/licences/lgpl-3.0.html LGPL | ||
* @author Mathias Arzberger <[email protected]> | ||
* @author Philipp Seibt <[email protected]> | ||
* @author pdir GmbH <https://pdir.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Pdir\SocialFeedBundle\Controller; | ||
|
||
use Pdir\SocialFeedBundle\EventListener\SocialFeedListener; | ||
use Doctrine\DBAL\Connection; | ||
use Pdir\SocialFeedBundle\EventListener\SocialFeedListener; | ||
use Symfony\Component\HttpFoundation\RedirectResponse; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpFoundation\Session\SessionInterface; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
use Symfony\Component\Routing\RouterInterface; | ||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; | ||
use LinkedIn\Client; | ||
|
||
/** | ||
* @Route("/auth", defaults={"_scope" = "backend", "_token_check" = false}) | ||
|
@@ -51,28 +74,26 @@ public function authAction(Request $request): Response | |
$sessionData = $this->session->get(SocialFeedListener::SESSION_KEY); | ||
|
||
// Missing code query parameter | ||
if (!($code = $request->query->get('code'))) { | ||
if (!$request->query->get('code')) { | ||
return new Response(Response::$statusTexts[Response::HTTP_BAD_REQUEST], Response::HTTP_BAD_REQUEST); | ||
} else { | ||
//get refresh token | ||
$data = [ | ||
'grant_type' => 'authorization_code', | ||
'code' => $request->query->get('code'), | ||
'client_id' => $sessionData['clientId'], | ||
'client_secret' => $sessionData['clientSecret'], | ||
'redirect_uri' => $this->router->generate('auth_linkedin', [], RouterInterface::ABSOLUTE_URL) | ||
]; | ||
|
||
try { | ||
$token = json_decode(file_get_contents('https://www.linkedin.com/oauth/v2/accessToken?'.http_build_query($data))); | ||
} | ||
//get refresh token | ||
$data = [ | ||
'grant_type' => 'authorization_code', | ||
'code' => $request->query->get('code'), | ||
'client_id' => $sessionData['clientId'], | ||
'client_secret' => $sessionData['clientSecret'], | ||
'redirect_uri' => $this->router->generate('auth_linkedin', [], RouterInterface::ABSOLUTE_URL), | ||
]; | ||
|
||
// Store the access token and remove temporary session key | ||
$this->db->update('tl_social_feed', ['linkedin_access_token' => $token->access_token, 'access_token_expires' => time() + $token->expires_in, 'linkedin_refresh_token' => $token->refresh_token, 'linkedin_refresh_token_expires' => time() + $token->refresh_token_expires_in], ['id' => $sessionData['socialFeedId']]); | ||
$this->session->remove(SocialFeedListener::SESSION_KEY); | ||
} catch(Exception $e) { | ||
\System::log($e->getMessage(), __METHOD__, TL_GENERAL); | ||
} | ||
try { | ||
$token = json_decode(file_get_contents('https://www.linkedin.com/oauth/v2/accessToken?'.http_build_query($data))); | ||
|
||
// Store the access token and remove temporary session key | ||
$this->db->update('tl_social_feed', ['linkedin_access_token' => $token->access_token, 'access_token_expires' => time() + $token->expires_in, 'linkedin_refresh_token' => $token->refresh_token, 'linkedin_refresh_token_expires' => time() + $token->refresh_token_expires_in], ['id' => $sessionData['socialFeedId']]); | ||
$this->session->remove(SocialFeedListener::SESSION_KEY); | ||
} catch (Exception $e) { | ||
System::log($e->getMessage(), __METHOD__, TL_GENERAL); | ||
} | ||
|
||
return new RedirectResponse($sessionData['backUrl']); | ||
|
Oops, something went wrong.