blob: afaf79d29746ed9e501d7dbb0960d336e43f1871 (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
<?php
namespace Kanboard\Core\User\Avatar;
/**
* Avatar Manager
*
* @package avatar
* @author Frederic Guillot
*/
class AvatarManager
{
/**
* Providers
*
* @access private
* @var AvatarProviderInterface[]
*/
private $providers = array();
/**
* Register a new Avatar provider
*
* @access public
* @param AvatarProviderInterface $provider
* @return $this
*/
public function register(AvatarProviderInterface $provider)
{
$this->providers[] = $provider;
return $this;
}
/**
* Render avatar html element
*
* @access public
* @param string $user_id
* @param string $username
* @param string $name
* @param string $email
* @param int $size
* @return string
*/
public function render($user_id, $username, $name, $email, $size)
{
$user = array(
'id' => $user_id,
'username' => $username,
'name' => $name,
'email' => $email,
);
krsort($this->providers);
foreach ($this->providers as $provider) {
if ($provider->isActive($user)) {
return $provider->render($user, $size);
}
}
return '';
}
}
|