If you have autowiring turned on, there are failures in the Abstract Admin class.
Cannot autowire service "AppBundle\Admin\SomeAdmin": argument "$code" of method "Sonata\AdminBundle\Admin\AbstractAdmin::__construct()" must have a type-hint or be given a value explicitly.
Is there any way around this, if autowiring is being used?
Hello @spacetraveller.
Did you managed to find a solution for your problem?
If not, please post the full stacktrace of your error, and the config related.
Hi jlamur,
I didn't find a solution, so decided against using Sonata Admin for this project, unfortunately. I've used it on other projects, but did not make use of autowiring.
To reproduce it, I believe all you need to do is have autowiring on a service. So create a service class, and autowire it in the class as so:
public function __construct(EntityManager $em, ContainerInterface $container)
{
$this->em = $em;
$this->container = $container;
}
Sonata Admin starts to throw errors when this method is used in Symfony 3.3
I think the original problem with autowiring an admin class is that the arguments are all string arguments and autowiring is not able to resolve the constructor arguments.
@spacetraveller Please next time follow the issue template. Right now we don't have any information for your issue and can't help you at all.
This kind of issue are generaly closed if not updated.
For this one, please follow #4710
How I solved it:
I had:
_defaults:
public:true
I had to change it to:
_defaults:
public:false
and then make each the required service public:true individually.