refactor services using constructor property promotions

This commit is contained in:
Simon Vieille 2023-10-20 09:44:18 +02:00
parent c1eb277a6a
commit 5c3f2ab1e7
Signed by: deblan
GPG key ID: 579388D585F70417
47 changed files with 136 additions and 343 deletions

View file

@ -10,14 +10,12 @@ namespace App\Core\Ab;
class AbTest implements AbTestInterface class AbTest implements AbTestInterface
{ {
protected $results; protected $results;
protected string $name;
protected array $variations = []; protected array $variations = [];
protected array $probabilities = []; protected array $probabilities = [];
protected int $duration = 3600 * 24; protected int $duration = 3600 * 24;
public function __construct(string $name) public function __construct(protected string $name)
{ {
$this->name = $name;
} }
public function getName(): string public function getName(): string

View file

@ -13,18 +13,16 @@ use App\Core\Repository\Analytic\ViewRepositoryQuery;
*/ */
class DateRangeAnalytic class DateRangeAnalytic
{ {
protected ViewRepositoryQuery $viewQuery;
protected RefererRepositoryQuery $refererQuery;
protected ?Node $node; protected ?Node $node;
protected ?\DateTime $from; protected ?\DateTime $from;
protected ?\DateTime $to; protected ?\DateTime $to;
protected bool $reload = true; protected bool $reload = true;
protected array $cache = []; protected array $cache = [];
public function __construct(ViewRepositoryQuery $viewQuery, RefererRepositoryQuery $refererQuery) public function __construct(
{ protected ViewRepositoryQuery $viewQuery,
$this->viewQuery = $viewQuery; protected RefererRepositoryQuery $refererQuery
$this->refererQuery = $refererQuery; ) {
} }
public function getViews(): array public function getViews(): array

View file

@ -10,16 +10,10 @@ namespace App\Core\Annotation;
#[\Attribute] #[\Attribute]
class UrlGenerator class UrlGenerator
{ {
public string $service; public function __construct(
public string $service,
public string $method; public string $method,
public array $options = []
public array $options = []; ) {
public function __construct(string $service, string $method, array $options = [])
{
$this->service = $service;
$this->method = $method;
$this->options = $options;
} }
} }

View file

@ -23,20 +23,12 @@ class LoginFormAuthenticator extends AbstractFormLoginAuthenticator
{ {
use TargetPathTrait; use TargetPathTrait;
private EntityManagerInterface $entityManager; public function __construct(
private EntityManagerInterface $entityManager,
private UrlGeneratorInterface $urlGenerator; private UrlGeneratorInterface $urlGenerator,
private CsrfTokenManagerInterface $csrfTokenManager,
private CsrfTokenManagerInterface $csrfTokenManager; private UserPasswordEncoderInterface $passwordEncoder
) {
private UserPasswordEncoderInterface $passwordEncoder;
public function __construct(EntityManagerInterface $entityManager, UrlGeneratorInterface $urlGenerator, CsrfTokenManagerInterface $csrfTokenManager, UserPasswordEncoderInterface $passwordEncoder)
{
$this->entityManager = $entityManager;
$this->urlGenerator = $urlGenerator;
$this->csrfTokenManager = $csrfTokenManager;
$this->passwordEncoder = $passwordEncoder;
} }
public function supports(Request $request) public function supports(Request $request)

View file

@ -20,15 +20,11 @@ use Symfony\Contracts\HttpClient\HttpClientInterface;
*/ */
class SymfonyCacheManager class SymfonyCacheManager
{ {
protected KernelInterface $kernel; public function __construct(
protected HttpClientInterface $httpClient; protected KernelInterface $kernel,
protected UrlGeneratorInterface $urlGenerator; protected HttpClientInterface $httpClient,
protected UrlGeneratorInterface $urlGenerator
public function __construct(KernelInterface $kernel, HttpClientInterface $httpClient, UrlGeneratorInterface $urlGenerator) ) {
{
$this->kernel = $kernel;
$this->httpClient = $httpClient;
$this->urlGenerator = $urlGenerator;
} }
public function cleanRouting() public function cleanRouting()

View file

@ -18,19 +18,12 @@ class UserCreateCommand extends Command
{ {
protected static $defaultName = 'murph:user:create'; protected static $defaultName = 'murph:user:create';
protected static $defaultDescription = 'Creates a user'; protected static $defaultDescription = 'Creates a user';
protected UserFactory $userFactory;
protected EntityManager $entityManager;
protected TokenGeneratorInterface $tokenGenerator;
public function __construct( public function __construct(
UserFactory $userFactory, protected UserFactory $userFactory,
EntityManager $entityManager, protected EntityManager $entityManager,
TokenGeneratorInterface $tokenGenerator protected TokenGeneratorInterface $tokenGenerator
) { ) {
$this->userFactory = $userFactory;
$this->entityManager = $entityManager;
$this->tokenGenerator = $tokenGenerator;
parent::__construct(); parent::__construct();
} }

View file

@ -15,11 +15,8 @@ class AbTestEvent extends Event
public const INIT_EVENT = 'ab_test.init'; public const INIT_EVENT = 'ab_test.init';
public const RUN_EVENT = 'ab_test.run'; public const RUN_EVENT = 'ab_test.run';
protected AbTest $test; public function __construct(protected AbTest $test)
public function __construct(AbTest $test)
{ {
$this->test = $test;
} }
public function getTest(): AbTest public function getTest(): AbTest

View file

@ -14,11 +14,8 @@ class PasswordRequestEvent extends Event
{ {
public const EVENT = 'account_event.password_request'; public const EVENT = 'account_event.password_request';
protected User $user; public function __construct(protected User $user)
public function __construct(User $user)
{ {
$this->user = $user;
} }
public function getUser(): User public function getUser(): User

View file

@ -19,11 +19,8 @@ class EntityManagerEvent extends Event
public const PRE_UPDATE_EVENT = 'entity_manager_event.pre_update'; public const PRE_UPDATE_EVENT = 'entity_manager_event.pre_update';
public const PRE_DELETE_EVENT = 'entity_manager_event.pre_delete'; public const PRE_DELETE_EVENT = 'entity_manager_event.pre_delete';
protected EntityInterface $entity; public function __construct(protected EntityInterface $entity)
public function __construct(EntityInterface $entity)
{ {
$this->entity = $entity;
} }
public function getEntity(): EntityInterface public function getEntity(): EntityInterface

View file

@ -14,12 +14,10 @@ class PageEditEvent extends Event
{ {
public const FORM_INIT_EVENT = 'page_edit_event.form_init'; public const FORM_INIT_EVENT = 'page_edit_event.form_init';
protected Page $page;
protected array $pageBuilderOptions = []; protected array $pageBuilderOptions = [];
public function __construct(Page $page) public function __construct(protected Page $page)
{ {
$this->page = $page;
} }
public function getPage() public function getPage()

View file

@ -14,11 +14,8 @@ class NavigationSettingEvent extends Event
public const INIT_EVENT = 'navigation_setting_event.init'; public const INIT_EVENT = 'navigation_setting_event.init';
public const FORM_INIT_EVENT = 'navigation_setting_event.form_init'; public const FORM_INIT_EVENT = 'navigation_setting_event.form_init';
protected $data; public function __construct(protected $data = null)
public function __construct($data = null)
{ {
$this->data = $data;
} }
public function getData() public function getData()

View file

@ -14,11 +14,8 @@ class SettingEvent extends Event
public const INIT_EVENT = 'setting_event.init'; public const INIT_EVENT = 'setting_event.init';
public const FORM_INIT_EVENT = 'setting_event.form_init'; public const FORM_INIT_EVENT = 'setting_event.form_init';
protected $data; public function __construct(protected $data = null)
public function __construct($data = null)
{ {
$this->data = $data;
} }
public function getData() public function getData()

View file

@ -16,15 +16,11 @@ class TaskRunRequestedEvent extends Event
{ {
public const RUN_REQUEST_EVENT = 'task_event.run_request'; public const RUN_REQUEST_EVENT = 'task_event.run_request';
protected string $task; public function __construct(
protected InputBag $parameters; protected string $task,
protected BufferedOutput $output; protected InputBag $parameters,
protected BufferedOutput $output
public function __construct(string $task, InputBag $parameters, BufferedOutput $output) ) {
{
$this->task = $task;
$this->parameters = $parameters;
$this->output = $output;
} }
public function getTask(): string public function getTask(): string

View file

@ -20,19 +20,13 @@ use Symfony\Component\HttpKernel\Event\ResponseEvent;
*/ */
class AbListener class AbListener
{ {
protected EventDispatcherInterface $eventDispatcher;
protected AbContainer $container;
protected SiteRequest $siteRequest;
protected ?Node $node; protected ?Node $node;
public function __construct( public function __construct(
AbContainer $container, protected AbContainer $container,
EventDispatcherInterface $eventDispatcher, protected EventDispatcherInterface $eventDispatcher,
SiteRequest $siteRequest protected SiteRequest $siteRequest
) { ) {
$this->eventDispatcher = $eventDispatcher;
$this->container = $container;
$this->siteRequest = $siteRequest;
} }
public function onKernelRequest(RequestEvent $event) public function onKernelRequest(RequestEvent $event)

View file

@ -23,30 +23,18 @@ use Symfony\Component\HttpKernel\Event\RequestEvent;
*/ */
class AnalyticListener class AnalyticListener
{ {
protected NodeRepository $nodeRepository;
protected ViewRepositoryQuery $viewRepositoryQuery;
protected ViewFactory $viewFactory;
protected RefererRepositoryQuery $refererRepositoryQuery;
protected RefererFactory $refererFactory;
protected EntityManager $manager;
protected DeviceDetector $deviceDetector; protected DeviceDetector $deviceDetector;
protected Request $request; protected Request $request;
protected Node $node; protected Node $node;
public function __construct( public function __construct(
NodeRepository $nodeRepository, protected NodeRepository $nodeRepository,
ViewRepositoryQuery $viewRepositoryQuery, protected ViewRepositoryQuery $viewRepositoryQuery,
ViewFactory $viewFactory, protected ViewFactory $viewFactory,
RefererRepositoryQuery $refererRepositoryQuery, protected RefererRepositoryQuery $refererRepositoryQuery,
RefererFactory $refererFactory, protected RefererFactory $refererFactory,
EntityManager $manager protected EntityManager $manager
) { ) {
$this->nodeRepository = $nodeRepository;
$this->viewRepositoryQuery = $viewRepositoryQuery;
$this->viewFactory = $viewFactory;
$this->refererRepositoryQuery = $refererRepositoryQuery;
$this->refererFactory = $refererFactory;
$this->manager = $manager;
$this->createDeviceDetector(); $this->createDeviceDetector();
} }

View file

@ -15,15 +15,11 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/ */
class RedirectListener class RedirectListener
{ {
protected RedirectMatcher $matcher; public function __construct(
protected RedirectBuilder $builder; protected RedirectMatcher $matcher,
protected RedirectRepositoryQuery $repository; protected RedirectBuilder $builder,
protected RedirectRepositoryQuery $repository
public function __construct(RedirectMatcher $matcher, RedirectBuilder $builder, RedirectRepositoryQuery $repository) ) {
{
$this->matcher = $matcher;
$this->builder = $builder;
$this->repository = $repository;
} }
public function onKernelException(ExceptionEvent $event) public function onKernelException(ExceptionEvent $event)

View file

@ -17,24 +17,13 @@ use Symfony\Contracts\Translation\TranslatorInterface;
*/ */
class PasswordRequestEventSubscriber implements EventSubscriberInterface class PasswordRequestEventSubscriber implements EventSubscriberInterface
{ {
protected MailNotifier $notifier;
protected UrlGeneratorInterface $urlGenerator;
protected EntityManager $entityManager;
protected TokenGeneratorInterface $tokenGenerator;
protected TranslatorInterface $translator;
public function __construct( public function __construct(
MailNotifier $notifier, protected MailNotifier $notifier,
UrlGeneratorInterface $urlGenerator, protected UrlGeneratorInterface $urlGenerator,
EntityManager $entityManager, protected EntityManager $entityManager,
TokenGeneratorInterface $tokenGenerator, protected TokenGeneratorInterface $tokenGenerator,
TranslatorInterface $translator protected TranslatorInterface $translator
) { ) {
$this->notifier = $notifier;
$this->urlGenerator = $urlGenerator;
$this->entityManager = $entityManager;
$this->tokenGenerator = $tokenGenerator;
$this->translator = $translator;
} }
public static function getSubscribedEvents() public static function getSubscribedEvents()

View file

@ -16,12 +16,12 @@ use Symfony\Component\Security\Core\Exception\AccessDeniedException;
*/ */
class RequestSecurityEventSubscriber implements EventSubscriberInterface class RequestSecurityEventSubscriber implements EventSubscriberInterface
{ {
protected NodeRepository $nodeRepository;
protected AuthorizationChecker $authorizationChecker; protected AuthorizationChecker $authorizationChecker;
public function __construct(NodeRepository $nodeRepository, ContainerInterface $container) public function __construct(
{ protected NodeRepository $nodeRepository,
$this->nodeRepository = $nodeRepository; ContainerInterface $container
) {
$this->authorizationChecker = $container->get('security.authorization_checker'); $this->authorizationChecker = $container->get('security.authorization_checker');
} }

View file

@ -11,11 +11,8 @@ use function Symfony\Component\String\u;
class ForcedDomainEventSubscriber implements EventSubscriberInterface class ForcedDomainEventSubscriber implements EventSubscriberInterface
{ {
protected SiteRequest $siteRequest; public function __construct(protected SiteRequest $siteRequest)
public function __construct(SiteRequest $siteRequest)
{ {
$this->siteRequest = $siteRequest;
} }
public function onKernelResponse(ResponseEvent $event) public function onKernelResponse(ResponseEvent $event)

View file

@ -20,27 +20,14 @@ use Symfony\Contracts\Translation\TranslatorInterface;
*/ */
class MenuEventSubscriber extends EntityManagerEventSubscriber class MenuEventSubscriber extends EntityManagerEventSubscriber
{ {
protected NodeFactory $nodeFactory;
protected NodeRepository $nodeRepository;
protected EntityManager $entityManager;
protected CodeSlugify $slugify;
protected SymfonyCacheManager $cacheManager;
protected TranslatorInterface $translation;
public function __construct( public function __construct(
NodeFactory $nodeFactory, protected NodeFactory $nodeFactory,
NodeRepository $nodeRepository, protected NodeRepository $nodeRepository,
EntityManager $entityManager, protected EntityManager $entityManager,
CodeSlugify $slugify, protected CodeSlugify $slugify,
SymfonyCacheManager $cacheManager, protected SymfonyCacheManager $cacheManager,
TranslatorInterface $translator protected TranslatorInterface $translator
) { ) {
$this->nodeFactory = $nodeFactory;
$this->nodeRepository = $nodeRepository;
$this->entityManager = $entityManager;
$this->slugify = $slugify;
$this->cacheManager = $cacheManager;
$this->translator = $translator;
} }
public function supports(EntityInterface $entity): bool public function supports(EntityInterface $entity): bool

View file

@ -17,11 +17,9 @@ use App\Core\Slugify\CodeSlugify;
class NavigationEventSubscriber extends EntityManagerEventSubscriber class NavigationEventSubscriber extends EntityManagerEventSubscriber
{ {
public function __construct( public function __construct(
EntityManager $entityManager, protected EntityManager $entityManager,
CodeSlugify $slugify protected CodeSlugify $slugify
) { ) {
$this->entityManager = $entityManager;
$this->slugify = $slugify;
} }
public function supports(EntityInterface $entity): bool public function supports(EntityInterface $entity): bool

View file

@ -12,7 +12,6 @@ use App\Core\Repository\Site\NodeRepository;
use App\Core\Slugify\CodeSlugify; use App\Core\Slugify\CodeSlugify;
use App\Core\Slugify\RouteParameterSlugify; use App\Core\Slugify\RouteParameterSlugify;
use App\Core\Slugify\Slugify; use App\Core\Slugify\Slugify;
use Symfony\Component\HttpKernel\KernelInterface;
use function Symfony\Component\String\u; use function Symfony\Component\String\u;
/** /**
@ -22,27 +21,14 @@ use function Symfony\Component\String\u;
*/ */
class NodeEventSubscriber extends EntityManagerEventSubscriber class NodeEventSubscriber extends EntityManagerEventSubscriber
{ {
protected NodeFactory $nodeFactory;
protected EntityManager $entityManager;
protected KernelInterface $kernel;
protected Slugify $slugify;
protected CodeSlugify $codeSlugify;
protected RouteParameterSlugify $routeParameterSlugify;
public function __construct( public function __construct(
NodeFactory $nodeFactory, protected NodeFactory $nodeFactory,
NodeRepository $nodeRepository, protected NodeRepository $nodeRepository,
EntityManager $entityManager, protected EntityManager $entityManager,
Slugify $slugify, protected Slugify $slugify,
CodeSlugify $codeSlugify, protected CodeSlugify $codeSlugify,
RouteParameterSlugify $routeParameterSlugify protected RouteParameterSlugify $routeParameterSlugify
) { ) {
$this->nodeFactory = $nodeFactory;
$this->nodeRepository = $nodeRepository;
$this->entityManager = $entityManager;
$this->slugify = $slugify;
$this->codeSlugify = $codeSlugify;
$this->routeParameterSlugify = $routeParameterSlugify;
} }
public function supports(EntityInterface $entity): bool public function supports(EntityInterface $entity): bool

View file

@ -17,11 +17,8 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
*/ */
class BlockEventSubscriber extends EntityManagerEventSubscriber class BlockEventSubscriber extends EntityManagerEventSubscriber
{ {
protected FileUploadHandler $fileUpload; public function __construct(protected FileUploadHandler $fileUpload)
public function __construct(FileUploadHandler $fileUpload)
{ {
$this->fileUpload = $fileUpload;
} }
public function supports(EntityInterface $entity): bool public function supports(EntityInterface $entity): bool

View file

@ -16,11 +16,8 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
*/ */
class PageEventSubscriber extends EntityManagerEventSubscriber class PageEventSubscriber extends EntityManagerEventSubscriber
{ {
protected FileUploadHandler $fileUpload; public function __construct(protected FileUploadHandler $fileUpload)
public function __construct(FileUploadHandler $fileUpload)
{ {
$this->fileUpload = $fileUpload;
} }
public function supports(EntityInterface $entity): bool public function supports(EntityInterface $entity): bool

View file

@ -18,13 +18,10 @@ use Symfony\Component\HttpKernel\KernelInterface;
*/ */
class SiteEventSubscriber extends EntityManagerEventSubscriber class SiteEventSubscriber extends EntityManagerEventSubscriber
{ {
protected KernelInterface $kernel; public function __construct(
protected SymfonyCacheManager $cacheManager; protected KernelInterface $kernel,
protected SymfonyCacheManager $cacheManager
public function __construct(KernelInterface $kernel, SymfonyCacheManager $cacheManager) ) {
{
$this->kernel = $kernel;
$this->cacheManager = $cacheManager;
} }
public function supports(EntityInterface $entity): bool public function supports(EntityInterface $entity): bool

View file

@ -13,11 +13,8 @@ use App\Core\Event\Task\TaskRunRequestedEvent;
*/ */
class CacheCleanTaskEventSubscriber extends TaskEventSubscriber class CacheCleanTaskEventSubscriber extends TaskEventSubscriber
{ {
protected SymfonyCacheManager $cacheManager; public function __construct(protected SymfonyCacheManager $cacheManager)
public function __construct(SymfonyCacheManager $cacheManager)
{ {
$this->cacheManager = $cacheManager;
} }
public function onInit(TaskInitEvent $event) public function onInit(TaskInitEvent $event)

View file

@ -23,22 +23,15 @@ class FsFileManager
protected string $path; protected string $path;
protected string $pathUri; protected string $pathUri;
protected array $pathLocked; protected array $pathLocked;
protected FileUploadHandler $uploadHandler;
protected FileInformationFactory $fileInformationFactory;
protected FileInformationRepositoryQuery $fileInformationRepositoryQuery;
public function __construct( public function __construct(
ParameterBagInterface $params, ParameterBagInterface $params,
FileUploadHandler $uploadHandler, protected FileUploadHandler $uploadHandler,
FileInformationFactory $fileInformationFactory, protected FileInformationFactory $fileInformationFactory,
FileInformationRepositoryQuery $fileInformationRepositoryQuery protected FileInformationRepositoryQuery $fileInformationRepositoryQuery
) { ) {
$config = $params->get('core')['file_manager']; $config = $params->get('core')['file_manager'];
$this->uploadHandler = $uploadHandler;
$this->fileInformationFactory = $fileInformationFactory;
$this->fileInformationRepositoryQuery = $fileInformationRepositoryQuery;
$this->mimes = $config['mimes']; $this->mimes = $config['mimes'];
$this->path = $config['path']; $this->path = $config['path'];
$this->pathUri = $this->normalizePath($config['path_uri']); $this->pathUri = $this->normalizePath($config['path_uri']);

View file

@ -4,7 +4,6 @@ namespace App\Core\Manager;
use App\Core\Entity\EntityInterface; use App\Core\Entity\EntityInterface;
use App\Core\Event\EntityManager\EntityManagerEvent; use App\Core\Event\EntityManager\EntityManagerEvent;
use Doctrine\ORM\EntityManager as DoctrineEntityManager;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@ -15,14 +14,10 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
*/ */
class EntityManager class EntityManager
{ {
protected EventDispatcherInterface $eventDispatcher; public function __construct(
protected EventDispatcherInterface $eventDispatcher,
protected DoctrineEntityManager $entityManager; protected EntityManagerInterface $entityManager
) {
public function __construct(EventDispatcherInterface $eventDispatcher, EntityManagerInterface $entityManager)
{
$this->eventDispatcher = $eventDispatcher;
$this->entityManager = $entityManager;
} }
public function create(EntityInterface $entity, bool $dispatchEvent = true, bool $flush = true): self public function create(EntityInterface $entity, bool $dispatchEvent = true, bool $flush = true): self

View file

@ -14,7 +14,6 @@ use Twig\Environment as TwigEnvironment;
*/ */
class MailNotifier class MailNotifier
{ {
protected MailerInterface $mailer;
protected array $attachments = []; protected array $attachments = [];
protected array $recipients = []; protected array $recipients = [];
protected array $bccRecipients = []; protected array $bccRecipients = [];
@ -22,10 +21,8 @@ class MailNotifier
protected ?string $from = null; protected ?string $from = null;
protected ?string $replyTo = null; protected ?string $replyTo = null;
public function __construct(TwigEnvironment $twig, MailerInterface $mailer) public function __construct(protected TwigEnvironment $twig, protected MailerInterface $mailer)
{ {
$this->mailer = $mailer;
$this->twig = $twig;
} }
public function setMailer(Swift_Mailer $mailer): self public function setMailer(Swift_Mailer $mailer): self

View file

@ -14,11 +14,8 @@ use Symfony\Component\HttpFoundation\Request;
*/ */
class RedirectBuilder class RedirectBuilder
{ {
protected UrlBuilder $urlBuilder; public function __construct(protected UrlBuilder $urlBuilder)
public function __construct(UrlBuilder $urlBuilder)
{ {
$this->urlBuilder = $urlBuilder;
} }
public function buildResponse(Redirect $redirect, Request $request): RedirectResponse public function buildResponse(Redirect $redirect, Request $request): RedirectResponse

View file

@ -15,10 +15,9 @@ use Symfony\Component\Routing\RouteCollection;
*/ */
class SiteRouteLoader extends Loader class SiteRouteLoader extends Loader
{ {
protected NavigationRepositoryQuery $navigationQuery;
protected $isLoaded = false; protected $isLoaded = false;
public function __construct(NavigationRepositoryQuery $navigationQuery) public function __construct(protected NavigationRepositoryQuery $navigationQuery)
{ {
$this->navigationQuery = $navigationQuery; $this->navigationQuery = $navigationQuery;
} }

View file

@ -16,21 +16,12 @@ use App\Core\Repository\Site\NavigationRepositoryQuery;
*/ */
class NavigationSettingManager class NavigationSettingManager
{ {
protected EntityManager $entityManager;
protected NavigationSettingRepositoryQuery $query;
protected NavigationRepositoryQuery $navigationQuery;
protected NavigationSettingFactory $factory;
public function __construct( public function __construct(
EntityManager $entityManager, protected EntityManager $entityManager,
NavigationSettingRepositoryQuery $query, protected NavigationSettingRepositoryQuery $query,
NavigationRepositoryQuery $navigationQuery, protected NavigationRepositoryQuery $navigationQuery,
NavigationSettingFactory $factory protected NavigationSettingFactory $factory
) { ) {
$this->entityManager = $entityManager;
$this->query = $query;
$this->navigationQuery = $navigationQuery;
$this->factory = $factory;
} }
public function init($navigation, string $code, string $section, string $label, $value = null) public function init($navigation, string $code, string $section, string $label, $value = null)

View file

@ -14,15 +14,11 @@ use App\Core\Repository\SettingRepositoryQuery;
*/ */
class SettingManager class SettingManager
{ {
protected EntityManager $entityManager; public function __construct(
protected SettingRepositoryQuery $query; protected EntityManager $entityManager,
protected SettingFactory $factory; protected SettingRepositoryQuery $query,
protected SettingFactory $factory
public function __construct(EntityManager $entityManager, SettingRepositoryQuery $query, SettingFactory $factory) ) {
{
$this->entityManager = $entityManager;
$this->query = $query;
$this->factory = $factory;
} }
public function init(string $code, string $section, string $label, $value = null) public function init(string $code, string $section, string $label, $value = null)

View file

@ -6,9 +6,7 @@ use App\Core\Entity\Site\Menu;
use App\Core\Entity\Site\Navigation; use App\Core\Entity\Site\Navigation;
use App\Core\Entity\Site\Node; use App\Core\Entity\Site\Node;
use App\Core\Entity\Site\Page\Page; use App\Core\Entity\Site\Page\Page;
use App\Core\Repository\Site\NavigationRepositoryQuery;
use App\Core\Repository\Site\NodeRepository; use App\Core\Repository\Site\NodeRepository;
use App\Core\Repository\Site\Page\PageRepositoryQuery;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
/** /**
@ -18,15 +16,10 @@ use Symfony\Component\HttpFoundation\RequestStack;
*/ */
class SiteRequest class SiteRequest
{ {
protected RequestStack $requestStack; public function __construct(
protected NodeRepository $nodeRepository; protected RequestStack $requestStack,
protected NavigationRepositoryQuery $navigationRepositoryQuery; protected NodeRepository $nodeRepository
protected PageRepositoryQuery $pageRepositoryQuery; ) {
public function __construct(RequestStack $requestStack, NodeRepository $nodeRepository)
{
$this->requestStack = $requestStack;
$this->nodeRepository = $nodeRepository;
} }
public function getNode(): ?Node public function getNode(): ?Node

View file

@ -13,13 +13,10 @@ use App\Core\Repository\Site\NavigationRepositoryQuery;
*/ */
class SiteStore class SiteStore
{ {
protected NavigationRepositoryQuery $navigationRepositoryQuery; public function __construct(
protected SiteRequest $siteRequest; protected NavigationRepositoryQuery $navigationRepositoryQuery,
protected SiteRequest $siteRequest
public function __construct(NavigationRepositoryQuery $navigationRepositoryQuery, SiteRequest $siteRequest) ) {
{
$this->navigationRepositoryQuery = $navigationRepositoryQuery;
$this->siteRequest = $siteRequest;
} }
public function getNavigations(): array public function getNavigations(): array

View file

@ -17,15 +17,11 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
*/ */
class SitemapBuilder class SitemapBuilder
{ {
protected Reader $annotationReader; public function __construct(
protected ContainerInterface $container; protected Reader $annotationReader,
protected UrlGeneratorInterface $urlGenerator; protected ContainerInterface $container,
protected UrlGeneratorInterface $urlGenerator
public function __construct(Reader $annotationReader, ContainerInterface $container, UrlGeneratorInterface $urlGenerator) ) {
{
$this->annotationReader = $annotationReader;
$this->container = $container;
$this->urlGenerator = $urlGenerator;
} }
public function build(Navigation $navigation, ?string $currentDomain): array public function build(Navigation $navigation, ?string $currentDomain): array

View file

@ -2,7 +2,6 @@
namespace App\Core\String; namespace App\Core\String;
use App\Core\FileManager\FsFileManager;
use App\Core\Repository\FileInformationRepositoryQuery; use App\Core\Repository\FileInformationRepositoryQuery;
/** /**
@ -12,13 +11,9 @@ use App\Core\Repository\FileInformationRepositoryQuery;
*/ */
class FileInformationBuilder class FileInformationBuilder
{ {
protected FsFileManager $fsManager; public function __construct(
protected FileInformationRepositoryQuery $query; protected FileInformationRepositoryQuery $query
) {
public function __construct(FsFileManager $fsManager, FileInformationRepositoryQuery $query)
{
$this->fsManager = $fsManager;
$this->query = $query;
} }
public function replaceTags(string $value) public function replaceTags(string $value)

View file

@ -12,13 +12,10 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
*/ */
class UrlBuilder class UrlBuilder
{ {
protected UrlGeneratorInterface $urlGenerator; public function __construct(
protected SiteRequest $siteRequest; protected UrlGeneratorInterface $urlGenerator,
protected SiteRequest $siteRequest
public function __construct(UrlGeneratorInterface $urlGenerator, SiteRequest $siteRequest) ) {
{
$this->urlGenerator = $urlGenerator;
$this->siteRequest = $siteRequest;
} }
public function replaceTags(string $value): string public function replaceTags(string $value): string

View file

@ -9,11 +9,8 @@ use Twig\TwigFunction;
class AbTestExtension extends AbstractExtension class AbTestExtension extends AbstractExtension
{ {
protected AbContainer $container; public function __construct(protected AbContainer $container)
public function __construct(AbContainer $container)
{ {
$this->container = $container;
} }
public function getFunctions(): array public function getFunctions(): array

View file

@ -12,15 +12,12 @@ use Twig\TwigFunction;
class CrudExtension extends AbstractExtension class CrudExtension extends AbstractExtension
{ {
protected PropertyAccessor $propertyAccessor; protected PropertyAccessor $propertyAccessor;
protected Environment $twig;
public function __construct(Environment $twig) public function __construct(protected Environment $twig)
{ {
$this->propertyAccessor = PropertyAccess::createPropertyAccessorBuilder() $this->propertyAccessor = PropertyAccess::createPropertyAccessorBuilder()
->getPropertyAccessor() ->getPropertyAccessor()
; ;
$this->twig = $twig;
} }
/** /**

View file

@ -9,7 +9,6 @@ use Twig\TwigFilter;
class EditorJsExtension extends AbstractExtension class EditorJsExtension extends AbstractExtension
{ {
protected Environment $twig;
protected array $views = []; protected array $views = [];
protected array $defaultAllowedBlocks = [ protected array $defaultAllowedBlocks = [
'paragraph', 'paragraph',
@ -27,9 +26,8 @@ class EditorJsExtension extends AbstractExtension
'link', 'link',
]; ];
public function __construct(Environment $twig, ParameterBagInterface $params) public function __construct(protected Environment $twig, ParameterBagInterface $params)
{ {
$this->twig = $twig;
$blocks = $params->get('core')['editor_js']['blocks'] ?? []; $blocks = $params->get('core')['editor_js']['blocks'] ?? [];
foreach ($blocks as $block => $view) { foreach ($blocks as $block => $view) {

View file

@ -14,9 +14,8 @@ class EntityExtension extends AbstractExtension
{ {
protected PropertyAccessor $propertyAccessor; protected PropertyAccessor $propertyAccessor;
public function __construct(EntityManagerInterface $entityManager) public function __construct(protected EntityManagerInterface $entityManager)
{ {
$this->entityManager = $entityManager;
$this->propertyAccessor = PropertyAccess::createPropertyAccessorBuilder() $this->propertyAccessor = PropertyAccess::createPropertyAccessorBuilder()
->disableExceptionOnInvalidPropertyPath() ->disableExceptionOnInvalidPropertyPath()
->getPropertyAccessor() ->getPropertyAccessor()

View file

@ -11,16 +11,11 @@ use Twig\TwigFilter;
class FileInformationExtension extends AbstractExtension class FileInformationExtension extends AbstractExtension
{ {
protected FileInformationBuilder $fileInfoBuilder;
public function __construct( public function __construct(
FileInformationBuilder $fileInfoBuilder, protected FileInformationBuilder $fileInfoBuilder,
FsFileManager $fsManager, protected FsFileManager $fsManager,
FileInformationRepositoryQuery $query protected FileInformationRepositoryQuery $query
) { ) {
$this->fileInfoBuilder = $fileInfoBuilder;
$this->fsManager = $fsManager;
$this->query = $query;
} }
/** /**

View file

@ -14,13 +14,10 @@ use Twig\TwigFunction;
class RoutingExtension extends AbstractExtension class RoutingExtension extends AbstractExtension
{ {
protected UrlGeneratorInterface $generator; public function __construct(
protected SiteRequest $siteRequest; protected UrlGeneratorInterface $generator,
protected SiteRequest $siteRequest
public function __construct(UrlGeneratorInterface $generator, SiteRequest $siteRequest) ) {
{
$this->generator = $generator;
$this->siteRequest = $siteRequest;
} }
/** /**

View file

@ -9,13 +9,10 @@ use Twig\TwigFunction;
class SettingExtension extends AbstractExtension class SettingExtension extends AbstractExtension
{ {
private SettingManager $settingManager; public function __construct(
private NavigationSettingManager $navigationSettingManager; protected SettingManager $settingManager,
protected NavigationSettingManager $navigationSettingManager
public function __construct(SettingManager $settingManager, NavigationSettingManager $navigationSettingManager) ) {
{
$this->settingManager = $settingManager;
$this->navigationSettingManager = $navigationSettingManager;
} }
/** /**

View file

@ -8,11 +8,8 @@ use Twig\TwigFilter;
class StringExtension extends AbstractExtension class StringExtension extends AbstractExtension
{ {
protected StringBuilder $stringBuilder; public function __construct(protected StringBuilder $stringBuilder)
public function __construct(StringBuilder $stringBuilder)
{ {
$this->stringBuilder = $stringBuilder;
} }
/** /**

View file

@ -8,11 +8,8 @@ use Twig\TwigFilter;
class UrlExtension extends AbstractExtension class UrlExtension extends AbstractExtension
{ {
protected UrlBuilder $urlBuilder; public function __construct(protected UrlBuilder $urlBuilder)
public function __construct(UrlBuilder $urlBuilder)
{ {
$this->urlBuilder = $urlBuilder;
} }
/** /**