summaryrefslogtreecommitdiffstats
path: root/Guard/AbstractGuardAuthenticator.php
blob: ebd09bb73f20e84b41b0d85f20b281f88f509415 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php

namespace Symfony\Component\Security\Guard;

use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Guard\Token\GenericGuardToken;

/**
 * An optional base class that creates a GenericGuardToken for you
 *
 * @author Ryan Weaver <weaverryan@gmail.com>
 */
abstract class AbstractGuardAuthenticator implements GuardAuthenticatorInterface
{
    /**
     * Shortcut to create a GenericGuardToken for you, if you don't really
     * care about which authenticated token you're using
     *
     * @param UserInterface $user
     * @param string $providerKey
     * @return GenericGuardToken
     */
    public function createAuthenticatedToken(UserInterface $user, $providerKey)
    {
        return new GenericGuardToken(
            $user,
            $providerKey,
            $user->getRoles()
        );
    }
}