I'm trying to upgrade an app from Symfony 3 to 4 (currently on 3.4), and I'm looking at a deprecation warning regarding Sonata 3 config that I'm not seeing how to fix:
Relying on service auto-registration for type "AppBundle\Entity\Box" is deprecated since Symfony 3.4 and won't be supported in 4.0.
Create a service named "AppBundle\Entity\Box" instead.
-severity: E_USER_DEPRECATED
trace: {
/Users/me/Sites/app-php-7/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php:321 {
› if (!$this->strictMode) {
› return $this->createAutowiredDefinition($type);
› }
}
}
Well, documentation says to not wire Entity classes as services, so I'm scratching my head at the pre-existing Sonata config (in app/config/services/admins.yml):
admin.box:
class: AppBundle\Admin\BoxAdmin
arguments: [ ~, AppBundle\Entity\Box, ~ ]
tags:
- { name: sonata.admin, manager_type: orm, label: Box }
Note that 'Box' here just refers to an example real-world object, like a cardboard box whose data we're saving to a database table
Anyway, I've tried different things, like changing AppBundle\Entity\Box
to '@AppBundle\Entity\Box'
(which of course makes Symfony look for its service which it has no definition for, and crashes the app), or 'AppBundle\Entity\Box'
which doesn't doesn't get rid of the deprecation warning.
I've tried adding container.autowiring.strict_mode: true
to parameters.yml, but to no avail.
I'm completely lost on what to do here. Maybe I've missed something in docs, but I've scoured Symfony 2.8, 3.4, 4.0 docs and Sonata 3.x docs.