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