mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 18:58:46 +02:00
Added comment to the element change log entries on permission schema change.
This commit is contained in:
parent
7b6a906d98
commit
751cdc603a
2 changed files with 11 additions and 2 deletions
|
@ -23,6 +23,7 @@ namespace App\Command\User;
|
||||||
use App\Entity\UserSystem\Group;
|
use App\Entity\UserSystem\Group;
|
||||||
use App\Entity\UserSystem\PermissionData;
|
use App\Entity\UserSystem\PermissionData;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
|
use App\Services\LogSystem\EventCommentHelper;
|
||||||
use App\Services\UserSystem\PermissionSchemaUpdater;
|
use App\Services\UserSystem\PermissionSchemaUpdater;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
@ -39,12 +40,14 @@ final class UpgradePermissionsSchemaCommand extends Command
|
||||||
|
|
||||||
private PermissionSchemaUpdater $permissionSchemaUpdater;
|
private PermissionSchemaUpdater $permissionSchemaUpdater;
|
||||||
private EntityManagerInterface $em;
|
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);
|
parent::__construct(self::$defaultName);
|
||||||
|
|
||||||
$this->permissionSchemaUpdater = $permissionSchemaUpdater;
|
$this->permissionSchemaUpdater = $permissionSchemaUpdater;
|
||||||
|
$this->eventCommentHelper = $eventCommentHelper;
|
||||||
$this->em = $entityManager;
|
$this->em = $entityManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,6 +115,8 @@ final class UpgradePermissionsSchemaCommand extends Command
|
||||||
$this->permissionSchemaUpdater->upgradeSchema($user);
|
$this->permissionSchemaUpdater->upgradeSchema($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->eventCommentHelper->setMessage('Manual permissions schema update via CLI');
|
||||||
|
|
||||||
//Write changes to database
|
//Write changes to database
|
||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
namespace App\EventSubscriber\UserSystem;
|
namespace App\EventSubscriber\UserSystem;
|
||||||
|
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
|
use App\Services\LogSystem\EventCommentHelper;
|
||||||
use App\Services\UserSystem\PermissionSchemaUpdater;
|
use App\Services\UserSystem\PermissionSchemaUpdater;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
|
@ -38,13 +39,15 @@ class UpgradePermissionsSchemaSubscriber implements EventSubscriberInterface
|
||||||
private PermissionSchemaUpdater $permissionSchemaUpdater;
|
private PermissionSchemaUpdater $permissionSchemaUpdater;
|
||||||
private EntityManagerInterface $entityManager;
|
private EntityManagerInterface $entityManager;
|
||||||
private FlashBagInterface $flashBag;
|
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->security = $security;
|
||||||
$this->permissionSchemaUpdater = $permissionSchemaUpdater;
|
$this->permissionSchemaUpdater = $permissionSchemaUpdater;
|
||||||
$this->entityManager = $entityManager;
|
$this->entityManager = $entityManager;
|
||||||
$this->flashBag = $flashBag;
|
$this->flashBag = $flashBag;
|
||||||
|
$this->eventCommentHelper = $eventCommentHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onRequest(RequestEvent $event): void
|
public function onRequest(RequestEvent $event): void
|
||||||
|
@ -60,6 +63,7 @@ class UpgradePermissionsSchemaSubscriber implements EventSubscriberInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->permissionSchemaUpdater->isSchemaUpdateNeeded($user)) {
|
if ($this->permissionSchemaUpdater->isSchemaUpdateNeeded($user)) {
|
||||||
|
$this->eventCommentHelper->setMessage('Automatic permission schema update');
|
||||||
$this->permissionSchemaUpdater->userUpgradeSchemaRecursively($user);
|
$this->permissionSchemaUpdater->userUpgradeSchemaRecursively($user);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
$this->flashBag->add('notice', 'user.permissions_schema_updated');
|
$this->flashBag->add('notice', 'user.permissions_schema_updated');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue