xiidea / EasyAuditBundle

A Symfony Bundle To Log Selective Events
http://xiidea.github.io/EasyAuditBundle/
MIT License
88 stars 22 forks source link

Doctrine ODM namespace error #42

Open zvirag opened 5 years ago

zvirag commented 5 years ago

Hi!

I found an issue in latest beta version. I create AuditLog document extends from Model, but didn't work. This is the error message:

The class 'App\\Document\\AuditLog' was not found in the chain configured namespaces App\\Entity, Xiidea\\EasyAuditBundle\\Entity

Thx

cnizzardini commented 3 years ago

I encounter this in version 1.4 with this configuration:

# Read the documentation: http://xiidea.github.io/EasyAuditBundle/
xiidea_easy_audit:
    #entity_class: App\Document\AuditLog
    default_logger: true
    user_property: null # or username
    audit_log_class: App\Document\AuditLog
    doctrine_objects:
        App\Document\Services: [created, updated, deleted]

We are attempting to track updates to a Doctrine MongoDB (ODM) document.

ronisaha commented 3 years ago

@cnizzardini @zvirag can you provide any example repository with this issue, so I can test

cnizzardini commented 3 years ago

For this, I have no custom repository, just a Doctrine ODM document for App\Document\Services. I think this library does not look at App\Document. Uses only settings from doctrine.orm and not doctrine_mongodb.

doctrine:
    dbal:
        url: '%env(resolve:DATABASE_URL)%'

        # IMPORTANT: You MUST configure your db driver and server version,
        # either here or in the DATABASE_URL env var (see .env file)
        driver: 'postgresql'
        server_version: '12'
    orm:
        auto_generate_proxy_classes: true
        naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
        auto_mapping: true
        mappings:
            App:
                is_bundle: false
                type: annotation
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'App\Entity'
                alias: App

versus

doctrine_mongodb:
    auto_generate_proxy_classes: true
    auto_generate_hydrator_classes: true
    connections:
        default:
            server: '%env(resolve:MONGODB_URL)%'
            options: {}
    default_database: '%env(resolve:MONGODB_DB)%'
    document_managers:
        default:
            auto_mapping: true
            # metadata_cache_driver: apcu
            #metadata_cache_driver:
            #    type: redis
            #    class: Doctrine\Common\Cache\RedisCache
            #    host: redisdb
            #    port: 6379
            #    instance_class: Redis
            mappings:
                App:
                    is_bundle: false
                    type: annotation
                    dir: '%kernel.project_dir%/src/Document'
                    prefix: 'App\Document'
                    alias: App
ronisaha commented 3 years ago

@cnizzardini Could you please share the App\Document\AuditLog class

cnizzardini commented 3 years ago

It was copied from here: https://github.com/xiidea/EasyAuditBundle/blob/master/Resources/doc/audit-log-entity-orm.md#or-doctrine-odm-document-class @ronisaha