|
@@ -32,7 +32,7 @@ discard block |
|
|
block discarded – undo |
|
32
|
32
|
$this->configuration = $configuration; |
|
33
|
33
|
$this->transactionManager = new TransactionManager($this); |
|
34
|
34
|
|
|
35
|
|
- \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
|
35
|
+ \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
36
|
36
|
$this->configuration->setProvider($this); |
|
37
|
37
|
} |
|
38
|
38
|
|
|
@@ -40,7 +40,7 @@ discard block |
|
|
block discarded – undo |
|
40
|
40
|
{ |
|
41
|
41
|
parent::registerAuditingService($service); |
|
42
|
42
|
|
|
43
|
|
- \assert($service instanceof AuditingService); // helps PHPStan |
|
|
43
|
+ \assert($service instanceof AuditingService); // helps PHPStan |
|
44
|
44
|
$entityManager = $service->getEntityManager(); |
|
45
|
45
|
$evm = $entityManager->getEventManager(); |
|
46
|
46
|
|
|
@@ -59,7 +59,7 @@ discard block |
|
|
block discarded – undo |
|
59
|
59
|
public function getAuditingServiceForEntity(string $entity): AuditingServiceInterface |
|
60
|
60
|
{ |
|
61
|
61
|
foreach ($this->auditingServices as $name => $service) { |
|
62
|
|
- \assert($service instanceof AuditingService); // helps PHPStan |
|
|
62
|
+ \assert($service instanceof AuditingService); // helps PHPStan |
|
63
|
63
|
|
|
64
|
64
|
try { |
|
65
|
65
|
// entity is managed by the entity manager of this service |
|
@@ -77,7 +77,7 @@ discard block |
|
|
block discarded – undo |
|
77
|
77
|
{ |
|
78
|
78
|
$this->checkStorageMapper(); |
|
79
|
79
|
|
|
80
|
|
- \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
|
80
|
+ \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
81
|
81
|
$storageMapper = $this->configuration->getStorageMapper(); |
|
82
|
82
|
|
|
83
|
83
|
if (null === $storageMapper || 1 === \count($this->getStorageServices())) { |
|
@@ -128,7 +128,7 @@ discard block |
|
|
block discarded – undo |
|
128
|
128
|
|
|
129
|
129
|
// let's get the last inserted ID from the database so other providers can use that info |
|
130
|
130
|
$payload = $event->getPayload(); |
|
131
|
|
- $payload['id'] = (int)$storageService->getEntityManager()->getConnection()->lastInsertId(); |
|
|
131
|
+ $payload['id'] = (int) $storageService->getEntityManager()->getConnection()->lastInsertId(); |
|
132
|
132
|
$event->setPayload($payload); |
|
133
|
133
|
} |
|
134
|
134
|
|
|
@@ -141,7 +141,7 @@ discard block |
|
|
block discarded – undo |
|
141
|
141
|
{ |
|
142
|
142
|
$class = DoctrineHelper::getRealClassName($entity); |
|
143
|
143
|
// is $entity part of audited entities? |
|
144
|
|
- \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
|
144
|
+ \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
145
|
145
|
if (!\array_key_exists($class, $this->configuration->getEntities())) { |
|
146
|
146
|
// no => $entity is not audited |
|
147
|
147
|
return false; |
|
@@ -193,7 +193,7 @@ discard block |
|
|
block discarded – undo |
|
193
|
193
|
public function isAuditedField($entity, string $field): bool |
|
194
|
194
|
{ |
|
195
|
195
|
// is $field is part of globally ignored columns? |
|
196
|
|
- \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
|
196
|
+ \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
197
|
197
|
if (\in_array($field, $this->configuration->getIgnoredColumns(), true)) { |
|
198
|
198
|
// yes => $field is not audited |
|
199
|
199
|
return false; |
|
@@ -235,13 +235,13 @@ discard block |
|
|
block discarded – undo |
|
235
|
235
|
|
|
236
|
236
|
public function setStorageMapper(callable $storageMapper): void |
|
237
|
237
|
{ |
|
238
|
|
- \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
|
238
|
+ \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
239
|
239
|
$this->configuration->setStorageMapper($storageMapper); |
|
240
|
240
|
} |
|
241
|
241
|
|
|
242
|
242
|
public function loadAnnotations(EntityManagerInterface $entityManager, ?array $entities = null): self |
|
243
|
243
|
{ |
|
244
|
|
- \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
|
244
|
+ \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
245
|
245
|
$annotationLoader = new AnnotationLoader($entityManager); |
|
246
|
246
|
$this->configuration->setEntities(array_merge( |
|
247
|
247
|
null === $entities ? $this->configuration->getEntities() : $entities, |
|
@@ -253,7 +253,7 @@ discard block |
|
|
block discarded – undo |
|
253
|
253
|
|
|
254
|
254
|
private function checkStorageMapper(): self |
|
255
|
255
|
{ |
|
256
|
|
- \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
|
256
|
+ \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
257
|
257
|
if (null === $this->configuration->getStorageMapper() && $this->isStorageMapperRequired()) { |
|
258
|
258
|
throw new ProviderException('You must provide a mapper function to map audits to storage.'); |
|
259
|
259
|
} |