From f0530c5b1283d361408a17a712e9a178cb45b70c Mon Sep 17 00:00:00 2001 From: Philipp Kitzberger Date: Mon, 17 Feb 2025 15:06:27 +0100 Subject: [PATCH 1/2] [BUGFIX] Deprecation notices Implicitly marking parameter as nullable is deprecated, the explicit nullable type must be used instead --- Classes/Command/DeleteCommand.php | 2 +- Classes/Command/ResetCommand.php | 2 +- Classes/Repository/FileRepository.php | 6 +++--- Classes/Resource/Handler/DomainResource.php | 6 +++--- Classes/Resource/RemoteResourceCollection.php | 2 +- Classes/Resource/RemoteResourceInterface.php | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Classes/Command/DeleteCommand.php b/Classes/Command/DeleteCommand.php index ad9d7da..3be5a97 100644 --- a/Classes/Command/DeleteCommand.php +++ b/Classes/Command/DeleteCommand.php @@ -17,7 +17,7 @@ class DeleteCommand extends AbstractCommand protected LanguageService $languageService; - public function __construct(string $name = null, FileRepository $fileRepository = null, $languageService = null) + public function __construct(?string $name = null, ?FileRepository $fileRepository = null, $languageService = null) { parent::__construct($name); diff --git a/Classes/Command/ResetCommand.php b/Classes/Command/ResetCommand.php index d54ef9a..9bee042 100644 --- a/Classes/Command/ResetCommand.php +++ b/Classes/Command/ResetCommand.php @@ -20,7 +20,7 @@ class ResetCommand extends AbstractCommand protected FileRepository $fileRepository; - public function __construct(string $name = null, Connection $connection = null, FileRepository $fileRepository = null) + public function __construct(?string $name = null, ?Connection $connection = null, ?FileRepository $fileRepository = null) { parent::__construct($name); diff --git a/Classes/Repository/FileRepository.php b/Classes/Repository/FileRepository.php index 25dd2ad..525a47e 100644 --- a/Classes/Repository/FileRepository.php +++ b/Classes/Repository/FileRepository.php @@ -34,9 +34,9 @@ class FileRepository protected ResourceFactory $resourceFactory; public function __construct( - Connection $connection = null, - ProcessedFileRepository $processedFileRepository = null, - ResourceFactory $resourceFactory = null + ?Connection $connection = null, + ?ProcessedFileRepository $processedFileRepository = null, + ?ResourceFactory $resourceFactory = null ) { $this->connection = $connection ?: GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('sys_file'); $this->processedFileRepository = $processedFileRepository ?: GeneralUtility::makeInstance(ProcessedFileRepository::class); diff --git a/Classes/Resource/Handler/DomainResource.php b/Classes/Resource/Handler/DomainResource.php index d0071e6..aa83ea3 100644 --- a/Classes/Resource/Handler/DomainResource.php +++ b/Classes/Resource/Handler/DomainResource.php @@ -35,7 +35,7 @@ class DomainResource implements RemoteResourceInterface * @param string $configuration * @param ?RequestFactory $requestFactory */ - public function __construct($configuration, RequestFactory $requestFactory = null) + public function __construct($configuration, ?RequestFactory $requestFactory = null) { $this->requestFactory = $requestFactory ?: GeneralUtility::makeInstance(RequestFactory::class); $urlParts = parse_url((string)$configuration); @@ -49,7 +49,7 @@ public function __construct($configuration, RequestFactory $requestFactory = nul * @param FileInterface|null $fileObject * @return bool */ - public function hasFile($fileIdentifier, $filePath, FileInterface $fileObject = null) + public function hasFile($fileIdentifier, $filePath, ?FileInterface $fileObject = null) { try { $response = $this->requestFactory->request($this->url . ltrim($filePath, '/'), 'HEAD'); @@ -66,7 +66,7 @@ public function hasFile($fileIdentifier, $filePath, FileInterface $fileObject = * @param FileInterface|null $fileObject * @return resource|string */ - public function getFile($fileIdentifier, $filePath, FileInterface $fileObject = null) + public function getFile($fileIdentifier, $filePath, ?FileInterface $fileObject = null) { try { $fileName = $this->url . ltrim($filePath, '/'); diff --git a/Classes/Resource/RemoteResourceCollection.php b/Classes/Resource/RemoteResourceCollection.php index fad7bf8..9406cbd 100644 --- a/Classes/Resource/RemoteResourceCollection.php +++ b/Classes/Resource/RemoteResourceCollection.php @@ -62,7 +62,7 @@ class RemoteResourceCollection implements LoggerAwareInterface * @param ResourceFactory|null $resourceFactory * @param FileRepository|null $fileRepository */ - public function __construct(array $resources, ResourceFactory $resourceFactory = null, FileRepository $fileRepository = null) + public function __construct(array $resources, ?ResourceFactory $resourceFactory = null, ?FileRepository $fileRepository = null) { $this->resources = $resources; $this->resourceFactory = $resourceFactory ?: GeneralUtility::makeInstance(ResourceFactory::class); diff --git a/Classes/Resource/RemoteResourceInterface.php b/Classes/Resource/RemoteResourceInterface.php index 846cec2..a9427f1 100644 --- a/Classes/Resource/RemoteResourceInterface.php +++ b/Classes/Resource/RemoteResourceInterface.php @@ -27,7 +27,7 @@ interface RemoteResourceInterface * @param FileInterface|null $fileObject * @return bool */ - public function hasFile($fileIdentifier, $filePath, FileInterface $fileObject = null); + public function hasFile($fileIdentifier, $filePath, ?FileInterface $fileObject = null); /** * @param string $fileIdentifier @@ -35,5 +35,5 @@ public function hasFile($fileIdentifier, $filePath, FileInterface $fileObject = * @param FileInterface|null $fileObject * @return resource|string */ - public function getFile($fileIdentifier, $filePath, FileInterface $fileObject = null); + public function getFile($fileIdentifier, $filePath, ?FileInterface $fileObject = null); } From 7be31ffef2c0747d846b0f2db93e85ea9ef23d38 Mon Sep 17 00:00:00 2001 From: Philipp Kitzberger Date: Mon, 17 Feb 2025 15:33:37 +0100 Subject: [PATCH 2/2] [BUGFIX] LanguageService cannot be injected in v13 --- Classes/Form/Element/ShowDeleteFiles.php | 8 +++++++- Classes/Form/Element/ShowMissingFiles.php | 8 +++++++- Configuration/Services.yaml | 3 +++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Classes/Form/Element/ShowDeleteFiles.php b/Classes/Form/Element/ShowDeleteFiles.php index ffee4d5..3659918 100644 --- a/Classes/Form/Element/ShowDeleteFiles.php +++ b/Classes/Form/Element/ShowDeleteFiles.php @@ -18,14 +18,19 @@ */ use IchHabRecht\Filefill\Repository\FileRepository; +use Symfony\Component\DependencyInjection\Attribute\Autoconfigure; use TYPO3\CMS\Backend\Form\Element\AbstractFormElement; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Imaging\IconSize; use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; +#[Autoconfigure(public: true)] class ShowDeleteFiles extends AbstractFormElement { + protected LanguageService $languageService; + /** * Container objects give $nodeFactory down to other containers. * @@ -34,8 +39,9 @@ class ShowDeleteFiles extends AbstractFormElement */ public function __construct( protected readonly FileRepository $fileRepository, - protected readonly LanguageService $languageService + protected readonly LanguageServiceFactory $languageServiceFactory ) { + $this->languageService = $this->languageServiceFactory->createFromUserPreferences($GLOBALS['BE_USER']); } /** diff --git a/Classes/Form/Element/ShowMissingFiles.php b/Classes/Form/Element/ShowMissingFiles.php index ee53b48..9f31016 100644 --- a/Classes/Form/Element/ShowMissingFiles.php +++ b/Classes/Form/Element/ShowMissingFiles.php @@ -18,23 +18,29 @@ */ use Doctrine\DBAL\ParameterType; +use Symfony\Component\DependencyInjection\Attribute\Autoconfigure; use TYPO3\CMS\Backend\Form\Element\AbstractFormElement; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Imaging\IconSize; use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; +#[Autoconfigure(public: true)] class ShowMissingFiles extends AbstractFormElement { + protected LanguageService $languageService; + /** * Container objects give $nodeFactory down to other containers. * * @param LanguageService|null $languageService * @throws \InvalidArgumentException */ - public function __construct(protected readonly LanguageService $languageService) + public function __construct(protected readonly LanguageServiceFactory $languageServiceFactory) { + $this->languageService = $this->languageServiceFactory->createFromUserPreferences($GLOBALS['BE_USER']); } /** diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 2cd62e6..c8e59a7 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -4,6 +4,9 @@ services: autoconfigure: true public: false + IchHabRecht\Filefill\: + resource: '../Classes/*' + IchHabRecht\Filefill\EventListener\ResourceStorageInitializationEventListener: tags: - name: psr.logger_aware