diff --git a/Classes/Controller/BrokenLinkListController.php b/Classes/Controller/BrokenLinkListController.php index c60170a68..5662271d5 100644 --- a/Classes/Controller/BrokenLinkListController.php +++ b/Classes/Controller/BrokenLinkListController.php @@ -205,29 +205,25 @@ class BrokenLinkListController extends AbstractBrofixController protected bool $backendUserHasPermissionsForExcludes = false; public function __construct( - PagesRepository $pagesRepository = null, - BrokenLinkRepository $brokenLinkRepository = null, - ExcludeLinkTarget $excludeLinkTarget = null, - FlashMessageService $flashMessageService = null, + PagesRepository $pagesRepository, + BrokenLinkRepository $brokenLinkRepository, + ExcludeLinkTarget $excludeLinkTarget, + FlashMessageService $flashMessageService, ModuleTemplateFactory $moduleTemplateFactory, - IconFactory $iconFactory = null, - ExtensionConfiguration $extensionConfiguration = null, - PageRenderer $pageRenderer = null + IconFactory $iconFactory, + ExtensionConfiguration $extensionConfiguration, + PageRenderer $pageRenderer ) { - $this->pageRenderer = $pageRenderer ?: GeneralUtility::makeInstance(PageRenderer::class); - $iconFactory = $iconFactory ?: GeneralUtility::makeInstance(IconFactory::class); - $excludeLinkTarget = $excludeLinkTarget ?: GeneralUtility::makeInstance(ExcludeLinkTarget::class); + $this->pageRenderer = $pageRenderer; + $iconFactory = $iconFactory; + $excludeLinkTarget = $excludeLinkTarget; $moduleTemplateFactory = $moduleTemplateFactory; - $this->brokenLinkRepository = $brokenLinkRepository ?: GeneralUtility::makeInstance(BrokenLinkRepository::class); - $this->pagesRepository = $pagesRepository ?: GeneralUtility::makeInstance(PagesRepository::class); - $flashMessageService = $flashMessageService ?: GeneralUtility::makeInstance(FlashMessageService::class); + $this->brokenLinkRepository = $brokenLinkRepository; + $this->pagesRepository = $pagesRepository; + $this->defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier(); $this->orderBy = BrokenLinkListController::DEFAULT_ORDER_BY; - // configuration / extension configuration - if (!$extensionConfiguration) { - $extensionConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class); - } $extConfArray = $extensionConfiguration->get('brofix') ?: []; $configuration = GeneralUtility::makeInstance(Configuration::class, $extConfArray); diff --git a/Classes/Controller/ManageExclusionsController.php b/Classes/Controller/ManageExclusionsController.php index e35834e23..2aaec9f05 100644 --- a/Classes/Controller/ManageExclusionsController.php +++ b/Classes/Controller/ManageExclusionsController.php @@ -91,27 +91,26 @@ class ManageExclusionsController extends AbstractBrofixController protected bool $backendUserHasPermissions = false; public function __construct( - ExcludeLinkTargetRepository $excludeLinkTargetRepository = null, - ManageExclusionsFilter $filter = null, - ExtensionConfiguration $extensionConfiguration = null, + ExcludeLinkTargetRepository $excludeLinkTargetRepository, + ManageExclusionsFilter $filter, + ExtensionConfiguration $extensionConfiguration, ModuleTemplateFactory $moduleTemplateFactory, - IconFactory $iconFactory = null, - ExcludeLinkTarget $excludeLinkTarget = null, - CharsetConverter $charsetConverter = null, - LocalizationUtility $localizationUtility = null, - PageRenderer $pageRenderer = null + IconFactory $iconFactory, + ExcludeLinkTarget $excludeLinkTarget, + CharsetConverter $charsetConverter, + LocalizationUtility $localizationUtility, + PageRenderer $pageRenderer ) { - $this->pageRenderer = $pageRenderer ?: GeneralUtility::makeInstance(PageRenderer::class); - $iconFactory = $iconFactory ?: GeneralUtility::makeInstance(IconFactory::class); + $this->pageRenderer = $pageRenderer; + $iconFactory = $iconFactory; $moduleTemplateFactory = $moduleTemplateFactory; - $excludeLinkTarget = $excludeLinkTarget ?: GeneralUtility::makeInstance(ExcludeLinkTarget::class); - $this->excludeLinkTargetRepository = $excludeLinkTargetRepository ?: GeneralUtility::makeInstance(ExcludeLinkTargetRepository::class); - $this->filter = $filter ?: GeneralUtility::makeInstance(ManageExclusionsFilter::class); - $this->charsetConverter = $charsetConverter ?? GeneralUtility::makeInstance(CharsetConverter::class); - $this->localizationUtility = $localizationUtility ?? GeneralUtility::makeInstance(LocalizationUtility::class); - $this->orderBy = ManageExclusionsController::ORDER_BY_DEFAULT; + $excludeLinkTarget = $excludeLinkTarget; + $this->excludeLinkTargetRepository = $excludeLinkTargetRepository; + $this->filter = $filter; + $this->charsetConverter = $charsetConverter; + $this->localizationUtility = $localizationUtility; - $extensionConfiguration = $extensionConfiguration ?: GeneralUtility::makeInstance(ExtensionConfiguration::class); + $this->orderBy = ManageExclusionsController::ORDER_BY_DEFAULT; $extConfArray = $extensionConfiguration->get('brofix') ?: []; $configuration = GeneralUtility::makeInstance(Configuration::class, $extConfArray); diff --git a/Classes/Exceptions/MissingConfigurationException.php b/Classes/Exceptions/MissingConfigurationException.php index cf1b0a8aa..7030ca579 100644 --- a/Classes/Exceptions/MissingConfigurationException.php +++ b/Classes/Exceptions/MissingConfigurationException.php @@ -3,22 +3,9 @@ declare(strict_types=1); namespace Sypets\Brofix\Exceptions; -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ - class MissingConfigurationException extends \Exception { - public function __construct(string $message = '', int $code = 0, \Throwable $previous = null) + public function __construct(string $message = '', int $code = 0, ?\Throwable $previous = null) { if ($message === '') { $message = 'Missing configuration'; diff --git a/Classes/Linktype/AbstractLinktype.php b/Classes/Linktype/AbstractLinktype.php index d188b0c8a..3a7ab0348 100644 --- a/Classes/Linktype/AbstractLinktype.php +++ b/Classes/Linktype/AbstractLinktype.php @@ -98,10 +98,10 @@ public function getBrokenUrl(array $row): string * Text to be displayed with the Link as anchor text * (not the real anchor text of the Link. * @param mixed[] $row - * @param mixed[] $additionalConfig + * @param array|null $additionalConfig * @return string */ - public function getBrokenLinkText(array $row, array $additionalConfig = null): string + public function getBrokenLinkText(array $row, ?array $additionalConfig = null): string { return $row['url']; } diff --git a/Classes/Linktype/ExternalLinktype.php b/Classes/Linktype/ExternalLinktype.php index 7e92a76c8..2f0b48408 100644 --- a/Classes/Linktype/ExternalLinktype.php +++ b/Classes/Linktype/ExternalLinktype.php @@ -77,15 +77,15 @@ class ExternalLinktype extends AbstractLinktype implements LoggerAwareInterface protected $crawlDelay; public function __construct( - RequestFactory $requestFactory = null, - ExcludeLinkTarget $excludeLinkTarget = null, - LinkTargetCacheInterface $linkTargetCache = null, - CrawlDelay $crawlDelay = null + RequestFactory $requestFactory, + ExcludeLinkTarget $excludeLinkTarget, + LinkTargetCacheInterface $linkTargetCache, + CrawlDelay $crawlDelay ) { - $this->requestFactory = $requestFactory ?: GeneralUtility::makeInstance(RequestFactory::class); - $this->excludeLinkTarget = $excludeLinkTarget ?: GeneralUtility::makeInstance(ExcludeLinkTarget::class); - $this->linkTargetCache = $linkTargetCache ?: GeneralUtility::makeInstance(LinkTargetPersistentCache::class); - $this->crawlDelay = $crawlDelay ?: GeneralUtility::makeInstance(CrawlDelay::class); + $this->requestFactory = $requestFactory; + $this->excludeLinkTarget = $excludeLinkTarget; + $this->linkTargetCache = $linkTargetCache; + $this->crawlDelay = $crawlDelay; } public function setConfiguration(Configuration $configuration): void diff --git a/Classes/Linktype/FileLinktype.php b/Classes/Linktype/FileLinktype.php index 26cd3b1ea..81c495ab8 100644 --- a/Classes/Linktype/FileLinktype.php +++ b/Classes/Linktype/FileLinktype.php @@ -95,10 +95,10 @@ public function getBrokenUrl(array $row): string * Text to be displayed with the Link as anchor text * (not the real anchor text of the Link. * @param mixed[] $row - * @param mixed[] $additionalConfig + * @param array|null $additionalConfig * @return string */ - public function getBrokenLinkText(array $row, array $additionalConfig = null): string + public function getBrokenLinkText(array $row, ?array $additionalConfig = null): string { return $this->getLanguageService()->sL('LLL:EXT:brofix/Resources/Private/Language/Module/locallang.xlf:list.report.url.file'); } diff --git a/Classes/Linktype/InternalLinktype.php b/Classes/Linktype/InternalLinktype.php index 7aecd06a3..8b93e7464 100644 --- a/Classes/Linktype/InternalLinktype.php +++ b/Classes/Linktype/InternalLinktype.php @@ -390,9 +390,10 @@ public function getBrokenUrl(array $row): string * Text to be displayed with the Link as anchor text * (not the real anchor text of the Link. * @param mixed[] $row + * @param array|null $additionalConfig * @return string */ - public function getBrokenLinkText(array $row, array $additionalConfig = null): string + public function getBrokenLinkText(array $row, ?array $additionalConfig = null): string { $pageTitle = $additionalConfig['page']['title'] ?? ''; $contentTitle = $additionalConfig['content']['title'] ?? ''; diff --git a/Classes/Linktype/LinktypeInterface.php b/Classes/Linktype/LinktypeInterface.php index 11b8ad443..5c35c053a 100644 --- a/Classes/Linktype/LinktypeInterface.php +++ b/Classes/Linktype/LinktypeInterface.php @@ -3,19 +3,6 @@ declare(strict_types=1); namespace Sypets\Brofix\Linktype; -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ - use Sypets\Brofix\CheckLinks\LinkTargetResponse\LinkTargetResponse; use Sypets\Brofix\Configuration\Configuration; @@ -70,5 +57,5 @@ public function getBrokenUrl(array $row): string; * @param mixed[] $additionalConfig * @return string */ - public function getBrokenLinkText(array $row, array $additionalConfig = null): string; + public function getBrokenLinkText(array $row, ?array $additionalConfig = null): string; } diff --git a/Classes/Mail/GenerateCheckResultFluidMail.php b/Classes/Mail/GenerateCheckResultFluidMail.php index 3b36c6371..54fff0893 100644 --- a/Classes/Mail/GenerateCheckResultFluidMail.php +++ b/Classes/Mail/GenerateCheckResultFluidMail.php @@ -3,19 +3,6 @@ declare(strict_types=1); namespace Sypets\Brofix\Mail; -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ - use Symfony\Component\Mailer\Exception\TransportExceptionInterface; use Symfony\Component\Mailer\SentMessage; use Symfony\Component\Mime\Address; @@ -24,13 +11,14 @@ use Sypets\Brofix\Exceptions\MissingConfigurationException; use TYPO3\CMS\Core\Mail\FluidEmail; use TYPO3\CMS\Core\Mail\Mailer; +use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Fluid\View\TemplatePaths; /** * Send mail with Fluid */ -class GenerateCheckResultFluidMail +class GenerateCheckResultFluidMail implements SingletonInterface { /** * @var Mailer @@ -42,9 +30,9 @@ class GenerateCheckResultFluidMail */ protected $messageId; - public function __construct(Mailer $mailer = null) + public function __construct(Mailer $mailer) { - $this->mailer = $mailer ?: GeneralUtility::makeInstance(Mailer::class); + $this->mailer = $mailer; } public function getMessageId(): string diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 49a24f843..5a826211b 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -10,6 +10,9 @@ services: Sypets\Brofix\LinkAnalyzer: public: true + Sypets\Brofix\Linktype\ExternalLinktype: + public: true + Sypets\Brofix\Repository\BrokenLinkRepository: public: true