mirror of
https://github.com/wallabag/wallabag.git
synced 2025-02-28 16:36:26 +00:00
Merge pull request #8018 from wallabag/use-constructor-injection-for-registration-parameter
Use constructor injection for registration parameter
This commit is contained in:
commit
3e20d07f96
2 changed files with 5 additions and 3 deletions
|
@ -104,7 +104,7 @@ class UserRestController extends WallabagRestController
|
||||||
*/
|
*/
|
||||||
public function putUserAction(Request $request, Config $craueConfig, UserManagerInterface $userManager, EntityManagerInterface $entityManager, EventDispatcherInterface $eventDispatcher)
|
public function putUserAction(Request $request, Config $craueConfig, UserManagerInterface $userManager, EntityManagerInterface $entityManager, EventDispatcherInterface $eventDispatcher)
|
||||||
{
|
{
|
||||||
if (!$this->getParameter('fosuser_registration') || !$craueConfig->get('api_user_registration')) {
|
if (!$this->registrationEnabled || !$craueConfig->get('api_user_registration')) {
|
||||||
$json = $this->serializer->serialize(['error' => "Server doesn't allow registrations"], 'json');
|
$json = $this->serializer->serialize(['error' => "Server doesn't allow registrations"], 'json');
|
||||||
|
|
||||||
return (new JsonResponse())
|
return (new JsonResponse())
|
||||||
|
|
|
@ -26,14 +26,16 @@ class WallabagRestController extends AbstractFOSRestController
|
||||||
protected AuthorizationCheckerInterface $authorizationChecker;
|
protected AuthorizationCheckerInterface $authorizationChecker;
|
||||||
protected TokenStorageInterface $tokenStorage;
|
protected TokenStorageInterface $tokenStorage;
|
||||||
protected TranslatorInterface $translator;
|
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->entityManager = $entityManager;
|
||||||
$this->serializer = $serializer;
|
$this->serializer = $serializer;
|
||||||
$this->authorizationChecker = $authorizationChecker;
|
$this->authorizationChecker = $authorizationChecker;
|
||||||
$this->tokenStorage = $tokenStorage;
|
$this->tokenStorage = $tokenStorage;
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
|
$this->registrationEnabled = $registrationEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,7 +88,7 @@ class WallabagRestController extends AbstractFOSRestController
|
||||||
{
|
{
|
||||||
$info = new ApplicationInfo(
|
$info = new ApplicationInfo(
|
||||||
$this->getParameter('wallabag.version'),
|
$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'));
|
return (new JsonResponse())->setJson($this->serializer->serialize($info, 'json'));
|
||||||
|
|
Loading…
Reference in a new issue