mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
show users as suggestions, not in constrained list
This commit is contained in:
@@ -20,14 +20,21 @@
|
||||
namespace Chill\MainBundle\Serializer\Normalizer;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
* @internal we keep this normalizer, because the property 'text' may be replace by a rendering in the future
|
||||
*/
|
||||
class UserNormalizer implements NormalizerInterface
|
||||
class UserNormalizer implements NormalizerInterface, NormalizerAwareInterface
|
||||
{
|
||||
use NormalizerAwareTrait;
|
||||
private UserRender $userRender;
|
||||
|
||||
public function __construct(UserRender $userRender)
|
||||
{
|
||||
$this->userRender = $userRender;
|
||||
}
|
||||
|
||||
public function normalize($user, string $format = null, array $context = array())
|
||||
{
|
||||
/** @var User $user */
|
||||
@@ -35,7 +42,11 @@ class UserNormalizer implements NormalizerInterface
|
||||
'type' => 'user',
|
||||
'id' => $user->getId(),
|
||||
'username' => $user->getUsername(),
|
||||
'text' => $user->getUsername()
|
||||
'text' => $this->userRender->renderString($user, []),
|
||||
'label' => $user->getLabel(),
|
||||
'user_job' => $this->normalizer->normalize($user->getUserJob(), $format, $context),
|
||||
'main_center' => $this->normalizer->normalize($user->getMainCenter(), $format, $context),
|
||||
'main_scope' => $this->normalizer->normalize($user->getMainScope(), $format, $context),
|
||||
];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user