diff --git a/src/Command/User/UpgradePermissionsSchemaCommand.php b/src/Command/User/UpgradePermissionsSchemaCommand.php index a4a02e00..ae5adfff 100644 --- a/src/Command/User/UpgradePermissionsSchemaCommand.php +++ b/src/Command/User/UpgradePermissionsSchemaCommand.php @@ -23,6 +23,7 @@ namespace App\Command\User; use App\Entity\UserSystem\Group; use App\Entity\UserSystem\PermissionData; use App\Entity\UserSystem\User; +use App\Services\LogSystem\EventCommentHelper; use App\Services\UserSystem\PermissionSchemaUpdater; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Console\Command\Command; @@ -39,12 +40,14 @@ final class UpgradePermissionsSchemaCommand extends Command private PermissionSchemaUpdater $permissionSchemaUpdater; private EntityManagerInterface $em; + private EventCommentHelper $eventCommentHelper; - public function __construct(PermissionSchemaUpdater $permissionSchemaUpdater, EntityManagerInterface $entityManager) + public function __construct(PermissionSchemaUpdater $permissionSchemaUpdater, EntityManagerInterface $entityManager, EventCommentHelper $eventCommentHelper) { parent::__construct(self::$defaultName); $this->permissionSchemaUpdater = $permissionSchemaUpdater; + $this->eventCommentHelper = $eventCommentHelper; $this->em = $entityManager; } @@ -112,6 +115,8 @@ final class UpgradePermissionsSchemaCommand extends Command $this->permissionSchemaUpdater->upgradeSchema($user); } + $this->eventCommentHelper->setMessage('Manual permissions schema update via CLI'); + //Write changes to database $this->em->flush(); diff --git a/src/EventSubscriber/UserSystem/UpgradePermissionsSchemaSubscriber.php b/src/EventSubscriber/UserSystem/UpgradePermissionsSchemaSubscriber.php index cda163c4..7d891df0 100644 --- a/src/EventSubscriber/UserSystem/UpgradePermissionsSchemaSubscriber.php +++ b/src/EventSubscriber/UserSystem/UpgradePermissionsSchemaSubscriber.php @@ -21,6 +21,7 @@ namespace App\EventSubscriber\UserSystem; use App\Entity\UserSystem\User; +use App\Services\LogSystem\EventCommentHelper; use App\Services\UserSystem\PermissionSchemaUpdater; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -38,13 +39,15 @@ class UpgradePermissionsSchemaSubscriber implements EventSubscriberInterface private PermissionSchemaUpdater $permissionSchemaUpdater; private EntityManagerInterface $entityManager; private FlashBagInterface $flashBag; + private EventCommentHelper $eventCommentHelper; - public function __construct(Security $security, PermissionSchemaUpdater $permissionSchemaUpdater, EntityManagerInterface $entityManager, FlashBagInterface $flashBag) + public function __construct(Security $security, PermissionSchemaUpdater $permissionSchemaUpdater, EntityManagerInterface $entityManager, FlashBagInterface $flashBag, EventCommentHelper $eventCommentHelper) { $this->security = $security; $this->permissionSchemaUpdater = $permissionSchemaUpdater; $this->entityManager = $entityManager; $this->flashBag = $flashBag; + $this->eventCommentHelper = $eventCommentHelper; } public function onRequest(RequestEvent $event): void @@ -60,6 +63,7 @@ class UpgradePermissionsSchemaSubscriber implements EventSubscriberInterface } if ($this->permissionSchemaUpdater->isSchemaUpdateNeeded($user)) { + $this->eventCommentHelper->setMessage('Automatic permission schema update'); $this->permissionSchemaUpdater->userUpgradeSchemaRecursively($user); $this->entityManager->flush(); $this->flashBag->add('notice', 'user.permissions_schema_updated');