Skip to content

Commit

Permalink
Merge pull request #41 from systopia/FundingFileRouter-D10-compatibility
Browse files Browse the repository at this point in the history
FundingFileRouter: Drop deprecated method call and make it D10 compatible
  • Loading branch information
dontub authored Jan 3, 2024
2 parents 2f16422 + 00849f3 commit 66d33c5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion civiremote_funding.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 12 additions & 8 deletions src/File/FundingFileRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}

}

0 comments on commit 66d33c5

Please sign in to comment.