Skip to content

Commit

Permalink
Remove deprecation notice about getProviderKey in Symfony 5.2+ (#68)
Browse files Browse the repository at this point in the history
Remove deprecation notice about getProviderKey in Symfony 5.2+
  • Loading branch information
Seldaek authored Apr 1, 2021
1 parent 00a4b0e commit 717e3a7
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/bundle/Security/Authentication/Token/TwoFactorToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TwoFactorToken implements TwoFactorTokenInterface
/**
* @var string
*/
private $providerKey;
private $firewallName;

/**
* @var array
Expand All @@ -40,11 +40,11 @@ class TwoFactorToken implements TwoFactorTokenInterface
*/
private $preparedProviders = [];

public function __construct(TokenInterface $authenticatedToken, ?string $credentials, string $providerKey, array $twoFactorProviders)
public function __construct(TokenInterface $authenticatedToken, ?string $credentials, string $firewallName, array $twoFactorProviders)
{
$this->authenticatedToken = $authenticatedToken;
$this->credentials = $credentials;
$this->providerKey = $providerKey;
$this->firewallName = $firewallName;
$this->twoFactorProviders = $twoFactorProviders;
}

Expand Down Expand Up @@ -80,7 +80,7 @@ public function getRoleNames(): array

public function createWithCredentials(string $credentials): TwoFactorTokenInterface
{
$credentialsToken = new self($this->authenticatedToken, $credentials, $this->providerKey, $this->twoFactorProviders);
$credentialsToken = new self($this->authenticatedToken, $credentials, $this->firewallName, $this->twoFactorProviders);
foreach (array_keys($this->preparedProviders) as $preparedProviderName) {
$credentialsToken->setTwoFactorProviderPrepared($preparedProviderName);
}
Expand Down Expand Up @@ -155,9 +155,21 @@ public function allTwoFactorProvidersAuthenticated(): bool
return 0 === \count($this->twoFactorProviders);
}

/**
* @deprecated since 5.8, use getFirewallName() instead
*/
public function getProviderKey(): string
{
return $this->providerKey;
if (1 !== \func_num_args() || true !== func_get_arg(0)) {
@trigger_error(sprintf('Method "%s" is deprecated, use "getFirewallName()" instead.', __METHOD__), E_USER_DEPRECATED);
}

return $this->firewallName;
}

public function getFirewallName(): string
{
return $this->getProviderKey(true);
}

public function isAuthenticated(): bool
Expand All @@ -178,7 +190,7 @@ public function __serialize(): array
return [
$this->authenticatedToken,
$this->credentials,
$this->providerKey,
$this->firewallName,
$this->attributes,
$this->twoFactorProviders,
$this->preparedProviders,
Expand All @@ -196,7 +208,7 @@ public function __unserialize(array $data): void
[
$this->authenticatedToken,
$this->credentials,
$this->providerKey,
$this->firewallName,
$this->attributes,
$this->twoFactorProviders,
$this->preparedProviders,
Expand Down

0 comments on commit 717e3a7

Please sign in to comment.