// composer.json
{
"require": {
"php": ">=8.3",
"ext-ctype": "*",
"ext-iconv": "*",
"babdev/pagerfanta-bundle": "^4.0", // v4.4.0
"doctrine/doctrine-bundle": "^2.7", // 2.11.1
"doctrine/doctrine-migrations-bundle": "^3.2", // 3.3.0
"doctrine/orm": "^2.12", // 2.17.3
"knplabs/knp-time-bundle": "^2.2", // v2.2.0
"pagerfanta/doctrine-orm-adapter": "^4.0", // v4.2.0
"pagerfanta/twig": "^4.0", // v4.2.0
"stof/doctrine-extensions-bundle": "^1.7", // v1.10.1
"symfony/asset": "7.0.*", // v7.0.0
"symfony/asset-mapper": "7.0.*", // v7.0.2
"symfony/console": "7.0.*", // v7.0.2
"symfony/dotenv": "7.0.*", // v7.0.2
"symfony/flex": "^2", // v2.4.3
"symfony/framework-bundle": "7.0.*", // v7.0.2
"symfony/http-client": "7.0.*", // v7.0.2
"symfony/messenger": "7.0.*", // v7.0.1
"symfony/monolog-bundle": "^3.0", // v3.10.0
"symfony/runtime": "7.0.*", // v7.0.0
"symfony/scheduler": "7.0.*", // v7.0.0
"symfony/twig-bundle": "7.0.*", // v7.0.0
"symfony/ux-turbo": "^2.0", // v2.13.2
"symfony/yaml": "7.0.*", // v7.0.0
"twig/extra-bundle": "^2.12|^3.0", // v3.8.0
"twig/twig": "^2.12|^3.0" // v3.8.0
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.4", // 3.5.1
"symfony/debug-bundle": "7.0.*", // v7.0.0
"symfony/maker-bundle": "^1.41", // v1.52.0
"symfony/stopwatch": "7.0.*", // v7.0.0
"symfony/web-profiler-bundle": "7.0.*", // v7.0.2
"zenstruck/foundry": "^1.21" // v1.36.1
}
}
3 Comments
Hello, not sure if this belongs here but
I have these 2 deprecations
Since symfony/doctrine-bridge 6.3: Registering "Gedmo\Loggable\LoggableListener" as a Doctrine subscriber is deprecated. Register it as a listener instead, using e.g. the #[AsDoctrineListener] attribute.
User Deprecated: Since symfony/doctrine-bridge 6.3: Registering "Gedmo\Loggable\LoggableListener" as a Doctrine subscriber is deprecated. Register it as a listener instead, using e.g. the #[AsDoctrineListener] or #[AsDocumentListener] attribute.
And this works nicely so if I update field it will version it.
This is my service
But I tried many things but none of them work.
I updated doctrine.event_subscriber to listener
Created new listener and was listening for onFlush
like this:
I managed to get rid of these deprecations but then setting username did not work.
Not sure were I am doing mistake but I just cannot get rid of that message and set username
Sadly I could not find anything on google or in doc.
And this is how Gedmo was changed to attributes from annotations
Entity
Can someone point me to right direction and tell me what I am doing wrong
Hey @Peter-K!
I don't have answer, but it sounds like Doctrine Bridge made some changes. The Gedmo docs have changed I think, to reflect this: https://github.com/doctrine-extensions/DoctrineExtensions/blob/main/doc/symfony.md#doctrine-extension-listener-services
This converts to a listener, like you did, but I believe when a service is manually registered like this, all of the events, like
onFlushneed to be in the service definition (the YAML). I think the attribute above the class is ignored.Let me know if this helps!
Cheers!
Thanks Ryan,
Ive seen that docs and tbf I used it but it is still bit outdated since it is using username for example and it is using subscribers rather than listener and using annotations and not attributes.
But I have a good news, it is working now with listener and attributes.
Not sure why, but when I set priority explicitly for AsDoctrineListener attribute then It will populate username otherwise username is blank.
I still dont understand why but that is why above code did not work so for anyone having similar issue with Gedmo this might be the solution to set priority.
Based on docs https://symfony.com/doc/current/doctrine/events.html priority is set just to determine when it will be executed so I guess LoggableListener priority is smaller than DoctrineEventListener (default = 0) so LoggableListener will set username to null since it is executed early? Not sure just assumption.
DoctrineEventListener
and mapping with services
and finally loggable entity sample
"Houston: no signs of life"
Start the conversation!