Comments (4)
Hi @bertoost, auditor
can be used outside of a Symfony project, that's why it doesn't require an autowired Symfony service for storage mapper.
A storage mapper has to be a closure/callable/invokable. It takes 2 parameters: an entity name and an array of storage services. It must return the storage service (from the provided array) handling the provided entity name.
There was a bug until version 2.4.2
which prevented using invokable classes, it's fixed now.
Let me give you an example:
<?php
namespace App;
use App\Entity\MyEntity1;
use App\Entity\MyEntity2;
use App\Entity\MyEntity3;
use DH\Auditor\Provider\Service\StorageServiceInterface;
/**
* MyStorageMapper is an invokable class/service
*
*/
class MyStorageMapper
{
// the service expects 2 parameters and should return an object
// implementing StorageServiceInterface
public function __invoke(string $entity, array $storageServices): StorageServiceInterface {
return \in_array($entity, [MyEntity1::class, MyEntity2::class], true) ? $storageServices['db1'] : $storageServices['db2'];
}
}
Then, if using auditor-bundle
, register it as a storage mapper
# config/packages/dh_auditor.yaml
dh_auditor:
providers:
doctrine:
# Invokable service that maps audit events to storage services
storage_mapper: App\MyStorageMapper
from auditor.
Thanks @DamienHarper ! The storage mapper now works.
I had to report this on the bundle maybe ;-)
Therefore I am now running into this error when running schema-update command of doctrine.
In MappingException.php line 26:
[Doctrine\Persistence\Mapping\MappingException]
The class 'App\Entity\Tenant\Student' was not found in the chain configured namespaces App\Entity\Main
The namespace is configured on the second entity-manager which I do correctly map in the storage mapper.
from auditor.
@bertoost can you provide more debug trace?
from auditor.
@bertoost I close this issue since no feedback has been provided, feel free to reopen it if needed.
from auditor.
Related Issues (20)
- Make DoctrineODM / MongoDB compatible? HOT 1
- Custom columns and custom data in the audit tables
- Example use statement shown for Auditing Configuration in Docs Undefined HOT 1
- Correct timezone on Created_At field HOT 1
- You have requested a non-existent parameter "dh_auditor.provider.doctrine.configuration". HOT 4
- Invalid audit table name with schema
- Inject the entity in the UserProvider HOT 1
- `ignored_columns` as a callback or as a service
- Route name on transaction
- Wrong migration when using Postgres HOT 4
- DoctrineSubscriber throw deprecation when Driver is wrapped with another class HOT 11
- Nested LoggerChain DoctrineSubscriber HOT 3
- Multiple Logs Updates with Decimal values HOT 1
- Mass import generate same hash for all operations
- ORM 3 HOT 3
- Invalid table name on Postgresql
- Update SimpleFilter value type to accept int
- Importing Audit data from another system
- Remove the final keyword for some classes?
- No routes after updating to Symfony 6.4 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from auditor.