|
<?php |
|
|
|
namespace Kanboard\Formatter; |
|
|
|
use Kanboard\Core\User\UserProviderInterface; |
|
use Kanboard\Core\Filter\FormatterInterface; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UserAutoCompleteFormatter extends BaseFormatter implements FormatterInterface |
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
protected $users; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function withUsers(array $users) |
|
{ |
|
$this->users = $users; |
|
return $this; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function format() |
|
{ |
|
$result = array(); |
|
|
|
foreach ($this->users as $user) { |
|
$result[] = array( |
|
'id' => $user->getInternalId(), |
|
'username' => $user->getUsername(), |
|
'external_id' => $user->getExternalId(), |
|
'external_id_column' => $user->getExternalIdColumn(), |
|
'value' => $user->getName() === '' ? $user->getUsername() : $user->getName(), |
|
'label' => $user->getName() === '' ? $user->getUsername() : $user->getName().' ('.$user->getUsername().')', |
|
); |
|
} |
|
|
|
return $result; |
|
} |
|
} |
|
|