Skip to content

Commit

Permalink
property promotion
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioRadu committed Oct 23, 2023
1 parent d298009 commit 27d2c2f
Show file tree
Hide file tree
Showing 27 changed files with 72 additions and 290 deletions.
17 changes: 4 additions & 13 deletions src/App/src/Controller/LanguageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@

class LanguageController extends AbstractActionController
{
protected TranslateServiceInterface $translateService;
protected RouterInterface $router;
protected TemplateRendererInterface $template;
protected array $translatorConfig = [];

/**
* @Inject({
* TranslateServiceInterface::class,
Expand All @@ -32,15 +27,11 @@ class LanguageController extends AbstractActionController
* })
*/
public function __construct(
TranslateServiceInterface $translateService,
RouterInterface $router,
TemplateRendererInterface $template,
array $translatorConfig
protected TranslateServiceInterface $translateService,
protected RouterInterface $router,
protected TemplateRendererInterface $template,
protected array $translatorConfig
) {
$this->translateService = $translateService;
$this->router = $router;
$this->template = $template;
$this->translatorConfig = $translatorConfig;
}

public function changeAction(): ResponseInterface
Expand Down
17 changes: 4 additions & 13 deletions src/App/src/Middleware/AuthMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,12 @@

class AuthMiddleware implements MiddlewareInterface
{
protected RouterInterface $router;
protected FlashMessengerInterface $messenger;
protected GuardsProviderInterface $guardProvider;
protected RbacGuardOptions $options;

public function __construct(
RouterInterface $router,
FlashMessengerInterface $messenger,
GuardsProviderInterface $guardProvider,
RbacGuardOptions $options
protected RouterInterface $router,
protected FlashMessengerInterface $messenger,
protected GuardsProviderInterface $guardProvider,
protected RbacGuardOptions $options
) {
$this->router = $router;
$this->messenger = $messenger;
$this->guardProvider = $guardProvider;
$this->options = $options;
}

public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
Expand Down
17 changes: 3 additions & 14 deletions src/App/src/Middleware/RememberMeMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
use Dot\AnnotatedServices\Annotation\Service;
use Frontend\User\Entity\UserIdentity;
use Frontend\User\Entity\UserRole;
use Frontend\User\Repository\UserRepository;
use Frontend\User\Service\UserServiceInterface;
use Laminas\Authentication\AuthenticationService;
use Laminas\Authentication\AuthenticationServiceInterface;
use Laminas\Authentication\Exception\ExceptionInterface;
use Psr\Http\Message\ResponseInterface;
Expand All @@ -25,12 +23,6 @@
*/
class RememberMeMiddleware implements MiddlewareInterface
{
protected UserServiceInterface $userService;
protected AuthenticationServiceInterface $authenticationService;

protected UserRepository $repository;
protected array $rememberConfig = [];

/**
* @Inject({
* UserServiceInterface::class,
Expand All @@ -39,13 +31,10 @@ class RememberMeMiddleware implements MiddlewareInterface
* })
*/
public function __construct(
UserServiceInterface $userService,
AuthenticationServiceInterface $authenticationService,
array $rememberConfig
protected UserServiceInterface $userService,
protected AuthenticationServiceInterface $authenticationService,
protected array $rememberConfig
) {
$this->userService = $userService;
$this->authenticationService = $authenticationService;
$this->rememberConfig = $rememberConfig;
}

/**
Expand Down
13 changes: 3 additions & 10 deletions src/App/src/Middleware/TranslatorMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
*/
class TranslatorMiddleware implements MiddlewareInterface
{
protected TranslateServiceInterface $translateService;
protected TemplateRendererInterface $template;
protected array $translatorConfig = [];

/**
* @Inject({
* TranslateServiceInterface::class,
Expand All @@ -40,13 +36,10 @@ class TranslatorMiddleware implements MiddlewareInterface
* })
*/
public function __construct(
TranslateServiceInterface $translateService,
TemplateRendererInterface $template,
array $translatorConfig
protected TranslateServiceInterface $translateService,
protected TemplateRendererInterface $template,
protected array $translatorConfig
) {
$this->translateService = $translateService;
$this->template = $template;
$this->translatorConfig = $translatorConfig;
}

public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
Expand Down
5 changes: 1 addition & 4 deletions src/App/src/Resolver/EntityListenerResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@

class EntityListenerResolver extends DefaultEntityListenerResolver
{
protected ContainerInterface $container;

public function __construct(ContainerInterface $container)
public function __construct(protected ContainerInterface $container)
{
$this->container = $container;
}

/**
Expand Down
9 changes: 2 additions & 7 deletions src/App/src/Service/TranslateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,16 @@

class TranslateService implements TranslateServiceInterface
{
protected CookieServiceInterface $cookieService;
protected array $config = [];

/**
* @Inject({
* CookieServiceInterface::class,
* "config"
* })
*/
public function __construct(
CookieServiceInterface $cookieService,
array $config = []
protected CookieServiceInterface $cookieService,
protected array $config = []
) {
$this->cookieService = $cookieService;
$this->config = $config;
}

public function addTranslatorCookie(string $languageKey): void
Expand Down
39 changes: 9 additions & 30 deletions src/Contact/src/Controller/ContactController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Frontend\Contact\Service\MessageServiceInterface;
use Frontend\Plugin\FormsPlugin;
use Laminas\Authentication\AuthenticationService;
use Laminas\Authentication\AuthenticationServiceInterface;
use Laminas\Diactoros\Response\HtmlResponse;
use Laminas\Diactoros\Response\RedirectResponse;
use Mezzio\Router\RouterInterface;
Expand All @@ -23,18 +22,7 @@

class ContactController extends AbstractActionController
{
protected RouterInterface $router;
protected TemplateRendererInterface $template;
protected MessageServiceInterface $messageService;
protected RecaptchaService $recaptchaService;
protected AuthenticationServiceInterface $authenticationService;
protected FlashMessenger $messenger;
protected FormsPlugin $forms;
protected DebugBar $debugBar;
protected array $config;

/**
* @param array $config
* @Inject({
* MessageServiceInterface::class,
* RecaptchaService::class,
Expand All @@ -48,25 +36,16 @@ class ContactController extends AbstractActionController
* })
*/
public function __construct(
MessageServiceInterface $messageService,
RecaptchaService $recaptchaService,
RouterInterface $router,
TemplateRendererInterface $template,
AuthenticationService $authenticationService,
FlashMessenger $messenger,
FormsPlugin $forms,
DebugBar $debugBar,
array $config = []
protected MessageServiceInterface $messageService,
protected RecaptchaService $recaptchaService,
protected RouterInterface $router,
protected TemplateRendererInterface $template,
protected AuthenticationService $authenticationService,
protected FlashMessenger $messenger,
protected FormsPlugin $forms,
protected DebugBar $debugBar,
protected array $config = []
) {
$this->messageService = $messageService;
$this->recaptchaService = $recaptchaService;
$this->router = $router;
$this->template = $template;
$this->authenticationService = $authenticationService;
$this->messenger = $messenger;
$this->forms = $forms;
$this->debugBar = $debugBar;
$this->config = $config;
}

public function formAction(): ResponseInterface
Expand Down
21 changes: 4 additions & 17 deletions src/Contact/src/Service/MessageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,7 @@

class MessageService implements MessageServiceInterface
{
protected MessageRepository|EntityRepository $repository;

protected MailServiceInterface $mailService;

protected TemplateRendererInterface $templateRenderer;

protected array $config = [];

/**
* @param array $config
* @Inject({
* MessageRepository::class,
* MailServiceInterface::class,
Expand All @@ -32,15 +23,11 @@ class MessageService implements MessageServiceInterface
* })
*/
public function __construct(
MessageRepository $repository,
MailServiceInterface $mailService,
TemplateRendererInterface $templateRenderer,
array $config = []
protected MessageRepository $repository,
protected MailServiceInterface $mailService,
protected TemplateRendererInterface $templateRenderer,
protected array $config = []
) {
$this->repository = $repository;
$this->mailService = $mailService;
$this->templateRenderer = $templateRenderer;
$this->config = $config;
}

public function getRepository(): MessageRepository|EntityRepository
Expand Down
13 changes: 3 additions & 10 deletions src/Page/src/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@

class PageController extends AbstractActionController
{
protected RouterInterface $router;
protected PageServiceInterface $pageService;
protected TemplateRendererInterface $template;

/**
* @Inject({
* PageServiceInterface::class,
Expand All @@ -26,13 +22,10 @@ class PageController extends AbstractActionController
* })
*/
public function __construct(
PageServiceInterface $pageService,
RouterInterface $router,
TemplateRendererInterface $template
protected PageServiceInterface $pageService,
protected RouterInterface $router,
protected TemplateRendererInterface $template
) {
$this->pageService = $pageService;
$this->router = $router;
$this->template = $template;
}

public function indexAction(): ResponseInterface
Expand Down
9 changes: 2 additions & 7 deletions src/Plugin/src/FormsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@

class FormsPlugin implements PluginInterface
{
protected FormElementManager $formElementManager;
protected ?FlashMessengerInterface $flashMessenger;

public function __construct(
FormElementManager $formManager,
?FlashMessengerInterface $flashMessenger = null
protected FormElementManager $formManager,
protected ?FlashMessengerInterface $flashMessenger = null
) {
$this->formElementManager = $formManager;
$this->flashMessenger = $flashMessenger;
}

public function restoreState(Form $form): void
Expand Down
11 changes: 1 addition & 10 deletions src/Plugin/src/TemplatePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,10 @@

class TemplatePlugin implements PluginInterface
{
protected TemplateRendererInterface $template;

public function __construct(TemplateRendererInterface $template)
public function __construct(protected TemplateRendererInterface $template)
{
$this->template = $template;
}

/**
* @param array $params
*/
public function __invoke(?string $templateName = null, array $params = []): TemplatePlugin|string
{
$args = func_get_args();
Expand All @@ -30,9 +24,6 @@ public function __invoke(?string $templateName = null, array $params = []): Temp
return $this->render($templateName, $params);
}

/**
* @param array $params
*/
public function render(string $templateName, array $params = []): string
{
return $this->template->render($templateName, $params);
Expand Down
8 changes: 1 addition & 7 deletions src/User/src/Adapter/AuthenticationAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,8 @@

class AuthenticationAdapter extends AbstractAdapter implements AdapterInterface
{
private EntityRepository $entityRepository;

private array $config;

public function __construct(EntityRepository $entityRepository, array $config)
public function __construct(private EntityRepository $entityRepository, private array $config)
{
$this->entityRepository = $entityRepository;
$this->config = $config;
}

public function authenticate(): Result
Expand Down
Loading

0 comments on commit 27d2c2f

Please sign in to comment.