|
@@ -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())) { |
|
@@ -95,8 +95,8 @@ discard block |
|
|
block discarded – undo |
|
95
|
95
|
$entity = $payload['entity']; |
|
96
|
96
|
unset($payload['table'], $payload['entity']); |
|
97
|
97
|
|
|
98
|
|
- $fields = array_combine(array_keys($payload), array_map(function ($x) {return ":{$x}"; }, array_keys($payload))); |
|
99
|
|
- \assert(\is_array($fields)); // helps PHPStan |
|
|
98
|
+ $fields = array_combine(array_keys($payload), array_map(function($x) {return ":{$x}"; }, array_keys($payload))); |
|
|
99
|
+ \assert(\is_array($fields)); // helps PHPStan |
|
100
|
100
|
|
|
101
|
101
|
$query = sprintf( |
|
102
|
102
|
'INSERT INTO %s (%s) VALUES (%s)', |
|
@@ -125,7 +125,7 @@ discard block |
|
|
block discarded – undo |
|
125
|
125
|
{ |
|
126
|
126
|
$class = DoctrineHelper::getRealClassName($entity); |
|
127
|
127
|
// is $entity part of audited entities? |
|
128
|
|
- \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
|
128
|
+ \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
129
|
129
|
if (!\array_key_exists($class, $this->configuration->getEntities())) { |
|
130
|
130
|
// no => $entity is not audited |
|
131
|
131
|
return false; |
|
@@ -177,7 +177,7 @@ discard block |
|
|
block discarded – undo |
|
177
|
177
|
public function isAuditedField($entity, string $field): bool |
|
178
|
178
|
{ |
|
179
|
179
|
// is $field is part of globally ignored columns? |
|
180
|
|
- \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
|
180
|
+ \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
181
|
181
|
if (\in_array($field, $this->configuration->getIgnoredColumns(), true)) { |
|
182
|
182
|
// yes => $field is not audited |
|
183
|
183
|
return false; |
|
@@ -219,13 +219,13 @@ discard block |
|
|
block discarded – undo |
|
219
|
219
|
|
|
220
|
220
|
public function setStorageMapper(callable $storageMapper): void |
|
221
|
221
|
{ |
|
222
|
|
- \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
|
222
|
+ \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
223
|
223
|
$this->configuration->setStorageMapper($storageMapper); |
|
224
|
224
|
} |
|
225
|
225
|
|
|
226
|
226
|
public function loadAnnotations(EntityManagerInterface $entityManager, ?array $entities = null): self |
|
227
|
227
|
{ |
|
228
|
|
- \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
|
228
|
+ \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
229
|
229
|
$annotationLoader = new AnnotationLoader($entityManager); |
|
230
|
230
|
$this->configuration->setEntities(array_merge( |
|
231
|
231
|
null === $entities ? $this->configuration->getEntities() : $entities, |
|
@@ -237,7 +237,7 @@ discard block |
|
|
block discarded – undo |
|
237
|
237
|
|
|
238
|
238
|
private function checkStorageMapper(): self |
|
239
|
239
|
{ |
|
240
|
|
- \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
|
240
|
+ \assert($this->configuration instanceof Configuration); // helps PHPStan |
|
241
|
241
|
if (null === $this->configuration->getStorageMapper() && $this->isStorageMapperRequired()) { |
|
242
|
242
|
throw new ProviderException('You must provide a mapper function to map audits to storage.'); |
|
243
|
243
|
} |