Use constructor injection for registration parameter

This commit is contained in:
Yassine Guedidi
2025-01-11 02:19:43 +01:00
parent 09dcee3fc6
commit f0cc6ddb49
2 changed files with 5 additions and 3 deletions

View File

@ -26,14 +26,16 @@ class WallabagRestController extends AbstractFOSRestController
protected AuthorizationCheckerInterface $authorizationChecker;
protected TokenStorageInterface $tokenStorage;
protected TranslatorInterface $translator;
protected bool $registrationEnabled;
public function __construct(EntityManagerInterface $entityManager, SerializerInterface $serializer, AuthorizationCheckerInterface $authorizationChecker, TokenStorageInterface $tokenStorage, TranslatorInterface $translator)
public function __construct(EntityManagerInterface $entityManager, SerializerInterface $serializer, AuthorizationCheckerInterface $authorizationChecker, TokenStorageInterface $tokenStorage, TranslatorInterface $translator, bool $registrationEnabled)
{
$this->entityManager = $entityManager;
$this->serializer = $serializer;
$this->authorizationChecker = $authorizationChecker;
$this->tokenStorage = $tokenStorage;
$this->translator = $translator;
$this->registrationEnabled = $registrationEnabled;
}
/**
@ -86,7 +88,7 @@ class WallabagRestController extends AbstractFOSRestController
{
$info = new ApplicationInfo(
$this->getParameter('wallabag.version'),
$this->getParameter('fosuser_registration') && $craueConfig->get('api_user_registration'),
$this->registrationEnabled && $craueConfig->get('api_user_registration'),
);
return (new JsonResponse())->setJson($this->serializer->serialize($info, 'json'));