userRender = $userRender; } public function normalize($user, ?string $format = null, array $context = []) { /** @var User $user */ return [ 'type' => 'user', 'id' => $user->getId(), 'username' => $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), ]; } public function supportsNormalization($data, ?string $format = null): bool { return $data instanceof User && ('json' === $format || 'docgen' === $format); } }