From cf57bb3ed174c82b424c3658f3bb345e7a0b5874 Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Sun, 23 Nov 2025 02:16:01 +0100 Subject: [PATCH] Make controllers get parameters from constructor --- app/config/services.yml | 7 +++++++ src/Controller/Api/EntryRestController.php | 6 ++---- src/Controller/Api/WallabagRestController.php | 8 +++++--- src/Controller/EntryController.php | 3 ++- src/Controller/FeedController.php | 10 ++++++---- src/Controller/Import/BrowserController.php | 12 +++++++++--- src/Controller/Import/ChromeController.php | 3 +++ src/Controller/Import/DeliciousController.php | 8 +++++--- src/Controller/Import/ElcuratorController.php | 3 +++ src/Controller/Import/FirefoxController.php | 3 +++ src/Controller/Import/HtmlController.php | 12 +++++++++--- src/Controller/Import/InstapaperController.php | 8 +++++--- src/Controller/Import/OmnivoreController.php | 8 +++++--- src/Controller/Import/PinboardController.php | 8 +++++--- src/Controller/Import/PocketCsvController.php | 8 +++++--- src/Controller/Import/PocketHtmlController.php | 3 +++ src/Controller/Import/ReadabilityController.php | 8 +++++--- src/Controller/Import/ShaarliController.php | 3 +++ src/Controller/Import/WallabagController.php | 12 +++++++++--- src/Controller/Import/WallabagV1Controller.php | 3 +++ src/Controller/Import/WallabagV2Controller.php | 3 +++ src/Controller/StaticController.php | 15 ++++++++++----- 22 files changed, 110 insertions(+), 44 deletions(-) diff --git a/app/config/services.yml b/app/config/services.yml index 76794dcc8..9b824429b 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -20,7 +20,13 @@ services: $encryptionKeyPath: "%wallabag.site_credentials.encryption_key_path%" $fetchingErrorMessageTitle: "%wallabag.fetching_error_message_title%" $fetchingErrorMessage: '%wallabag.fetching_error_message%' + $version: "%wallabag.version%" + $paypalUrl: "%wallabag.paypal_url%" $languages: '%wallabag.languages%' + $feedLimit: "%wallabag.feed_limit%" + $apiLimitMassActions: "%wallabag.api_limit_mass_actions%" + $allowMimetypes: "%wallabag.allow_mimetypes%" + $resourceDir: "%wallabag.resource_dir%" $lifeTime: '%wallabag.cache_lifetime%' $logoPath: 'web/img/appicon/apple-touch-icon-152.png' $registrationEnabled: '%fosuser_registration%' @@ -32,6 +38,7 @@ services: $fonts: '%wallabag.fonts%' $defaultIgnoreOriginInstanceRules: '%wallabag.default_ignore_origin_instance_rules%' $defaultUserAgent: "%wallabag_user_agent%" + $addonsUrl: "%addons_url%" Wallabag\: resource: '../../src/*' diff --git a/src/Controller/Api/EntryRestController.php b/src/Controller/Api/EntryRestController.php index 848ce1aff..0922dcae0 100644 --- a/src/Controller/Api/EntryRestController.php +++ b/src/Controller/Api/EntryRestController.php @@ -539,9 +539,7 @@ class EntryRestController extends WallabagRestController { $urls = json_decode($request->query->get('urls', '[]')); - $limit = $this->getParameter('wallabag.api_limit_mass_actions'); - - if (\count($urls) > $limit) { + if (\count($urls) > $this->apiLimitMassActions) { throw new BadRequestHttpException('API limit reached'); } @@ -1067,7 +1065,7 @@ class EntryRestController extends WallabagRestController } // if refreshing entry failed, don't save it - if ($this->getParameter('wallabag.fetching_error_message') === $entry->getContent()) { + if ($this->fetchingErrorMessage === $entry->getContent()) { return new JsonResponse([], 304); } diff --git a/src/Controller/Api/WallabagRestController.php b/src/Controller/Api/WallabagRestController.php index fad611536..48e7b0aba 100644 --- a/src/Controller/Api/WallabagRestController.php +++ b/src/Controller/Api/WallabagRestController.php @@ -28,6 +28,9 @@ class WallabagRestController extends AbstractFOSRestController protected TokenStorageInterface $tokenStorage, protected TranslatorInterface $translator, protected bool $registrationEnabled, + protected string $version, + protected int $apiLimitMassActions, + protected string $fetchingErrorMessage, ) { } @@ -55,8 +58,7 @@ class WallabagRestController extends AbstractFOSRestController #[Route(path: '/api/version.{_format}', name: 'api_get_version', methods: ['GET'], defaults: ['_format' => 'json'])] public function getVersionAction() { - $version = $this->getParameter('wallabag.version'); - $json = $this->serializer->serialize($version, 'json'); + $json = $this->serializer->serialize($this->version, 'json'); return (new JsonResponse())->setJson($json); } @@ -78,7 +80,7 @@ class WallabagRestController extends AbstractFOSRestController public function getInfoAction(Config $craueConfig) { $info = new ApplicationInfo( - $this->getParameter('wallabag.version'), + $this->version, $this->registrationEnabled && $craueConfig->get('api_user_registration'), ); diff --git a/src/Controller/EntryController.php b/src/Controller/EntryController.php index ca34e0dd1..beaeac8ea 100644 --- a/src/Controller/EntryController.php +++ b/src/Controller/EntryController.php @@ -43,6 +43,7 @@ class EntryController extends AbstractController private readonly FilterBuilderUpdaterInterface $filterBuilderUpdater, private readonly ContentProxy $contentProxy, private readonly Security $security, + private readonly string $fetchingErrorMessage, ) { } @@ -411,7 +412,7 @@ class EntryController extends AbstractController $this->updateEntry($entry, 'entry_reloaded'); // if refreshing entry failed, don't save it - if ($this->getParameter('wallabag.fetching_error_message') === $entry->getContent()) { + if ($this->fetchingErrorMessage === $entry->getContent()) { $this->addFlash('notice', 'flashes.entry.notice.entry_reloaded_failed'); return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()])); diff --git a/src/Controller/FeedController.php b/src/Controller/FeedController.php index 3b69d6c47..48184c95e 100644 --- a/src/Controller/FeedController.php +++ b/src/Controller/FeedController.php @@ -22,6 +22,8 @@ class FeedController extends AbstractController { public function __construct( private readonly EntryRepository $entryRepository, + private readonly int $feedLimit, + private readonly string $version, ) { } @@ -122,7 +124,7 @@ class FeedController extends AbstractController $user ); - $perPage = $user->getConfig()->getFeedLimit() ?: $this->getParameter('wallabag.feed_limit'); + $perPage = $user->getConfig()->getFeedLimit() ?: $this->feedLimit; $entries->setMaxPerPage($perPage); try { @@ -140,7 +142,7 @@ class FeedController extends AbstractController 'url' => $url, 'entries' => $entries, 'user' => $user->getUsername(), - 'version' => $this->getParameter('wallabag.version'), + 'version' => $this->version, 'tag' => $tag->getSlug(), 'updated' => $this->prepareFeedUpdatedDate($entries, $sort), ], @@ -186,7 +188,7 @@ class FeedController extends AbstractController $pagerAdapter = new DoctrineORMAdapter($qb->getQuery(), true, false); $entries = new Pagerfanta($pagerAdapter); - $perPage = $user->getConfig()->getFeedLimit() ?: $this->getParameter('wallabag.feed_limit'); + $perPage = $user->getConfig()->getFeedLimit() ?: $this->feedLimit; $entries->setMaxPerPage($perPage); $url = $this->generateUrl( @@ -211,7 +213,7 @@ class FeedController extends AbstractController 'url' => $url, 'entries' => $entries, 'user' => $user->getUsername(), - 'version' => $this->getParameter('wallabag.version'), + 'version' => $this->version, 'updated' => $this->prepareFeedUpdatedDate($entries), ], new Response('', 200, ['Content-Type' => 'application/atom+xml'])); } diff --git a/src/Controller/Import/BrowserController.php b/src/Controller/Import/BrowserController.php index 3b897248b..236c2d820 100644 --- a/src/Controller/Import/BrowserController.php +++ b/src/Controller/Import/BrowserController.php @@ -13,6 +13,12 @@ use Wallabag\Import\ImportInterface; abstract class BrowserController extends AbstractController { + public function __construct( + protected readonly array $allowMimetypes, + protected readonly string $resourceDir, + ) { + } + /** * @return Response */ @@ -31,9 +37,9 @@ abstract class BrowserController extends AbstractController $markAsRead = $form->get('mark_as_read')->getData(); $name = $this->getUser()->getId() . '.json'; - if (null !== $file && \in_array($file->getClientMimeType(), $this->getParameter('wallabag.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag.resource_dir'), $name)) { + if (null !== $file && \in_array($file->getClientMimeType(), $this->allowMimetypes, true) && $file->move($this->resourceDir, $name)) { $res = $wallabag - ->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name) + ->setFilepath($this->resourceDir . '/' . $name) ->setMarkAsRead($markAsRead) ->import(); @@ -52,7 +58,7 @@ abstract class BrowserController extends AbstractController ]); } - unlink($this->getParameter('wallabag.resource_dir') . '/' . $name); + unlink($this->resourceDir . '/' . $name); } $this->addFlash('notice', $message); diff --git a/src/Controller/Import/ChromeController.php b/src/Controller/Import/ChromeController.php index 0283cdee4..e0203bf0a 100644 --- a/src/Controller/Import/ChromeController.php +++ b/src/Controller/Import/ChromeController.php @@ -18,7 +18,10 @@ class ChromeController extends BrowserController private readonly Config $craueConfig, private readonly RabbitMqProducer $rabbitMqProducer, private readonly RedisProducer $redisProducer, + array $allowMimetypes, + string $resourceDir, ) { + parent::__construct($allowMimetypes, $resourceDir); } #[Route(path: '/import/chrome', name: 'import_chrome', methods: ['GET', 'POST'])] diff --git a/src/Controller/Import/DeliciousController.php b/src/Controller/Import/DeliciousController.php index 2caa6bdc1..d0e06df98 100644 --- a/src/Controller/Import/DeliciousController.php +++ b/src/Controller/Import/DeliciousController.php @@ -18,6 +18,8 @@ class DeliciousController extends AbstractController public function __construct( private readonly RabbitMqProducer $rabbitMqProducer, private readonly RedisProducer $redisProducer, + private readonly array $allowMimetypes, + private readonly string $resourceDir, ) { } @@ -41,9 +43,9 @@ class DeliciousController extends AbstractController $markAsRead = $form->get('mark_as_read')->getData(); $name = 'delicious_' . $this->getUser()->getId() . '.json'; - if (null !== $file && \in_array($file->getClientMimeType(), $this->getParameter('wallabag.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag.resource_dir'), $name)) { + if (null !== $file && \in_array($file->getClientMimeType(), $this->allowMimetypes, true) && $file->move($this->resourceDir, $name)) { $res = $delicious - ->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name) + ->setFilepath($this->resourceDir . '/' . $name) ->setMarkAsRead($markAsRead) ->import(); @@ -62,7 +64,7 @@ class DeliciousController extends AbstractController ]); } - unlink($this->getParameter('wallabag.resource_dir') . '/' . $name); + unlink($this->resourceDir . '/' . $name); } $this->addFlash('notice', $message); diff --git a/src/Controller/Import/ElcuratorController.php b/src/Controller/Import/ElcuratorController.php index 4132f01d4..28ea6dcb0 100644 --- a/src/Controller/Import/ElcuratorController.php +++ b/src/Controller/Import/ElcuratorController.php @@ -18,7 +18,10 @@ class ElcuratorController extends WallabagController private readonly Config $craueConfig, private readonly RabbitMqProducer $rabbitMqProducer, private readonly RedisProducer $redisProducer, + array $allowMimetypes, + string $resourceDir, ) { + parent::__construct($allowMimetypes, $resourceDir); } #[Route(path: '/import/elcurator', name: 'import_elcurator', methods: ['GET', 'POST'])] diff --git a/src/Controller/Import/FirefoxController.php b/src/Controller/Import/FirefoxController.php index d3c6ad75d..29bc778e8 100644 --- a/src/Controller/Import/FirefoxController.php +++ b/src/Controller/Import/FirefoxController.php @@ -18,7 +18,10 @@ class FirefoxController extends BrowserController private readonly Config $craueConfig, private readonly RabbitMqProducer $rabbitMqProducer, private readonly RedisProducer $redisProducer, + array $allowMimetypes, + string $resourceDir, ) { + parent::__construct($allowMimetypes, $resourceDir); } #[Route(path: '/import/firefox', name: 'import_firefox', methods: ['GET', 'POST'])] diff --git a/src/Controller/Import/HtmlController.php b/src/Controller/Import/HtmlController.php index c55e114e1..b302ece48 100644 --- a/src/Controller/Import/HtmlController.php +++ b/src/Controller/Import/HtmlController.php @@ -13,6 +13,12 @@ use Wallabag\Import\ImportInterface; abstract class HtmlController extends AbstractController { + public function __construct( + protected readonly array $allowMimetypes, + protected readonly string $resourceDir, + ) { + } + /** * @return Response */ @@ -31,9 +37,9 @@ abstract class HtmlController extends AbstractController $markAsRead = $form->get('mark_as_read')->getData(); $name = $this->getUser()->getId() . '.html'; - if (null !== $file && \in_array($file->getClientMimeType(), $this->getParameter('wallabag.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag.resource_dir'), $name)) { + if (null !== $file && \in_array($file->getClientMimeType(), $this->allowMimetypes, true) && $file->move($this->resourceDir, $name)) { $res = $wallabag - ->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name) + ->setFilepath($this->resourceDir . '/' . $name) ->setMarkAsRead($markAsRead) ->import(); @@ -52,7 +58,7 @@ abstract class HtmlController extends AbstractController ]); } - unlink($this->getParameter('wallabag.resource_dir') . '/' . $name); + unlink($this->resourceDir . '/' . $name); } $this->addFlash('notice', $message); diff --git a/src/Controller/Import/InstapaperController.php b/src/Controller/Import/InstapaperController.php index 7edb4a9e7..7bd1815a0 100644 --- a/src/Controller/Import/InstapaperController.php +++ b/src/Controller/Import/InstapaperController.php @@ -18,6 +18,8 @@ class InstapaperController extends AbstractController public function __construct( private readonly RabbitMqProducer $rabbitMqProducer, private readonly RedisProducer $redisProducer, + private readonly array $allowMimetypes, + private readonly string $resourceDir, ) { } @@ -41,9 +43,9 @@ class InstapaperController extends AbstractController $markAsRead = $form->get('mark_as_read')->getData(); $name = 'instapaper_' . $this->getUser()->getId() . '.csv'; - if (null !== $file && \in_array($file->getClientMimeType(), $this->getParameter('wallabag.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag.resource_dir'), $name)) { + if (null !== $file && \in_array($file->getClientMimeType(), $this->allowMimetypes, true) && $file->move($this->resourceDir, $name)) { $res = $instapaper - ->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name) + ->setFilepath($this->resourceDir . '/' . $name) ->setMarkAsRead($markAsRead) ->import(); @@ -62,7 +64,7 @@ class InstapaperController extends AbstractController ]); } - unlink($this->getParameter('wallabag.resource_dir') . '/' . $name); + unlink($this->resourceDir . '/' . $name); } $this->addFlash('notice', $message); diff --git a/src/Controller/Import/OmnivoreController.php b/src/Controller/Import/OmnivoreController.php index 1796cb4ab..8c0793714 100644 --- a/src/Controller/Import/OmnivoreController.php +++ b/src/Controller/Import/OmnivoreController.php @@ -18,6 +18,8 @@ class OmnivoreController extends AbstractController public function __construct( private readonly RabbitMqProducer $rabbitMqProducer, private readonly RedisProducer $redisProducer, + private readonly array $allowMimetypes, + private readonly string $resourceDir, ) { } @@ -41,9 +43,9 @@ class OmnivoreController extends AbstractController $markAsRead = $form->get('mark_as_read')->getData(); $name = 'omnivore_' . $this->getUser()->getId() . '.json'; - if (null !== $file && \in_array($file->getClientMimeType(), $this->getParameter('wallabag.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag.resource_dir'), $name)) { + if (null !== $file && \in_array($file->getClientMimeType(), $this->allowMimetypes, true) && $file->move($this->resourceDir, $name)) { $res = $omnivore - ->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name) + ->setFilepath($this->resourceDir . '/' . $name) ->setMarkAsRead($markAsRead) ->import(); @@ -62,7 +64,7 @@ class OmnivoreController extends AbstractController ]); } - unlink($this->getParameter('wallabag.resource_dir') . '/' . $name); + unlink($this->resourceDir . '/' . $name); } $this->addFlash('notice', $message); diff --git a/src/Controller/Import/PinboardController.php b/src/Controller/Import/PinboardController.php index 437faac83..bb447f9a4 100644 --- a/src/Controller/Import/PinboardController.php +++ b/src/Controller/Import/PinboardController.php @@ -18,6 +18,8 @@ class PinboardController extends AbstractController public function __construct( private readonly RabbitMqProducer $rabbitMqProducer, private readonly RedisProducer $redisProducer, + private readonly array $allowMimetypes, + private readonly string $resourceDir, ) { } @@ -41,9 +43,9 @@ class PinboardController extends AbstractController $markAsRead = $form->get('mark_as_read')->getData(); $name = 'pinboard_' . $this->getUser()->getId() . '.json'; - if (null !== $file && \in_array($file->getClientMimeType(), $this->getParameter('wallabag.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag.resource_dir'), $name)) { + if (null !== $file && \in_array($file->getClientMimeType(), $this->allowMimetypes, true) && $file->move($this->resourceDir, $name)) { $res = $pinboard - ->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name) + ->setFilepath($this->resourceDir . '/' . $name) ->setMarkAsRead($markAsRead) ->import(); @@ -62,7 +64,7 @@ class PinboardController extends AbstractController ]); } - unlink($this->getParameter('wallabag.resource_dir') . '/' . $name); + unlink($this->resourceDir . '/' . $name); } $this->addFlash('notice', $message); diff --git a/src/Controller/Import/PocketCsvController.php b/src/Controller/Import/PocketCsvController.php index 8630e5b4c..2d949a7c8 100644 --- a/src/Controller/Import/PocketCsvController.php +++ b/src/Controller/Import/PocketCsvController.php @@ -20,6 +20,8 @@ class PocketCsvController extends AbstractController private readonly Config $craueConfig, private readonly RabbitMqProducer $rabbitMqProducer, private readonly RedisProducer $redisProducer, + private readonly array $allowMimetypes, + private readonly string $resourceDir, ) { } @@ -43,9 +45,9 @@ class PocketCsvController extends AbstractController $markAsRead = $form->get('mark_as_read')->getData(); $name = 'pocket_' . $this->getUser()->getId() . '.csv'; - if (null !== $file && \in_array($file->getClientMimeType(), $this->getParameter('wallabag.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag.resource_dir'), $name)) { + if (null !== $file && \in_array($file->getClientMimeType(), $this->allowMimetypes, true) && $file->move($this->resourceDir, $name)) { $res = $this->pocketCsvImport - ->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name) + ->setFilepath($this->resourceDir . '/' . $name) ->setMarkAsRead($markAsRead) ->import(); @@ -64,7 +66,7 @@ class PocketCsvController extends AbstractController ]); } - unlink($this->getParameter('wallabag.resource_dir') . '/' . $name); + unlink($this->resourceDir . '/' . $name); } $this->addFlash('notice', $message); diff --git a/src/Controller/Import/PocketHtmlController.php b/src/Controller/Import/PocketHtmlController.php index 00f6b7b7d..cf3c3691d 100644 --- a/src/Controller/Import/PocketHtmlController.php +++ b/src/Controller/Import/PocketHtmlController.php @@ -18,7 +18,10 @@ class PocketHtmlController extends HtmlController private readonly Config $craueConfig, private readonly RabbitMqProducer $rabbitMqProducer, private readonly RedisProducer $redisProducer, + array $allowMimetypes, + string $resourceDir, ) { + parent::__construct($allowMimetypes, $resourceDir); } #[Route(path: '/import/pocket_html', name: 'import_pocket_html', methods: ['GET', 'POST'])] diff --git a/src/Controller/Import/ReadabilityController.php b/src/Controller/Import/ReadabilityController.php index 6409f5d05..560dea8f4 100644 --- a/src/Controller/Import/ReadabilityController.php +++ b/src/Controller/Import/ReadabilityController.php @@ -18,6 +18,8 @@ class ReadabilityController extends AbstractController public function __construct( private readonly RabbitMqProducer $rabbitMqProducer, private readonly RedisProducer $redisProducer, + private readonly array $allowMimetypes, + private readonly string $resourceDir, ) { } @@ -41,9 +43,9 @@ class ReadabilityController extends AbstractController $markAsRead = $form->get('mark_as_read')->getData(); $name = 'readability_' . $this->getUser()->getId() . '.json'; - if (null !== $file && \in_array($file->getClientMimeType(), $this->getParameter('wallabag.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag.resource_dir'), $name)) { + if (null !== $file && \in_array($file->getClientMimeType(), $this->allowMimetypes, true) && $file->move($this->resourceDir, $name)) { $res = $readability - ->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name) + ->setFilepath($this->resourceDir . '/' . $name) ->setMarkAsRead($markAsRead) ->import(); @@ -62,7 +64,7 @@ class ReadabilityController extends AbstractController ]); } - unlink($this->getParameter('wallabag.resource_dir') . '/' . $name); + unlink($this->resourceDir . '/' . $name); } $this->addFlash('notice', $message); diff --git a/src/Controller/Import/ShaarliController.php b/src/Controller/Import/ShaarliController.php index 8be50a180..522041ace 100644 --- a/src/Controller/Import/ShaarliController.php +++ b/src/Controller/Import/ShaarliController.php @@ -18,7 +18,10 @@ class ShaarliController extends HtmlController private readonly Config $craueConfig, private readonly RabbitMqProducer $rabbitMqProducer, private readonly RedisProducer $redisProducer, + array $allowMimetypes, + string $resourceDir, ) { + parent::__construct($allowMimetypes, $resourceDir); } #[Route(path: '/import/shaarli', name: 'import_shaarli', methods: ['GET', 'POST'])] diff --git a/src/Controller/Import/WallabagController.php b/src/Controller/Import/WallabagController.php index 12700f902..394224e07 100644 --- a/src/Controller/Import/WallabagController.php +++ b/src/Controller/Import/WallabagController.php @@ -15,6 +15,12 @@ use Wallabag\Import\ImportInterface; */ abstract class WallabagController extends AbstractController { + public function __construct( + protected readonly array $allowMimetypes, + protected readonly string $resourceDir, + ) { + } + /** * Handle import request. * @@ -33,9 +39,9 @@ abstract class WallabagController extends AbstractController $markAsRead = $form->get('mark_as_read')->getData(); $name = $this->getUser()->getId() . '.json'; - if (null !== $file && \in_array($file->getClientMimeType(), $this->getParameter('wallabag.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag.resource_dir'), $name)) { + if (null !== $file && \in_array($file->getClientMimeType(), $this->allowMimetypes, true) && $file->move($this->resourceDir, $name)) { $res = $wallabag - ->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name) + ->setFilepath($this->resourceDir . '/' . $name) ->setMarkAsRead($markAsRead) ->import(); @@ -54,7 +60,7 @@ abstract class WallabagController extends AbstractController ]); } - unlink($this->getParameter('wallabag.resource_dir') . '/' . $name); + unlink($this->resourceDir . '/' . $name); } $this->addFlash('notice', $message); diff --git a/src/Controller/Import/WallabagV1Controller.php b/src/Controller/Import/WallabagV1Controller.php index 7537db124..324436de0 100644 --- a/src/Controller/Import/WallabagV1Controller.php +++ b/src/Controller/Import/WallabagV1Controller.php @@ -18,7 +18,10 @@ class WallabagV1Controller extends WallabagController private readonly Config $craueConfig, private readonly RabbitMqProducer $rabbitMqProducer, private readonly RedisProducer $redisProducer, + array $allowMimetypes, + string $resourceDir, ) { + parent::__construct($allowMimetypes, $resourceDir); } #[Route(path: '/import/wallabag-v1', name: 'import_wallabag_v1', methods: ['GET', 'POST'])] diff --git a/src/Controller/Import/WallabagV2Controller.php b/src/Controller/Import/WallabagV2Controller.php index dee455336..67bda491d 100644 --- a/src/Controller/Import/WallabagV2Controller.php +++ b/src/Controller/Import/WallabagV2Controller.php @@ -18,7 +18,10 @@ class WallabagV2Controller extends WallabagController private readonly Config $craueConfig, private readonly RabbitMqProducer $rabbitMqProducer, private readonly RedisProducer $redisProducer, + array $allowMimetypes, + string $resourceDir, ) { + parent::__construct($allowMimetypes, $resourceDir); } #[Route(path: '/import/wallabag-v2', name: 'import_wallabag_v2', methods: ['GET', 'POST'])] diff --git a/src/Controller/StaticController.php b/src/Controller/StaticController.php index 5c7bb06e3..28cd2d727 100644 --- a/src/Controller/StaticController.php +++ b/src/Controller/StaticController.php @@ -7,16 +7,21 @@ use Symfony\Component\Routing\Annotation\Route; class StaticController extends AbstractController { + public function __construct( + private readonly array $addonsUrl, + private readonly string $version, + private readonly string $paypalUrl, + ) { + } + #[Route(path: '/howto', name: 'howto', methods: ['GET'])] #[IsGranted('IS_AUTHENTICATED_FULLY')] public function howtoAction() { - $addonsUrl = $this->getParameter('addons_url'); - return $this->render( 'Static/howto.html.twig', [ - 'addonsUrl' => $addonsUrl, + 'addonsUrl' => $this->addonsUrl, ] ); } @@ -28,8 +33,8 @@ class StaticController extends AbstractController return $this->render( 'Static/about.html.twig', [ - 'version' => $this->getParameter('wallabag.version'), - 'paypal_url' => $this->getParameter('wallabag.paypal_url'), + 'version' => $this->version, + 'paypal_url' => $this->paypalUrl, ] ); }