Closed oleg-andreyev closed 5 months ago
Same here, but in different context
User Deprecated: Method Doctrine\ORM\Event\OnFlushEventArgs::getEntityManager() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead. (OnFlushEventArgs.php:34 called by ORM.php:98, https://github.com/doctrine/orm/issues/9875, package doctrine/orm)
Any possible updates on this?
Waiting for any update too
This is not deprecated in Doctrine itself. However, Symfony has deprecated registering Doctrine subscribers because they cannot be lazy-loaded (contrary to Symfony subscribers, the Doctrine ones require instantiating the object to get the list of subscribed events).
In https://packagist.org/packages/stof/doctrine-extensions-bundle, I already updated the way listeners are registered to be compatible with this lazy-loading (include tests that will ensure that the explicit registration is in sync with the library subscriber). If you manage the listener yourselves instead of using the bundle, you need to manage the registration yourselves.
Just found my answer in the documentation : https://github.com/doctrine-extensions/DoctrineExtensions/blob/main/doc/symfony.md#doctrine-extension-listener-services
Needed to update the config in services.yaml
@LaurentSanson I get
The service "gedmo.listener.tree" has a dependency on a non-existent service "annotation_reader"
how did you solve it?
@mcanepa ,
You could just remove the call to annotation reader that you've set in your config file, or better option, use the @stof 's bundle properly and in hisstof_doctrine_extensions_yaml
set something like this :
# Read the documentation: https://symfony.com/doc/current/bundles/StofDoctrineExtensionsBundle/index.html
# See the official DoctrineExtensions documentation for more details: https://github.com/doctrine-extensions/DoctrineExtensions/tree/main/doc
stof_doctrine_extensions:
default_locale: fr_FR
orm:
default:
timestampable: true
sluggable: true
It should works just fine
@LaurentSanson I did both:
In config/services.yaml I removed
calls:
- [ setAnnotationReader, [ "@annotation_reader" ] ]
and instead of using
gedmo.listener.timestampable:
class: Gedmo\Timestampable\TimestampableListener
tags:
- { name: doctrine.event_listener, event: 'prePersist' }
- { name: doctrine.event_listener, event: 'onFlush' }
- { name: doctrine.event_listener, event: 'loadClassMetadata' }
I used config/stof_doctrine_extensions.yaml
stof_doctrine_extensions:
default_locale: en_US
orm:
default:
timestampable: true
now TimestampableEntity trait works but only for POST operation, it fails on PUT. I get
An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'created_at' cannot be null"
I think you can get rid of the calling of timestampable in your services.yaml
as it is enabled in stof_doctrine_extensions.yaml
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Environment
Package
show
``` Info from https://repo.packagist.org: #StandWithUkraine name : gedmo/doctrine-extensions descrip. : Doctrine behavioral extensions keywords : Blameable, behaviors, doctrine, extensions, gedmo, loggable, nestedset, odm, orm, sluggable, sortable, timestampable, translatable, tree, uploadable versions : * v3.13.0 latest : v3.13.0 type : library license : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText homepage : http://gediminasm.org/ source : [git] https://github.com/doctrine-extensions/DoctrineExtensions.git 291d0c527d2dc9ee07b888c9a4e2a179893f08ab dist : [zip] https://api.github.com/repos/doctrine-extensions/DoctrineExtensions/zipball/291d0c527d2dc9ee07b888c9a4e2a179893f08ab 291d0c527d2dc9ee07b888c9a4e2a179893f08ab path : /app/vendor/gedmo/doctrine-extensions names : gedmo/doctrine-extensions ```
Doctrine packages
show
``` Color legend: - patch or minor release available - update recommended - major release available - update possible - up to date version Direct dependencies required in composer.json: doctrine/annotations 2.0.1 2.0.1 Docblock Annotations Parser doctrine/doctrine-bundle 2.10.2 2.10.2 Symfony DoctrineBundle doctrine/doctrine-migrations-bundle 3.2.4 3.2.4 Symfony DoctrineMigrationsBundle doctrine/orm 2.16.2 2.16.2 Object-Relational-Mapper for PHP Transitive dependencies not required in composer.json: doctrine/cache 2.2.0 2.2.0 PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others. doctrine/collections 1.8.0 2.1.3 PHP Doctrine Collections library that adds additional functionality on top of PHP arrays. doctrine/common 3.4.3 3.4.3 PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as better reflection support, proxies and ... doctrine/dbal 3.6.7 3.7.0 Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management. doctrine/deprecations v1.1.1 1.1.2 A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages. doctrine/event-manager 2.0.0 2.0.0 The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects. doctrine/inflector 2.0.8 2.0.8 PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words. doctrine/instantiator 2.0.0 2.0.0 A small, lightweight utility to instantiate objects in PHP without invoking their constructors doctrine/lexer 2.1.0 3.0.0 PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers. doctrine/migrations 3.6.0 3.6.0 PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and easily deployin... doctrine/persistence 3.2.0 3.2.0 The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share. doctrine/sql-formatter 1.1.3 1.1.3 a PHP SQL highlighting library ```
PHP version
Subject
Minimal repository with the bug
Steps to reproduce
Expected results
Actual results