|
@@ -34,7 +34,7 @@ discard block |
|
|
block discarded – undo |
|
34
|
34
|
$this->configuration = $configuration; |
|
35
|
35
|
$this->transactionManager = new TransactionManager($this); |
|
36
|
36
|
|
|
37
|
|
- \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
|
37
|
+ \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
38
|
38
|
$this->configuration->setProvider($this); |
|
39
|
39
|
} |
|
40
|
40
|
|
|
@@ -42,7 +42,7 @@ discard block |
|
|
block discarded – undo |
|
42
|
42
|
{ |
|
43
|
43
|
parent::registerAuditingService($service); |
|
44
|
44
|
|
|
45
|
|
- \assert($service instanceof AuditingService); // helps PHPStan |
|
|
45
|
+ \assert($service instanceof AuditingService); // helps PHPStan |
|
46
|
46
|
$entityManager = $service->getEntityManager(); |
|
47
|
47
|
$evm = $entityManager->getEventManager(); |
|
48
|
48
|
|
|
@@ -61,7 +61,7 @@ discard block |
|
|
block discarded – undo |
|
61
|
61
|
public function getAuditingServiceForEntity(string $entity): AuditingServiceInterface |
|
62
|
62
|
{ |
|
63
|
63
|
foreach ($this->auditingServices as $name => $service) { |
|
64
|
|
- \assert($service instanceof AuditingService); // helps PHPStan |
|
|
64
|
+ \assert($service instanceof AuditingService); // helps PHPStan |
|
65
|
65
|
|
|
66
|
66
|
try { |
|
67
|
67
|
// entity is managed by the entity manager of this service |
|
@@ -79,7 +79,7 @@ discard block |
|
|
block discarded – undo |
|
79
|
79
|
{ |
|
80
|
80
|
$this->checkStorageMapper(); |
|
81
|
81
|
|
|
82
|
|
- \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
|
82
|
+ \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
83
|
83
|
$storageMapper = $this->configuration->getStorageMapper(); |
|
84
|
84
|
|
|
85
|
85
|
if (null === $storageMapper || 1 === \count($this->getStorageServices())) { |
|
@@ -87,7 +87,7 @@ discard block |
|
|
block discarded – undo |
|
87
|
87
|
return array_values($this->getStorageServices())[0]; |
|
88
|
88
|
} |
|
89
|
89
|
|
|
90
|
|
- \assert(\is_callable($storageMapper)); // helps PHPStan |
|
|
90
|
+ \assert(\is_callable($storageMapper)); // helps PHPStan |
|
91
|
91
|
|
|
92
|
92
|
return $storageMapper($entity, $this->getStorageServices()); |
|
93
|
93
|
} |
|
@@ -145,7 +145,7 @@ discard block |
|
|
block discarded – undo |
|
145
|
145
|
{ |
|
146
|
146
|
$class = DoctrineHelper::getRealClassName($entity); |
|
147
|
147
|
// is $entity part of audited entities? |
|
148
|
|
- \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
|
148
|
+ \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
149
|
149
|
|
|
150
|
150
|
// no => $entity is not audited |
|
151
|
151
|
return !(!\array_key_exists($class, $this->configuration->getEntities())); |
|
@@ -195,7 +195,7 @@ discard block |
|
|
block discarded – undo |
|
195
|
195
|
public function isAuditedField($entity, string $field): bool |
|
196
|
196
|
{ |
|
197
|
197
|
// is $field is part of globally ignored columns? |
|
198
|
|
- \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
|
198
|
+ \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
199
|
199
|
if (\in_array($field, $this->configuration->getIgnoredColumns(), true)) { |
|
200
|
200
|
// yes => $field is not audited |
|
201
|
201
|
return false; |
|
@@ -233,13 +233,13 @@ discard block |
|
|
block discarded – undo |
|
233
|
233
|
|
|
234
|
234
|
public function setStorageMapper(callable $storageMapper): void |
|
235
|
235
|
{ |
|
236
|
|
- \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
|
236
|
+ \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
237
|
237
|
$this->configuration->setStorageMapper($storageMapper); |
|
238
|
238
|
} |
|
239
|
239
|
|
|
240
|
240
|
public function loadAnnotations(EntityManagerInterface $entityManager, ?array $entities = null): self |
|
241
|
241
|
{ |
|
242
|
|
- \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
|
242
|
+ \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
243
|
243
|
$annotationLoader = new AnnotationLoader($entityManager); |
|
244
|
244
|
$this->configuration->setEntities(array_merge( |
|
245
|
245
|
$entities ?? $this->configuration->getEntities(), |
|
@@ -251,7 +251,7 @@ discard block |
|
|
block discarded – undo |
|
251
|
251
|
|
|
252
|
252
|
private function checkStorageMapper(): self |
|
253
|
253
|
{ |
|
254
|
|
- \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
|
254
|
+ \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
255
|
255
|
if (null === $this->configuration->getStorageMapper() && $this->isStorageMapperRequired()) { |
|
256
|
256
|
throw new ProviderException('You must provide a mapper function to map audits to storage.'); |
|
257
|
257
|
} |