diff --git a/composer.json b/composer.json index 92bec45..569f94c 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,8 @@ "require": { "php": "^8.1", "contao/core-bundle": "^4.13 || ^5.0", - "symfony/mime": "^5.4 || ^6.0 || ^7.0" + "symfony/mime": "^5.4 || ^6.0 || ^7.0", + "symfony/security-core": "^5.4 || ^6.0 || ^7.0" }, "require-dev": { "contao/manager-plugin": "^2.0", diff --git a/src/DoctrineOrmHelper.php b/src/DoctrineOrmHelper.php index 7c5fa68..86490c4 100644 --- a/src/DoctrineOrmHelper.php +++ b/src/DoctrineOrmHelper.php @@ -11,7 +11,7 @@ use Doctrine\DBAL\Connection; use Doctrine\Persistence\ObjectManager; use Symfony\Component\Routing\RouterInterface; -use Symfony\Component\Security\Core\Security; +use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; class DoctrineOrmHelper { @@ -27,7 +27,7 @@ public function __construct( private readonly Connection $connection, private readonly DcaRelationsManager $dcaRelationsManager, private readonly RouterInterface $router, - private readonly Security $security, + private readonly TokenStorageInterface $tokenStorage, ) { } @@ -82,7 +82,7 @@ public function createObjectVersion(ObjectManager $objectManager, object $entity $versions = new Versions($objectManager->getClassMetadata($entity::class)->getTableName(), $entity->getId()); // Set the frontend user, if any - if (($user = $this->security->getUser()) instanceof FrontendUser) { + if (($user = $this->tokenStorage->getToken()?->getUser()) instanceof FrontendUser) { $versions->setUsername($user->username); $versions->setUserId(0); } diff --git a/src/EventListener/DcaAjaxOperationsListener.php b/src/EventListener/DcaAjaxOperationsListener.php index 81d83ee..1f82d56 100644 --- a/src/EventListener/DcaAjaxOperationsListener.php +++ b/src/EventListener/DcaAjaxOperationsListener.php @@ -23,7 +23,7 @@ use Symfony\Component\Asset\Packages; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\Security\Core\Security; +use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; class DcaAjaxOperationsListener { @@ -32,7 +32,7 @@ public function __construct( private readonly Packages $packages, private readonly RequestStack $requestStack, private readonly ScopeMatcher $scopeMatcher, - private readonly Security $security, + private readonly AuthorizationCheckerInterface $security, private readonly ContaoCsrfTokenManager $tokenManager, ) { }