Skip to content

Commit

Permalink
[ResourceBundle] fix Pimcore 10.6 compatibility to find Admin User
Browse files Browse the repository at this point in the history
  • Loading branch information
dpfaffenbauer committed May 25, 2023
1 parent 4c5322f commit fabfd90
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,23 @@ protected function isGrantedOr403(): void
*
* @psalm-var User $user
*/
$user = method_exists($this, 'getAdminUser') ? $this->getAdminUser() : $this->getUser();
$user = $this->getUser();

if (class_exists(\Pimcore\Security\User\User::class) && $user instanceof \Pimcore\Security\User\User) {
/**
* @psalm-suppress UndefinedClass, UndefinedInterfaceMethod
*/
$user = $user->getUser();
}
else if (class_exists(\Pimcore\Bundle\AdminBundle\Security\User\User::class) && $user instanceof \Pimcore\Bundle\AdminBundle\Security\User\User) {
/**
* @psalm-suppress UndefinedClass, UndefinedInterfaceMethod
*/
$user = $user->getUser();
}
else {
throw new \RuntimeException(sprintf('Unknown Pimcore Admin User Class given "%s"', get_class($user)));
}

if ($user->isAllowed($permission)) {
return;
Expand Down

0 comments on commit fabfd90

Please sign in to comment.