mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Chill\MainBundle\Export\Helper;
|
|
|
|
use Chill\MainBundle\Repository\UserRepositoryInterface;
|
|
use Chill\MainBundle\Templating\Entity\UserRender;
|
|
|
|
class UserHelper
|
|
{
|
|
private UserRender $userRender;
|
|
|
|
private UserRepositoryInterface $userRepository;
|
|
|
|
public function __construct(UserRender $userRender, UserRepositoryInterface $userRepository)
|
|
{
|
|
$this->userRender = $userRender;
|
|
$this->userRepository = $userRepository;
|
|
}
|
|
|
|
public function getLabel($key, array $values, string $header): callable
|
|
{
|
|
return function ($value) use ($header) {
|
|
if ('_header' === $value) {
|
|
return $header;
|
|
}
|
|
|
|
if (null === $value || null === $user = $this->userRepository->find($value)) {
|
|
return '';
|
|
}
|
|
|
|
return $this->userRender->renderString($user, []);
|
|
};
|
|
}
|
|
}
|