From 00849f333532e6a7c7223db5cd7cd36304d26e0a Mon Sep 17 00:00:00 2001 From: Dominic Tubach Date: Wed, 3 Jan 2024 10:51:14 +0100 Subject: [PATCH] FundingFileRouter: Drop deprecated method call and make it D10 compatible --- civiremote_funding.services.yml | 2 +- src/File/FundingFileRouter.php | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/civiremote_funding.services.yml b/civiremote_funding.services.yml index 3db4f5a..1abf60e 100644 --- a/civiremote_funding.services.yml +++ b/civiremote_funding.services.yml @@ -147,7 +147,7 @@ services: Drupal\civiremote_funding\File\FundingFileRouter: class: Drupal\civiremote_funding\File\FundingFileRouter arguments: - $router: '@router.no_access_checks' + $urlGenerator: '@url_generator' public: true Drupal\civiremote_funding\File\FundingFileDownloadHook: diff --git a/src/File/FundingFileRouter.php b/src/File/FundingFileRouter.php index 92eed7f..1f07834 100644 --- a/src/File/FundingFileRouter.php +++ b/src/File/FundingFileRouter.php @@ -22,26 +22,30 @@ use Assert\Assertion; use Drupal\civiremote_funding\Entity\FundingFileInterface; -use Symfony\Component\Routing\RouterInterface; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; /** * @codeCoverageIgnore */ class FundingFileRouter { - private RouterInterface $router; + private UrlGeneratorInterface $urlGenerator; - public function __construct(RouterInterface $router) { - $this->router = $router; + public function __construct(UrlGeneratorInterface $urlGenerator) { + $this->urlGenerator = $urlGenerator; } public function generate(FundingFileInterface $fundingFile): string { Assertion::notNull($fundingFile->getFile()); - return $this->router->generate('civiremote_funding.token_file_download', [ - 'token' => $fundingFile->getToken(), - 'filename' => $fundingFile->getFile()->getFilename(), - ], RouterInterface::ABSOLUTE_URL); + return $this->urlGenerator->generate( + 'civiremote_funding.token_file_download', + [ + 'token' => $fundingFile->getToken(), + 'filename' => $fundingFile->getFile()->getFilename(), + ], + UrlGeneratorInterface::ABSOLUTE_URL + ); } }