blob: e1692480b8d017eaa458e96a0c0036fa052c2b55 (
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
65
66
67
68
69
70
71
|
<?php
namespace Kanboard\Core\User;
/**
* User Manager
*
* @package Kanboard\Core\User
* @author Frederic Guillot
*/
class UserManager
{
/**
* List of backend providers
*
* @access protected
* @var array
*/
protected $providers = array();
/**
* Register a new group backend provider
*
* @access public
* @param UserBackendProviderInterface $provider
* @return $this
*/
public function register(UserBackendProviderInterface $provider)
{
$this->providers[] = $provider;
return $this;
}
/**
* Find a group from a search query
*
* @access public
* @param string $input
* @return UserProviderInterface[]
*/
public function find($input)
{
$groups = array();
foreach ($this->providers as $provider) {
$groups = array_merge($groups, $provider->find($input));
}
return $this->removeDuplicates($groups);
}
/**
* Remove duplicated users
*
* @access protected
* @param array $users
* @return UserProviderInterface[]
*/
protected function removeDuplicates(array $users)
{
$result = array();
foreach ($users as $user) {
if (! isset($result[$user->getUsername()])) {
$result[$user->getUsername()] = $user;
}
}
return array_values($result);
}
}
|