show users as suggestions, not in constrained list

This commit is contained in:
2021-10-20 19:59:08 +02:00
parent 0a058bad82
commit 3f138dc152
13 changed files with 197 additions and 42 deletions

View File

@@ -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),
];
}