mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-30 22:18:46 +02:00
N°6934 - Symfony 6.4 - upgrade Symfony bundles to 6.4 (#580)
* Update Symfony lib to version ~6.4.0 * Update code missing return type * Add an iTop general configuration entry to store application secret (Symfony mandatory parameter) * Use dependency injection in ExceptionListener & UserProvider classes
This commit is contained in:
@@ -25,9 +25,8 @@ use Twig\TwigFunction;
|
||||
*/
|
||||
final class SecurityExtension extends AbstractExtension
|
||||
{
|
||||
private $securityChecker;
|
||||
|
||||
private $impersonateUrlGenerator;
|
||||
private ?AuthorizationCheckerInterface $securityChecker;
|
||||
private ?ImpersonateUrlGenerator $impersonateUrlGenerator;
|
||||
|
||||
public function __construct(AuthorizationCheckerInterface $securityChecker = null, ImpersonateUrlGenerator $impersonateUrlGenerator = null)
|
||||
{
|
||||
@@ -35,10 +34,7 @@ final class SecurityExtension extends AbstractExtension
|
||||
$this->impersonateUrlGenerator = $impersonateUrlGenerator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $object
|
||||
*/
|
||||
public function isGranted($role, $object = null, string $field = null): bool
|
||||
public function isGranted(mixed $role, mixed $object = null, string $field = null): bool
|
||||
{
|
||||
if (null === $this->securityChecker) {
|
||||
return false;
|
||||
@@ -50,7 +46,7 @@ final class SecurityExtension extends AbstractExtension
|
||||
|
||||
try {
|
||||
return $this->securityChecker->isGranted($role, $object);
|
||||
} catch (AuthenticationCredentialsNotFoundException $e) {
|
||||
} catch (AuthenticationCredentialsNotFoundException) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -73,15 +69,32 @@ final class SecurityExtension extends AbstractExtension
|
||||
return $this->impersonateUrlGenerator->generateExitPath($exitTo);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getImpersonateUrl(string $identifier): string
|
||||
{
|
||||
if (null === $this->impersonateUrlGenerator) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->impersonateUrlGenerator->generateImpersonationUrl($identifier);
|
||||
}
|
||||
|
||||
public function getImpersonatePath(string $identifier): string
|
||||
{
|
||||
if (null === $this->impersonateUrlGenerator) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->impersonateUrlGenerator->generateImpersonationPath($identifier);
|
||||
}
|
||||
|
||||
public function getFunctions(): array
|
||||
{
|
||||
return [
|
||||
new TwigFunction('is_granted', [$this, 'isGranted']),
|
||||
new TwigFunction('impersonation_exit_url', [$this, 'getImpersonateExitUrl']),
|
||||
new TwigFunction('impersonation_exit_path', [$this, 'getImpersonateExitPath']),
|
||||
new TwigFunction('is_granted', $this->isGranted(...)),
|
||||
new TwigFunction('impersonation_exit_url', $this->getImpersonateExitUrl(...)),
|
||||
new TwigFunction('impersonation_exit_path', $this->getImpersonateExitPath(...)),
|
||||
new TwigFunction('impersonation_url', $this->getImpersonateUrl(...)),
|
||||
new TwigFunction('impersonation_path', $this->getImpersonatePath(...)),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user