Skip to content

Commit f169c5a

Browse files
[Security] Make impersonation_path() argument mandatory and add impersonation_url()
1 parent de78b53 commit f169c5a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CHANGELOG
77
* Allow an array to be passed as the first argument to the `importmap()` Twig function
88
* Add `TemplatedEmail::locale()` to set the locale for the email rendering
99
* Add `AppVariable::getEnabledLocales()` to retrieve the enabled locales
10+
* Add `impersonation_path()` and `impersonation_url()` Twig functions
1011

1112
6.3
1213
---

Extension/SecurityExtension.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,16 @@ public function getImpersonateExitPath(string $exitTo = null): string
6969
return $this->impersonateUrlGenerator->generateExitPath($exitTo);
7070
}
7171

72-
public function getImpersonatePath(string $identifier = null): string
72+
public function getImpersonateUrl(string $identifier): string
73+
{
74+
if (null === $this->impersonateUrlGenerator) {
75+
return '';
76+
}
77+
78+
return $this->impersonateUrlGenerator->generateImpersonationUrl($identifier);
79+
}
80+
81+
public function getImpersonatePath(string $identifier): string
7382
{
7483
if (null === $this->impersonateUrlGenerator) {
7584
return '';
@@ -84,6 +93,7 @@ public function getFunctions(): array
8493
new TwigFunction('is_granted', $this->isGranted(...)),
8594
new TwigFunction('impersonation_exit_url', $this->getImpersonateExitUrl(...)),
8695
new TwigFunction('impersonation_exit_path', $this->getImpersonateExitPath(...)),
96+
new TwigFunction('impersonation_url', $this->getImpersonateUrl(...)),
8797
new TwigFunction('impersonation_path', $this->getImpersonatePath(...)),
8898
];
8999
}

0 commit comments

Comments
 (0)