Skip to content
This repository was archived by the owner on Aug 17, 2022. It is now read-only.

Commit de422d1

Browse files
authored
Merge pull request #7 from zikula/analysis-XaA0mV
Apply fixes from StyleCI
2 parents fb1f4f1 + 753fd20 commit de422d1

17 files changed

+42
-26
lines changed

AuthenticationMethod/AbstractAuthenticationMethod.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34
/*
45
* This file is part of the Zikula package.
56
*
@@ -131,7 +132,7 @@ protected function setAdditionalUserData()
131132
*/
132133
public function authenticate(array $data = [])
133134
{
134-
$redirectUri = isset($data['redirectUri']) ? $data['redirectUri'] : $this->router->generate('zikulausersmodule_access_login', [], UrlGeneratorInterface::ABSOLUTE_URL);
135+
$redirectUri = $data['redirectUri'] ?? $this->router->generate('zikulausersmodule_access_login', [], UrlGeneratorInterface::ABSOLUTE_URL);
135136
$this->setProvider($redirectUri);
136137
$request = $this->requestStack->getCurrentRequest();
137138
$state = $request->query->get('state', null);
@@ -151,39 +152,38 @@ public function authenticate(array $data = [])
151152
$this->session->getFlashBag()->add('error', 'Invalid State');
152153

153154
return null;
154-
} else {
155-
// Try to get an access token (using the authorization code grant)
156-
$this->token = $this->getProvider()->getAccessToken('authorization_code', [
155+
}
156+
// Try to get an access token (using the authorization code grant)
157+
$this->token = $this->getProvider()->getAccessToken('authorization_code', [
157158
'code' => $code
158159
]);
159160

160-
try {
161-
// get the user's details
162-
$this->user = $this->getProvider()->getResourceOwner($this->token);
163-
$this->setAdditionalUserData();
164-
$uid = $this->repository->getZikulaId($this->getAlias(), $this->user->getId());
165-
if (isset($uid)) {
166-
//$this->session->getFlashBag()->add('success', sprintf('Hello %s!', $this->getUname()));
167-
} else {
168-
$registrationUrl = $this->router->generate('zikulausersmodule_registration_register');
169-
$this->session->remove('oauth2state');
170-
$registerLink = '<a href="' . $registrationUrl . '">' . $this->translator->__('create a new account') . '</a>';
171-
$this->session->getFlashBag()->add('error',
161+
try {
162+
// get the user's details
163+
$this->user = $this->getProvider()->getResourceOwner($this->token);
164+
$this->setAdditionalUserData();
165+
$uid = $this->repository->getZikulaId($this->getAlias(), $this->user->getId());
166+
if (isset($uid)) {
167+
//$this->session->getFlashBag()->add('success', sprintf('Hello %s!', $this->getUname()));
168+
} else {
169+
$registrationUrl = $this->router->generate('zikulausersmodule_registration_register');
170+
$this->session->remove('oauth2state');
171+
$registerLink = '<a href="' . $registrationUrl . '">' . $this->translator->__('create a new account') . '</a>';
172+
$this->session->getFlashBag()->add('error',
172173
$this->translator->__f(
173174
'This user is not locally registered. You must first %registerLink on this site before logging in with %displayName', [
174175
'%registerLink' => $registerLink,
175176
'%displayName' => $this->getDisplayName()
176177
]
177178
)
178179
);
179-
}
180+
}
180181

181-
return $uid;
182-
} catch (\Exception $exception) {
183-
$this->session->getFlashBag()->add('error', $this->translator->__('Could not obtain user details from external service.') . ' (' . $exception->getMessage() . ')');
182+
return $uid;
183+
} catch (\Exception $exception) {
184+
$this->session->getFlashBag()->add('error', $this->translator->__('Could not obtain user details from external service.') . ' (' . $exception->getMessage() . ')');
184185

185-
return null;
186-
}
186+
return null;
187187
}
188188
}
189189

AuthenticationMethod/FacebookAuthenticationMethod.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34
/*
45
* This file is part of the Zikula package.
56
*

AuthenticationMethod/GithubAuthenticationMethod.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34
/*
45
* This file is part of the Zikula package.
56
*

AuthenticationMethod/GoogleAuthenticationMethod.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34
/*
45
* This file is part of the Zikula package.
56
*

AuthenticationMethod/LinkedInAuthenticationMethod.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34
/*
45
* This file is part of the Zikula package.
56
*

Container/LinkContainer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34
/*
45
* This file is part of the Zikula package.
56
*
@@ -65,9 +66,9 @@ public function __construct(TranslatorInterface $translator, RouterInterface $ro
6566
*/
6667
public function getLinks($type = LinkContainerInterface::TYPE_ADMIN)
6768
{
68-
$method = 'get' . ucfirst(strtolower($type));
69+
$method = 'get' . ucfirst(mb_strtolower($type));
6970
if (method_exists($this, $method)) {
70-
return $this->$method();
71+
return $this->{$method}();
7172
}
7273

7374
return [];

Controller/ConfigController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34
/*
45
* This file is part of the Zikula package.
56
*

Controller/MappingController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34
/*
45
* This file is part of the Zikula package.
56
*
@@ -15,8 +16,8 @@
1516
use Symfony\Component\Routing\Annotation\Route;
1617
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
1718
use Zikula\Core\Controller\AbstractController;
18-
use Zikula\ThemeModule\Engine\Annotation\Theme;
1919
use Zikula\OAuthModule\Entity\Repository\MappingRepository;
20+
use Zikula\ThemeModule\Engine\Annotation\Theme;
2021

2122
/**
2223
* Class MappingController

DependencyInjection/ZikulaOAuthExtension.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34
/*
45
* This file is part of the Zikula package.
56
*
@@ -11,10 +12,10 @@
1112

1213
namespace Zikula\OAuthModule\DependencyInjection;
1314

15+
use Symfony\Component\Config\FileLocator;
1416
use Symfony\Component\DependencyInjection\ContainerBuilder;
1517
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
1618
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
17-
use Symfony\Component\Config\FileLocator;
1819

1920
class ZikulaOAuthExtension extends Extension
2021
{

Entity/MappingEntity.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34
/*
45
* This file is part of the Zikula package.
56
*

Entity/Repository/MappingRepository.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34
/*
45
* This file is part of the Zikula package.
56
*

Exception/InvalidProviderConfigException.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34
/*
45
* This file is part of the Zikula package.
56
*

Form/Type/SettingsType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34
/*
45
* This file is part of the Zikula package.
56
*

Listener/UserDeleteListener.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34
/*
45
* This file is part of the Zikula package.
56
*

OAuthConstant.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34
/*
45
* This file is part of the Zikula package.
56
*

OAuthModuleInstaller.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34
/*
45
* This file is part of the Zikula package.
56
*

ZikulaOAuthModule.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
declare(strict_types=1);
34
/*
45
* This file is part of the Zikula package.
56
*

0 commit comments

Comments
 (0)