mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-13 21:59:34 +00:00
IPN-Vorschlagslogik um Konfiguration erweitert
This commit is contained in:
parent
3100c83246
commit
a2f53290f4
14 changed files with 163 additions and 51 deletions
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\EventSubscriber\UserSystem;
|
||||
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Settings\MiscSettings\IpnSuggestSettings;
|
||||
use Doctrine\Common\EventSubscriber;
|
||||
use Doctrine\Persistence\Event\LifecycleEventArgs;
|
||||
use Doctrine\ORM\Events;
|
||||
|
|
@ -12,7 +13,7 @@ class PartUniqueIpnSubscriber implements EventSubscriber
|
|||
{
|
||||
public function __construct(
|
||||
private EntityManagerInterface $entityManager,
|
||||
private readonly bool $enforceUniqueIpn = false
|
||||
private IpnSuggestSettings $ipnSuggestSettings
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +54,7 @@ class PartUniqueIpnSubscriber implements EventSubscriber
|
|||
->findOneBy(['ipn' => $part->getIpn()]);
|
||||
|
||||
if ($existingPart && $existingPart->getId() !== $part->getId()) {
|
||||
if ($this->enforceUniqueIpn) {
|
||||
if ($this->ipnSuggestSettings->enableUniqueCheck) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -70,4 +71,4 @@ class PartUniqueIpnSubscriber implements EventSubscriber
|
|||
$part->setIpn($originalIpn . "_$increment");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue