Release 2.0.19 (#4022)
* prevent invoices with exceeding filename * fixed invalid LDAP log level * support locale switching in action events
This commit is contained in:
@@ -19,6 +19,8 @@ use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
*/
|
||||
abstract class AbstractActionsSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
private ?string $locale = null;
|
||||
|
||||
public function __construct(private AuthorizationCheckerInterface $auth, private UrlGeneratorInterface $urlGenerator)
|
||||
{
|
||||
}
|
||||
@@ -30,16 +32,27 @@ abstract class AbstractActionsSubscriber implements EventSubscriberInterface
|
||||
|
||||
protected function path(string $route, array $parameters = []): string
|
||||
{
|
||||
if ($this->locale !== null) {
|
||||
$parameters['_locale'] = $this->locale;
|
||||
}
|
||||
|
||||
return $this->urlGenerator->generate($route, $parameters);
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
'actions.' . static::getActionName() => ['onActions', 1000],
|
||||
'actions.' . static::getActionName() => ['handleEvent', 1000],
|
||||
];
|
||||
}
|
||||
|
||||
final public function handleEvent(PageActionsEvent $event): void
|
||||
{
|
||||
$this->locale = $event->getLocale();
|
||||
|
||||
$this->onActions($event);
|
||||
}
|
||||
|
||||
public static function getActionName(): string
|
||||
{
|
||||
throw new \Exception('You need to overwrite getActionName() or getSubscribedEvents() in ' . static::class);
|
||||
|
||||
Reference in New Issue
Block a user