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
{
protected $results;
protected string $name;
protected array $variations = [];
protected array $probabilities = [];
protected int $duration = 3600 * 24;
public function __construct(string $name)
public function __construct(protected string $name)
{
$this->name = $name;
}
public function getName(): string

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -14,11 +14,8 @@ class PasswordRequestEvent extends Event
{
public const EVENT = 'account_event.password_request';
protected User $user;
public function __construct(User $user)
public function __construct(protected User $user)
{
$this->user = $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_DELETE_EVENT = 'entity_manager_event.pre_delete';
protected EntityInterface $entity;
public function __construct(EntityInterface $entity)
public function __construct(protected EntityInterface $entity)
{
$this->entity = $entity;
}
public function getEntity(): EntityInterface

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -20,27 +20,14 @@ use Symfony\Contracts\Translation\TranslatorInterface;
*/
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(
NodeFactory $nodeFactory,
NodeRepository $nodeRepository,
EntityManager $entityManager,
CodeSlugify $slugify,
SymfonyCacheManager $cacheManager,
TranslatorInterface $translator
protected NodeFactory $nodeFactory,
protected NodeRepository $nodeRepository,
protected EntityManager $entityManager,
protected CodeSlugify $slugify,
protected SymfonyCacheManager $cacheManager,
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

View file

@ -17,11 +17,9 @@ use App\Core\Slugify\CodeSlugify;
class NavigationEventSubscriber extends EntityManagerEventSubscriber
{
public function __construct(
EntityManager $entityManager,
CodeSlugify $slugify
protected EntityManager $entityManager,
protected CodeSlugify $slugify
) {
$this->entityManager = $entityManager;
$this->slugify = $slugify;
}
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\RouteParameterSlugify;
use App\Core\Slugify\Slugify;
use Symfony\Component\HttpKernel\KernelInterface;
use function Symfony\Component\String\u;
/**
@ -22,27 +21,14 @@ use function Symfony\Component\String\u;
*/
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(
NodeFactory $nodeFactory,
NodeRepository $nodeRepository,
EntityManager $entityManager,
Slugify $slugify,
CodeSlugify $codeSlugify,
RouteParameterSlugify $routeParameterSlugify
protected NodeFactory $nodeFactory,
protected NodeRepository $nodeRepository,
protected EntityManager $entityManager,
protected Slugify $slugify,
protected CodeSlugify $codeSlugify,
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

View file

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

View file

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

View file

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

View file

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

View file

@ -23,22 +23,15 @@ class FsFileManager
protected string $path;
protected string $pathUri;
protected array $pathLocked;
protected FileUploadHandler $uploadHandler;
protected FileInformationFactory $fileInformationFactory;
protected FileInformationRepositoryQuery $fileInformationRepositoryQuery;
public function __construct(
ParameterBagInterface $params,
FileUploadHandler $uploadHandler,
FileInformationFactory $fileInformationFactory,
FileInformationRepositoryQuery $fileInformationRepositoryQuery
protected FileUploadHandler $uploadHandler,
protected FileInformationFactory $fileInformationFactory,
protected FileInformationRepositoryQuery $fileInformationRepositoryQuery
) {
$config = $params->get('core')['file_manager'];
$this->uploadHandler = $uploadHandler;
$this->fileInformationFactory = $fileInformationFactory;
$this->fileInformationRepositoryQuery = $fileInformationRepositoryQuery;
$this->mimes = $config['mimes'];
$this->path = $config['path'];
$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\Event\EntityManager\EntityManagerEvent;
use Doctrine\ORM\EntityManager as DoctrineEntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@ -15,14 +14,10 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
*/
class EntityManager
{
protected EventDispatcherInterface $eventDispatcher;
protected DoctrineEntityManager $entityManager;
public function __construct(EventDispatcherInterface $eventDispatcher, EntityManagerInterface $entityManager)
{
$this->eventDispatcher = $eventDispatcher;
$this->entityManager = $entityManager;
public function __construct(
protected EventDispatcherInterface $eventDispatcher,
protected EntityManagerInterface $entityManager
) {
}
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
{
protected MailerInterface $mailer;
protected array $attachments = [];
protected array $recipients = [];
protected array $bccRecipients = [];
@ -22,10 +21,8 @@ class MailNotifier
protected ?string $from = 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

View file

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

View file

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

View file

@ -16,21 +16,12 @@ use App\Core\Repository\Site\NavigationRepositoryQuery;
*/
class NavigationSettingManager
{
protected EntityManager $entityManager;
protected NavigationSettingRepositoryQuery $query;
protected NavigationRepositoryQuery $navigationQuery;
protected NavigationSettingFactory $factory;
public function __construct(
EntityManager $entityManager,
NavigationSettingRepositoryQuery $query,
NavigationRepositoryQuery $navigationQuery,
NavigationSettingFactory $factory
protected EntityManager $entityManager,
protected NavigationSettingRepositoryQuery $query,
protected NavigationRepositoryQuery $navigationQuery,
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)

View file

@ -14,15 +14,11 @@ use App\Core\Repository\SettingRepositoryQuery;
*/
class SettingManager
{
protected EntityManager $entityManager;
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 __construct(
protected EntityManager $entityManager,
protected SettingRepositoryQuery $query,
protected SettingFactory $factory
) {
}
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\Node;
use App\Core\Entity\Site\Page\Page;
use App\Core\Repository\Site\NavigationRepositoryQuery;
use App\Core\Repository\Site\NodeRepository;
use App\Core\Repository\Site\Page\PageRepositoryQuery;
use Symfony\Component\HttpFoundation\RequestStack;
/**
@ -18,15 +16,10 @@ use Symfony\Component\HttpFoundation\RequestStack;
*/
class SiteRequest
{
protected RequestStack $requestStack;
protected NodeRepository $nodeRepository;
protected NavigationRepositoryQuery $navigationRepositoryQuery;
protected PageRepositoryQuery $pageRepositoryQuery;
public function __construct(RequestStack $requestStack, NodeRepository $nodeRepository)
{
$this->requestStack = $requestStack;
$this->nodeRepository = $nodeRepository;
public function __construct(
protected RequestStack $requestStack,
protected NodeRepository $nodeRepository
) {
}
public function getNode(): ?Node

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -9,7 +9,6 @@ use Twig\TwigFilter;
class EditorJsExtension extends AbstractExtension
{
protected Environment $twig;
protected array $views = [];
protected array $defaultAllowedBlocks = [
'paragraph',
@ -27,9 +26,8 @@ class EditorJsExtension extends AbstractExtension
'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'] ?? [];
foreach ($blocks as $block => $view) {

View file

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

View file

@ -11,16 +11,11 @@ use Twig\TwigFilter;
class FileInformationExtension extends AbstractExtension
{
protected FileInformationBuilder $fileInfoBuilder;
public function __construct(
FileInformationBuilder $fileInfoBuilder,
FsFileManager $fsManager,
FileInformationRepositoryQuery $query
protected FileInformationBuilder $fileInfoBuilder,
protected FsFileManager $fsManager,
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
{
protected UrlGeneratorInterface $generator;
protected SiteRequest $siteRequest;
public function __construct(UrlGeneratorInterface $generator, SiteRequest $siteRequest)
{
$this->generator = $generator;
$this->siteRequest = $siteRequest;
public function __construct(
protected UrlGeneratorInterface $generator,
protected SiteRequest $siteRequest
) {
}
/**

View file

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

View file

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

View file

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